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

The result of pvc memory usage is not religious #1381

Open
zhujian7 opened this issue Feb 17, 2020 · 2 comments
Open

The result of pvc memory usage is not religious #1381

zhujian7 opened this issue Feb 17, 2020 · 2 comments

Comments

@zhujian7
Copy link
Collaborator

zhujian7 commented Feb 17, 2020

Cyclone use du -sh to get memory usage, read the annotation of -h for du command:

-h "Human-readable" output. Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte.

Please pay attention to the unit : Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte. Instead of Kibibyte, Mebibyte, Gibibyte, Tebibyte and Pebibyte.

Unfortunately, we use the following formula to calculate:

var unitMap = map[byte]int64{
	'B': 1,
	'K': 1024,
	'M': 1024 * 1024,
	'G': 1024 * 1024 * 1024,
	'T': 1024 * 1024 * 1024 * 1024,
}

And It is obviously wrong, since 1 Mebibyte=1000Kibibyte (1M=1000K).

There are two ways to fix it:

  • correct the formula from 1 Mebibyte=**1024**Kibibyte to 1 Mebibyte=**1000**Kibibyte
  • find a way to get PVC usage with Kibibyte, Mebibyte unit.

Related Reads:

/kind bug

What happened:

What you expected to happen:

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:
@supereagle @hyy0322 @qiuxiaolian

@zhujian7 zhujian7 changed the title The unit of pvc usage is not religious The result of pvc memory usage is not religious Feb 17, 2020
@supereagle
Copy link
Member

What are the preferred units? Could we convert to these preferred units after 'du -sh'?

@zhujian7
Copy link
Collaborator Author

zhujian7 commented Feb 17, 2020

A piece of output of man du:

...
       Display values are in units of the first available SIZE from --block-size, and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.  Otherwise, units default to 1024  bytes  (or
       512 if POSIXLY_CORRECT is set).

       SIZE is an integer and optional unit (example: 10M is 10*1024*1024).  Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).
...

So I rethought the description of the issue is wrong
And It is obviously wrong, since 1 Mebibyte=1000Kibibyte (1M=1000K).

The implementation of command du treats 1M=1024K. So I think the only thing we need to do is change the unit from K M G T to Ki Mi Gi Ti to make them more readable. Besides Kubernetes uses Ki Mi Gi Ti instead of K M G T as memory units:
Unit of Memory in Kubernetes

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

No branches or pull requests

2 participants