Skip to content

Switch to kB, MB, GB (as opposed to kiB, MiB, GiB) in vm_memory_monitor where possible #1235

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

Closed
wants to merge 2 commits into from

Conversation

dcorbacho
Copy link
Contributor

Closes #1233

rabbitmq-server#1233
[#146160779]
@dcorbacho dcorbacho requested a review from michaelklishin May 26, 2017 14:41
@michaelklishin michaelklishin changed the title Use MB as 1000000 Define "1 MB" as 1000000 (instead of 1 MiB) May 26, 2017
@michaelklishin
Copy link
Collaborator

There is a bunch of other places that imply mebibytes/gibibytes, e.g.

parse_line_linux(Line) ->
and
list_to_integer(Value1) * ?ONE_MB * 1024;
.

Should also we switch other places to the currently defined IEC value of 1 kilobytes/megabyte/gigabyte?

@michaelklishin
Copy link
Collaborator

According to Red Hat documentation, /proc/meminfo actually reports values in kibibytes when it says "kilobyte". I wouldn't be surprised if more OS'es did the same. So this needs an investigation first.

…vm_memory_monitor

Note that when parsing /proc/meminfo output we still use kibibytes, mebibytes,
etc because that's what the values actually mean according ot RHEL documentation:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-proc-meminfo.html.
@michaelklishin michaelklishin changed the title Define "1 MB" as 1000000 (instead of 1 MiB) Switch to kB, MB, GB (as opposed to kiB, MiB, GiB) in vm_memory_monitor where possible May 26, 2017
@dumbbell
Copy link
Collaborator

dumbbell commented Jun 2, 2017

According to Red Hat documentation, /proc/meminfo actually reports values in kibibytes when it says "kilobyte". I wouldn't be surprised if more OS'es did the same. So this needs an investigation first.

I believe this is true for most cases. Historically, "kilobytes", "megabytes" and so on were used to qualify values base on power-of-two units. Only persistent storage device makers used SI units on their products. For instance a hard disk of 80 GB is exactly what it says: 80,000,000,000 bytes, unlike what people expected (80 x 1024 x 1024 x 1024 = 85899345920 bytes).

The power-of-two units were introduced in 1998 [1][2] and it took time for people to start to use them. Now, applications usually report the same power-of-two-based values but might have fixed the unit to display "kiB", "MiB", "GiB", ...

IMHO we should do the same: keep the power-of-two-based values and fix the unit we display or document, because nobody uses the power-of-ten values, even if the unit is spelled "MB".

[1] https://en.wikipedia.org/wiki/Mebibyte
[2] http://physics.nist.gov/cuu/Units/binary.html

@lukebakken
Copy link
Collaborator

FWIW, I always assume MB means 2^20 (the power-of-two value) unless docs say otherwise. I think the values should remain power-of-two (kiB, MiB, GiB) and if the power-of-ten abbreviations are displayed, they could be switched to the IEC abbreviations.

Check out the man page for dd as yet another example of potential confusion:

N and BYTES may be followed by the following multiplicative suffixes: c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M, GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.

@michaelklishin
Copy link
Collaborator

We decided to not change the calculations and instead change the unit we display (to be MiB, GiB, etc) and log.

The reason for that was mentioned by @dumbbell in #1235 (comment): there is plenty of existing tools that use kibibytes, mebibytes, etc at the OS, filesystem, networking layers. Some tools (e.g. /proc/meminfo) claim to use kilobytes but actually use kibibytes.

Some monitoring tools (e.g. Data Dog) use MiB, GiB values as well. So switching to kB, MB, GB may end up making things more confusing, not less.

Sign up for free to 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.

4 participants