A ground-up tour of what is inside the machine that runs your scripts.
To fully understand Rust, you need an idea of how a computer actually works.
What we’ll cover:
The big picture: CPU, RAM, registers, cache, storage
The memory hierarchy and the memory wall
Cache lines and why sequential access wins
How a program lays out memory: code, static data, heap, stack
Stack frames and function calls
Boxed vs unboxed values
The OS, syscalls, and the kernel/user-space split
What happens when you run a program, end to end
Why this matters for bioinformatics performance
The big picture — a computer is gears that move bits
One chip does the work; everything else feeds it or stores its results.
Figure 1
The same machine in the wild
The three things you need to recognise: CPU, RAM, storage. Photo: Darkone, Wikimedia Commons, CC BY-SA 2.5.
Registers — the CPU’s hands
Registers are the tiny storage slots inside the CPU. The CPU can only do arithmetic on values that are sitting in registers — everything else has to be loaded in first.
About 16 general-purpose slots, 64 bits each — hold whatever the program is currently working with
A handful of special-purpose slots — one points at the next instruction, one points at the top of the stack
A separate set of wider slots for floating-point and vector maths
The von Neumann architecture (the standard design where code and data share the same memory, fetched into the CPU over a bus): the CPU has a small set of registers that exchange data with main memory over a bus.
RAM — where the program lives while it runs
RAM holds the running program and its working data.
Gigabytes — laptop: 16–64 GB; server: up to 1 TB
Volatile — contents vanish on power-off (save to disk)
Much faster than disk, much slower than the CPU
Working sizes in bioinformatics: human reference + BWA index ~8 GB; single-cell expression matrix 30+ GB; pangenome graph index 100+ GB.
The memory hierarchy — fast & small, or big & slow
You cannot have memory that is both huge and fast. Real machines stack several layers, fastest-and-smallest at the top.
Figure 2
The memory wall — CPUs got fast, RAM didn’t
CPU clock speeds rose roughly a thousand-fold from 1980 to 2005. RAM latency improved by less than a factor of ten in the same period. So the gap between CPU and RAM has grown to hundreds of cycles.
Figure 3: CPUs got ~1000x faster; RAM did not.
Cache — bridging the gap
A cache is a small block of fast memory inside the CPU that automatically holds copies of recently-used (and likely-soon-to-be-used) bytes from RAM. You never ask for it explicitly; the hardware just does it.
L1 cache — ~32 KB per core, ~1 ns access
L2 cache — ~256 KB to 1 MB per core, ~3 ns
L3 cache — ~8 to 64 MB shared across cores, ~10 ns
All three together are still thousands of times smaller than RAM
The CPU — arithmetic + decisions
The central processing unit is the one component that actually runs code. Everything else just feeds it or stores its results.
From registers to RAM in nanoseconds — what the CPU actually waits on. Each arrow is a cache miss — the requested byte wasn’t in the faster level above, so the CPU has to fetch from the next level down.
A CPU die — registers, ALU, L1/L2/L3 all live on the same silicon chip.
A RAM module — separate chip board sitting in a DIMM slot.
A cache line — 64 bytes at a time
When the CPU misses cache and fetches from RAM, it does not fetch one byte — it fetches a whole 64-byte block called a cache line.
Step 1: CPU asks for byte at offset 5.
A cache line — what step 2 looks like
Step 2: the whole 64-byte line is fetched into the cache (one slow RAM trip).
Cache lines — and why sequential access wins
Step 3: nearby byte reads are cache hits, fast and free.
Sequential reads inside a line are essentially free.
Storage — SSD vs HDD vs RAM
Medium
Latency
Bandwidth
Persistent?
Capacity (laptop, 2026)
RAM (DDR4/5)
~100 ns
~30 GB/s
no
16–64 GB
NVMe SSD
~100 µs
~3–7 GB/s
yes
0.5–4 TB
SATA SSD
~200 µs
~0.5 GB/s
yes
up to 8 TB
HDD (spinning)
~10 ms
~0.15 GB/s
yes
up to 20 TB
Most real datasets overflow RAM; streaming is the rule.
DDR3 RAM stick.
NVMe SSD (M.2 form factor).
Hard disk drive with platter visible.
Photos (left to right): Alan Lorenzo, DDR3 RAM, CC BY-SA 3.0; Wikimedia user -stk, Toshiba M.2 SSD, CC BY-SA 4.0; Evan-Amos (Vanamo Media), laptop HDD exposed, CC BY-SA 3.0.
Inside the running program
A running program in memory
The OS sets up the same shape for every process: code at the bottom, heap (grows up), stack (grows down), with a big empty gap in between.
Figure 4: Every process gets the same private memory shape.
Stack — fast, structured, automatic
The stack is a fast, last-in-first-out region used for function calls. Each call pushes a fresh stack frame (its arguments and local variables) on top; returning pops it.
def gc_count(seq):returnsum(1for b in seq if b in"GC")def main(): seq ="ACGTACGT" n = gc_count(seq) # push gc_count frameprint(n) # gc_count returned, popmain()
Stack frames — push on call, pop on return
Step 1: main() running — one frame on the stack.
Stack frames — push on call, pop on return (step 2)
Step 2: main() calls gc_count(seq) — a new frame pushed on top.
Step 3: gc_count() returns — its frame is popped; main continues.
Heap — flexible, slower, you manage the lifetime
A large region for data whose size or lifetime isn’t known at compile time.
Ask the allocator for n bytes, get a pointer back
Slower than stack pushes, but flexible — growing vectors, unknown-length strings, graphs
Someone must decide when to free it: you (C), a garbage collector (Python), or the compiler (Rust)
Tidy stack frames on the left; the heap on the right holds allocations of any size, with pointers from stack-frame variables reaching into them.
Boxed vs unboxed — what the value actually costs
In C or Rust, 42 lives directly in its 4-byte slot. In Python, the variable is a pointer; the value is wrapped in a heap object with a type tag and a refcount.
Same 42, very different memory.
A million-int list: ~60 MB in Python vs ~4 MB in C/Rust
The operating system — referee and gatekeeper
Your program is not alone on the machine. The OS decides which process gets the CPU when, hands out memory, and is the only thing allowed to touch hardware directly.
Kernel — the privileged core that runs the scheduler, file system, network stack
User space — where ordinary programs run, with no direct hardware access
Syscall — the only legal way for your program to ask the kernel to do something
Figure 5: Only the kernel touches hardware; user code goes through syscalls.
OS vs software — syscalls are the doorway
When your Python code does f = open("data.fa"), the runtime issues an open syscall — a controlled jump into the kernel, which checks permissions, locates the file, and returns a file descriptor.
Putting it together — what happens when you run a program
You type ./my_tool data.fa in a shell
The shell asks the kernel to create a new process (fork + exec)
The kernel loads your binary from disk into a fresh chunk of RAM
It sets up the program’s memory layout: code, static data, an empty heap, an empty stack
It places one register (rip) at the start of main and schedules the CPU to run you
Your code runs, calling functions (stack), allocating data (heap), making syscalls (kernel)
main returns; the kernel reclaims your memory and tells the shell you’re done
Why this matters for bioinformatics
Research (BWA, minimap2): big indexes, tight loops
Clinical (DeepVariant, GATK): hours not days per patient
Public health (Nextstrain): thousands of samples per week
Why latency matters — clinical turnaround
Same machine speed, very different acceptable wait times depending on the question:
Scenario
Acceptable turnaround
ER: suspected sepsis — which antibiotic?
< 1 hour
ICU: drug-resistance variant calling
hours
Rare-disease workup: full WGS analysis
days
Cancer panel: tumour mutation report
days to a week
Public-health outbreak: SARS-CoV-2 surveillance
days
Cohort study / GWAS: hundreds of genomes
weeks-months
Research method development
months
The bottom rows are tolerant of slow code. The top rows are NOT — every second your pipeline takes is a second the clinical decision is waiting on you. Rust’s “compile-time-free of a class of bugs, runtime-fast” combination is most valuable up there.