Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-15375][core] Improve MemorySize to print / parse with better readability. #10785

Conversation

xintongsong
Copy link
Contributor

@xintongsong xintongsong commented Jan 7, 2020

What is the purpose of the change

This PR improves readability and usability of MemorySize.

Brief change log

  • 70b2119: Code clean-up in TaskExecutorResourceUtilsTest. Remove unnecessary usage of MemorySize#toString.
  • 9245f66: Introduce MemorySize#toHumanReadableString
  • 57539a3: Use MemorySize#toHumanReadableString for logs and error messages.
  • 65aaf3d: Introduce factory method for creating MemorySize from mebibytes conveniently.

Verifying this change

  • Add cases in MemorySizeTest

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (no)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (not applicable)

@xintongsong
Copy link
Contributor Author

cc @azagrebin

@flinkbot
Copy link
Collaborator

flinkbot commented Jan 7, 2020

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit bfb11ff (Tue Jan 07 07:46:39 UTC 2020)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.


The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Jan 7, 2020

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run travis re-run the last Travis build
  • @flinkbot run azure re-run the last Azure build

@xintongsong
Copy link
Contributor Author

@tillrohrmann The PR is ready for review. Could you take a look at your convenience?

@tillrohrmann tillrohrmann self-assigned this Jan 17, 2020
Copy link
Contributor

@tillrohrmann tillrohrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for updating this PR @xintongsong. The changes look good. The only question I had was whether the human readable string should have the format %.3f%s (%d bytes) instead of %.3f%s (%d). What do you think?

.filter(idx -> bytes > ORDERED_UNITS.get(idx).getMultiplier())
.boxed()
.max(Comparator.naturalOrder())
.map(idx -> ORDERED_UNITS.get(idx))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could be replaced with lambda method reference.

} else {
double approximate = 1.0 * bytes / highestUnit.getMultiplier();
return String.format(
"%.3f%s (%d)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add %.3f%s (%d bytes)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought people could easily understand that the value in the parentheses are they exact bytes. But true, it would be better to explicitly add the unit.

@xintongsong xintongsong force-pushed the FLINK-15375-print-parse-memory-size branch from 72f09ab to 9ac1d96 Compare January 18, 2020 02:11
@xintongsong
Copy link
Contributor Author

@tillrohrmann, thanks for the review. I've addressed your comments.

@tillrohrmann
Copy link
Contributor

Thanks for addressing my comments @xintongsong. Merging this PR now.

@tillrohrmann tillrohrmann force-pushed the FLINK-15375-print-parse-memory-size branch from 9ac1d96 to 53d6a43 Compare January 21, 2020 13:05
tillrohrmann pushed a commit to tillrohrmann/flink that referenced this pull request Jan 21, 2020
tillrohrmann pushed a commit that referenced this pull request Jan 21, 2020
JTaky pushed a commit to JTaky/flink that referenced this pull request Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment