Why does TiKV's configuration need to distinguish between MiB|GiB and MB|GB? Shouldn't this configuration be the same?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 为什么TiKV的配置需要区分MiB|GiB和MB|GB,这个配置不是应该一样的才对?

| username: ojbk

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version] 5.4.3
[Reproduction Path] None
[Issue Encountered: Why is it necessary to distinguish between MB/MiB, GB/GiB in the configuration options?]
In the configuration, different data volume options require the use of different units, such as MB and MiB, but in practice, they should be the same.

Why is it necessary to separate them here?
[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]



| username: tidb菜鸟一只 | Original post link

I don’t understand, 100KB and 100MB are definitely different, right?

| username: 裤衩儿飞上天 | Original post link

It’s convenient to configure.
For example: when you configure 996M, you don’t need to calculate the byte size by 99610241024 and then paste a string of numbers :crazy_face:

| username: ojbk | Original post link

Logically, MiB and MB should be the same, so why does the documentation distinguish between MiB and MB?

| username: tidb菜鸟一只 | Original post link

It’s just a different way of writing. Whether you write MiB or MB, they are recognized the same way. Just like writing 1024KB, 1MB, and 1MiB, they are all the same.

| username: buptzhoutian | Original post link

Why does the official use two different units? I don’t know, maybe using consistent units would be better.

Difference between MiB and MB:

  • MiB is binary, according to IEC 60027-2 International Electrotechnical Commission standard for letter symbols used in electrical technology.
  • MB is decimal, according to the International System of Units (SI) prefix standard.
| username: buptzhoutian | Original post link

No, the literal meaning is different. I don’t know if the official implementation is really based on the literal meaning.

| username: Kongdom | Original post link

I think it should mainly be for convenience.

| username: tidb菜鸟一只 | Original post link

MiB and MB are both units of computer storage capacity, but they have different meanings.

MiB, short for Mebibyte, is a binary unit equal to 2^20 (i.e., 1,048,576) bytes. MiB is based on the binary system and is mainly used for measuring computer memory and network bandwidth.

MB, short for Megabyte, is a decimal unit equal to 10^6 (i.e., 1,000,000) bytes. MB is based on the decimal system and is mainly used for measuring the capacity of storage media, such as hard drives, optical discs, USB flash drives, etc.

Therefore, in the field of computing, MiB and MB have different meanings, and their conversion relationship is:
1 MB = 10^6 bytes
1 MiB = 2^20 bytes

Thus, 1 MiB is not equal to 1 MB but is slightly larger, approximately 1.05 MB. In the computing field, to avoid confusion and misunderstanding, MiB is usually used to represent memory capacity and network bandwidth measurements, while MB is used to represent storage media capacity measurements.

| username: buptzhoutian | Original post link

You replied to the wrong person, why did you reply to me?

| username: 我是咖啡哥 | Original post link

Let me share my thoughts, haha.
MB doesn’t need much explanation, it’s the most commonly used.
MiB is generally used for configuring memory size in k8s, and since TiDB also supports k8s deployment, this unit is used. :grimacing: