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:
| Prefix | Symbol | Factor | Prefix | Symbol | Factor | |
|---|---|---|---|---|---|---|
| kilo | k | 10³ | milli | m | 10⁻³ | |
| mega | M | 10⁶ | micro | µ | 10⁻⁶ | |
| giga | G | 10⁹ | nano | n | 10⁻⁹ | |
| tera | T | 10¹² | pico | p | 10⁻¹² | |
| peta | P | 10¹⁵ | femto | f | 10⁻¹⁵ | |
| exa | E | 10¹⁸ | atto | a | 10⁻¹⁸ | |
| zetta | Z | 10²¹ | zepto | z | 10⁻²¹ | |
| yotta | Y | 10²⁴ | yocto | y | 10⁻²⁴ | |
| ronna | R | 10²⁷ | ronto | r | 10⁻²⁷ | |
| quetta | Q | 10³⁰ | quecto | q | 10⁻³⁰ |
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) | Value | Binary (IEC) | Value | Difference |
|---|---|---|---|---|
| kilobyte, kB | 10³ | kibibyte, KiB | 2¹⁰ = 1,024 | 2.4 % |
| megabyte, MB | 10⁶ | mebibyte, MiB | 2²⁰ = 1,048,576 | 4.9 % |
| gigabyte, GB | 10⁹ | gibibyte, GiB | 2³⁰ = 1,073,741,824 | 7.4 % |
| terabyte, TB | 10¹² | tebibyte, TiB | 2⁴⁰ = 1,099,511,627,776 | 10.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.memsizereports 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 disk0reports "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:
| Unit | Seconds | What happens in about that time |
|---|---|---|
| picosecond, ps | 10⁻¹² | a logic gate switches |
| nanosecond, ns | 10⁻⁹ | a few clock cycles; an L1 cache hit |
| microsecond, µs | 10⁻⁶ | a context switch; an SSD read (tens of µs) |
| millisecond, ms | 10⁻³ | 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.
| Operation | Time | Where measured | If 1 ns were 1 s |
|---|---|---|---|
one CPU cycle (dependent add) | 0.31 ns | this chapter | 0.3 s |
| load that hits the L1 cache | 0.9 ns (3 cycles) | this chapter, pointer chase over 16 KiB; the ISA overview's alignment test measured 1.19 ns | 1 s |
| function call and return | 0.9 ns | traps chapter | 1 s |
| branch misprediction | 15–20 cycles, about 5 ns | estimated in the branch prediction chapter | 5 s |
| random load within 8 MiB (L2 cache) | 13 ns | this chapter | 13 s |
clock_gettime through the vDSO | 17 ns | system calls chapter | 17 s |
system call (getppid) | 92 ns (macOS), 150 ns (Linux VM) | system calls, traps | 1.5–2.5 min |
| random load within 1 GiB (main memory, plus TLB misses) | 125–140 ns | this chapter | about 2 min |
| two context switches through a pipe | 7–36 µs | processes chapter | 2–10 hours |
| start a program and wait for it | 0.22 ms (Linux VM) to 2 ms (macOS) | processes chapter | 2.5–23 days |
| TCP connection to example.com (one network round trip) | 18–22 ms | this chapter, with curl | about 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.