Skip to content

[SPARK-20691][CORE] Difference between Storage Memory as seen internally and in web UI - #18229

Closed
mkesselaers wants to merge 8 commits into
apache:masterfrom
mkesselaers:SPARK-20691
Closed

[SPARK-20691][CORE] Difference between Storage Memory as seen internally and in web UI#18229
mkesselaers wants to merge 8 commits into
apache:masterfrom
mkesselaers:SPARK-20691

Conversation

@mkesselaers

Copy link
Copy Markdown

What changes were proposed in this pull request?

Changed the Strings from MegaBytes to MebiBytes (and likewise for other sizes)

Please review http://spark.apache.org/contributing.html before opening a pull request.

@mkesselaers
Changed the Strings from MegaBytes to MebiBytes (and likewise for other sizes)
@srowen

Copy link
Copy Markdown
Member

No, this is wrong. The function is still computing megabytes, etc.
Did you see my comment in JIRA? there is more to this change.

@mkesselaers
Changed the calculation of bytesToString towards MebiBytes instead of Megabytes
@mkesselaers
Changed the result string to indicate MebiBytes
@mkesselaers

Copy link
Copy Markdown
Author

@srowen , my apologies, I must have misunderstood you.
I changed the calculation to be MebiBytes, but afterwards saw in the tests that the calculation was already correct
test("bytesToString") { assert(Utils.bytesToString(10) === "10.0 B") assert(Utils.bytesToString(1500) === "1500.0 B") assert(Utils.bytesToString(2000000) === "1953.1 KB") assert(Utils.bytesToString(2097152) === "2.0 MB") assert(Utils.bytesToString(2306867) === "2.2 MB") assert(Utils.bytesToString(5368709120L) === "5.0 GB") assert(Utils.bytesToString(5L * (1L << 40)) === "5.0 TB") assert(Utils.bytesToString(5L * (1L << 50)) === "5.0 PB") assert(Utils.bytesToString(5L * (1L << 60)) === "5.0 EB") assert(Utils.bytesToString(BigInt(1L << 11) * (1L << 60)) === "2.36E+21 B") }

Can you please help me with the one?

@mkesselaers
Update the test to take into account the newly returned String
@srowen

Copy link
Copy Markdown
Member

Those tests are wrong, in that 2000000 bytes is not "1953.1 KB". It is "1953.1 KiB". And so on. The numbers should stay the same to make sure behavior doesn't actually change, but the labels should be fixed.

The utils.js correctly computed MB, etc, but, it should compute MiB and label it as such, for consistency. This was the original issue.

@mkesselaers
formatBytes should calculate MiB instead of MB.
@mkesselaers

Copy link
Copy Markdown
Author

OK, the tests are fixed to take this into account.
BytesToString, now correctly output "KiB" instead of "KB" and utils.js now also calculates the correct value.

There is still a small difference between BytesToString and FormatBytes, because the first only goes towards a higher size when it is at least 2 MiB, fe.
Should we adapt this as well?

@srowensrowen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's looking good. It may be worth searching the code for any other instances of "KB" to see if anything else is formatting numbers inconsistently.

I think this is a safe fix because it is cosmetic.

@mkesselaers

Copy link
Copy Markdown
Author

@srowen ,
I propose to rewrite the variable names of bytesToString as well, to be consistent.
Other occurences of KB can be found in the ivy-report.xsl and in the ByteSuffixes of JavaUtils.
Since there seems to be a lot of logic behind the JavaUtils, I would not change this.

@mkesselaers
Changed the variable names to reflect the difference between MegaBytes en MebiBytes
@mkesselaers

Copy link
Copy Markdown
Author

@srowen , I changed the variable names for bytesToString.
As far as I see, this should be everything.

@SparkQA

Copy link
Copy Markdown

Test build #3783 has finished for PR 18229 at commit 71c2bbe.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen

Copy link
Copy Markdown
Member

@mkesselaers looks like there is at least one more test testing the formatted string that will need to be updated

@mkesselaers
Fixed filling test
@mkesselaers

Copy link
Copy Markdown
Author

@srowen, you're right. I changed the strings there as well.

@SparkQA

Copy link
Copy Markdown

Test build #3784 has finished for PR 18229 at commit dd9cc4d.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen

Copy link
Copy Markdown
Member

@kishorvpatil@wzhfy do you have any thoughts on this? it touches some code you created

@wzhfy

wzhfy commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

I agree with changing the base 1000 to 1024. About MiB and MB, strictly speaking, they are different. But I think in the computing technology world, most people say Megabyte (MB) instead of Mebibytes even though they know the difference. MiB may seem rare for many users.
That's only my personal thoughts, I don't have strong disagreement on this.

@jiangxb1987

Copy link
Copy Markdown
Contributor

@mkesselaers are you still working on this?

@kiszk

kiszk commented Oct 6, 2017

Copy link
Copy Markdown
Member

gentle ping @mkesselaers

@vanzinvanzin mentioned this pull request May 11, 2018
@AmplabJenkins

Copy link
Copy Markdown

Can one of the admins verify this patch?

@HyukjinKwon

Copy link
Copy Markdown
Member

gentle ping @mkesselaers

@HyukjinKwonHyukjinKwon mentioned this pull request Jul 16, 2018
zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 22, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@mkesselaers@srowen@SparkQA@wzhfy@jiangxb1987@kiszk@AmplabJenkins@HyukjinKwon