Skip to content

Foundations · Chapter F.8

Units: kilo, kibi and friends

Decimal SI prefixes and binary IEC prefixes (KB vs KiB), why a 1 TB disk shows up as 931 GiB, bits versus bytes in network speeds, nanoseconds and gigahertz, and a table of real latencies measured on this site, from a 0.9 ns cache hit to a 20 ms network round trip.

Computing spans absurd ranges: a transistor switches in picoseconds, a disk holds terabytes, a supercomputer does 10¹⁸ operations per second. Prefixes like kilo, giga and nano make those numbers manageable, but in computing some of them have two meanings, and bits and bytes are easy to confuse. This chapter sorts it out, and ends with a table of how long common operations really take.

SI prefixes

The International System of Units (SI) defines prefixes for powers of 1,000:

PrefixSymbolFactorPrefixSymbolFactor
kilok10³millim10⁻³
megaM10⁶microµ10⁻⁶
gigaG10⁹nanon10⁻⁹
teraT10¹²picop10⁻¹²
petaP10¹⁵femtof10⁻¹⁵
exaE10¹⁸attoa10⁻¹⁸
zettaZ10²¹zeptoz10⁻²¹
yottaY10²⁴yoctoy10⁻²⁴
ronnaR10²⁷rontor10⁻²⁷
quettaQ10³⁰quectoq10⁻³⁰

The symbols are case-sensitive: kilo is a lowercase k, and m (milli) and M (mega) differ by a factor of a billion. Micro uses the Greek letter µ, written u when only ASCII is available (us for microseconds). The prefixes long stopped at yotta and yocto; ronna, quetta, ronto and quecto were added in 2022, driven partly by the growth of worldwide data storage.

Binary prefixes

Memory comes in powers of two, because an address with n bits reaches exactly 2ⁿ locations. 2¹⁰ = 1,024 is close to 1,000, so early on "kilobyte" came to mean 1,024 bytes when talking about memory. The approximation gets worse at each step:

Decimal (SI)ValueBinary (IEC)ValueDifference
kilobyte, kB10³kibibyte, KiB2¹⁰ = 1,0242.4 %
megabyte, MB10⁶mebibyte, MiB2²⁰ = 1,048,5764.9 %
gigabyte, GB10⁹gibibyte, GiB2³⁰ = 1,073,741,8247.4 %
terabyte, TB10¹²tebibyte, TiB2⁴⁰ = 1,099,511,627,77610.0 %

To end the ambiguity, the IEC defined the binary prefixes kibi, mebi, gibi, tebi (Ki, Mi, Gi, Ti, for "kilo binary" and so on) in 1998. The industry was slow to adopt the new names, and KB, MB and GB long remained the usual way to write powers of two. Since then, adoption has grown, if unevenly: on Linux, free -h prints Gi, while df -h and ls -h compute in powers of 1,024 but print a bare G or K; macOS's df -h prints Gi. Disk sizes, unlike memory sizes, don't use the binary meaning: drive makers have used decimal units for decades.

Who means what today

The practical rule: memory is binary, storage and networks are decimal. On the Mac this chapter was written on:

  • Memory: sysctl hw.memsize reports 68,719,476,736 bytes. That's exactly 64 GiB, and Apple sells it as "64 GB".
  • Pages are 16 KiB (16,384 bytes), cache lines 128 bytes, and each performance core has a 128 KiB L1 data cache and shares a 16 MiB L2: all powers of two.
  • The SSD: diskutil info disk0 reports "1.0 TB (1000555581440 Bytes)", decimal, as the manufacturer counts.

Operating systems disagree on how to display sizes. macOS's Finder has used decimal units since 2009. Windows computes in binary but writes "GB". On the command line, the same volume on the Mac shows as 926Gi with df -h (binary) and 995G with df -H (decimal).

Why a 1 TB disk shows 931 GB

A disk sold as 1 TB holds 10¹² bytes. Windows divides by 2³⁰ and labels the result "GB":

10¹² bytes ÷ 1,073,741,824 bytes/GiB = 931.3 GiB

No space is missing: 931.3 GiB and 1,000 GB are the same number of bytes, counted in different units. This Mac's SSD, at 1,000,555,581,440 bytes, is 931.8 GiB. The gap grows with size: a "4 TB" drive is 3.64 TiB. What you can actually use is a bit less again, because the file system keeps space for its own structures, and the operating system occupies some of it.

Bits and bytes

A lowercase b means bits, an uppercase B means bytes, and there are 8 bits in a byte. Network speeds are quoted in bits per second, with decimal prefixes: gigabit Ethernet carries 10⁹ bits per second, and a "500 Mb/s" internet plan carries 500 million bits per second. File sizes and download progress are shown in bytes per second. Divide by 8 to convert:

1 Gb/s ÷ 8 = 125 MB/s        (before protocol overhead)
500 Mb/s ÷ 8 = 62.5 MB/s

Headers, acknowledgments and retransmissions take their share, so a transfer never quite reaches that. Speeds are often written kbps and Mbps; you'll also see kbit/s and Mb/s. Watch out for storage interfaces, which also quote bits: a "10 Gbps" USB port is 10 gigabits per second.

Time and frequency

Computer time is measured in small units:

UnitSecondsWhat happens in about that time
picosecond, ps10⁻¹²a logic gate switches
nanosecond, ns10⁻⁹a few clock cycles; an L1 cache hit
microsecond, µs10⁻⁶a context switch; an SSD read (tens of µs)
millisecond, ms10⁻³a hard disk seek; a network round trip across a country

Frequency is the inverse of a period: a clock at f hertz ticks every 1/f seconds. A 1 GHz clock has a 1 ns period; at 4 GHz, a cycle takes 250 ps. On the M2, a chain of dependent additions, each needing the previous result, ran at 0.31 ns per addition: one per cycle, so the performance cores were running at about 3.3 GHz during the test. Light, the fastest anything can travel, covers about 30 cm per nanosecond in vacuum, and about 9 cm during one 0.3 ns cycle, less in a wire. That's one of the reasons why chips are small and why memory is far away in cycles, as the clock chapter and the signals on wires chapter discuss.

Another clock on the same Mac, the timebase that mach_absolute_time counts, runs at 24 MHz (sysctl hw.tbfrequency): one tick every 41.7 ns.

How long things take

The numbers below were measured on the Apple M2 Ultra this site is written on, in this chapter or in the chapters linked. The last column scales them so that 1 ns becomes 1 second, which makes the orders of magnitude easier to feel.

OperationTimeWhere measuredIf 1 ns were 1 s
one CPU cycle (dependent add)0.31 nsthis chapter0.3 s
load that hits the L1 cache0.9 ns (3 cycles)this chapter, pointer chase over 16 KiB; the ISA overview's alignment test measured 1.19 ns1 s
function call and return0.9 nstraps chapter1 s
branch misprediction15–20 cycles, about 5 nsestimated in the branch prediction chapter5 s
random load within 8 MiB (L2 cache)13 nsthis chapter13 s
clock_gettime through the vDSO17 nssystem calls chapter17 s
system call (getppid)92 ns (macOS), 150 ns (Linux VM)system calls, traps1.5–2.5 min
random load within 1 GiB (main memory, plus TLB misses)125–140 nsthis chapterabout 2 min
two context switches through a pipe7–36 µsprocesses chapter2–10 hours
start a program and wait for it0.22 ms (Linux VM) to 2 ms (macOS)processes chapter2.5–23 days
TCP connection to example.com (one network round trip)18–22 msthis chapter, with curlabout 8 months

The memory numbers come from a pointer chase: an array filled with a random cycle of pointers, followed for 20 million steps, so each load depends on the previous one and the hardware can't predict or overlap them. The array size decides which level answers: 16 KiB fits in L1, 8 MiB in the L2, 1 GiB only in main memory. Each run was repeated, and varied by a few percent. The 1 GiB figure includes the cost of TLB misses, since a random access in 1 GiB also misses the address-translation caches; the caches chapter gives typical figures for other machines, including SSDs (tens of µs) and hard disks (5–10 ms).

The pattern matters more than any single number: each step down the memory hierarchy, or across a boundary like the kernel or the network, costs one to three orders of magnitude. Performance work is mostly about staying at the top of this table.

Takeaways

  • SI prefixes are powers of 1,000, from quecto (10⁻³⁰) to quetta (10³⁰); ronna, quetta, ronto and quecto date from 2022.
  • IEC binary prefixes are powers of 1,024: KiB, MiB, GiB, TiB. The gap reaches 10 % at tera.
  • Memory is sized in binary units, disks and networks in decimal ones: a 1 TB disk is 931.3 GiB, which Windows shows as "931 GB".
  • b is a bit, B a byte: 1 Gb/s is 125 MB/s before overhead.
  • Period = 1 / frequency: 1 GHz ↔ 1 ns. The M2's performance cores ran at about 3.3 GHz, 0.31 ns per cycle.
  • Measured on the M2: L1 hit 0.9 ns, main memory about 130 ns, system call about 100–150 ns, context switches in µs, starting a program in ms, a network round trip about 20 ms.

Foundations

  1. F.1Levels of abstraction and a short history of computers
  2. F.2Binary and hexadecimal
  3. F.3Two’s complement and signed numbers
  4. F.4Floating point (IEEE 754)
  5. F.5Characters, ASCII and Unicode
  6. F.6Endianness
  7. F.7Parity, Hamming codes and error correction
  8. F.8Units: kilo, kibi and friends