Chapter 1
Processes, Threads & Parallelism
Most user-space execution on Linux runs in processes, each containing one or more threads. How those execution contexts are created, scheduled, isolated, and coordinated shapes both performance and failure behavior, from a single service to a fleet of batch jobs.
This chapter covers the fundamentals of processes and threads, per-thread state, the primitives that coordinate shared state, the hardware locality costs of sharing it (false sharing and NUMA), signals, patterns for running jobs in parallel, resource control with cgroups, and techniques for moving data between processes without wasting cycles.
Performance work on modern hardware is mostly about locality: keeping data close to the cores that use it and avoiding invisible contention. The costs hide in cache lines, memory nodes, and coherence traffic rather than in the code you can read—false sharing, where different processors concurrently access independent variables in the same cache line and at least one access is a write, and NUMA, where memory is closer to some cores than others.
# Chapter Sections
Process and thread creation (fork, exec, clone), scheduling, and the trade-offs between processes and threads.
Thread Local StoragePer-thread global state without synchronization. Covers ELF TLS models, linkage impact on performance, static TLS exhaustion, glibc vs musl differences, __tls_get_addr internals, and Rust specifics.
Synchronization primitivesCoordinating shared state between threads: mutexes and futexes, atomics and memory ordering, and the failure modes—contention, priority inversion, and deadlock.
False sharingHow concurrent accesses by different processors to unrelated variables in the same cache line, with at least one write, can severely degrade parallel performance—and how to detect and mitigate the problem.
NUMANUMA architecture, memory locality, and tools for observing and controlling NUMA placement.
SignalsSignal delivery and handling, signal safety, and common pitfalls in multithreaded programs.
Running jobs in parallelPatterns and tools for running jobs in parallel, from xargs and GNU parallel to job schedulers.
cgroupscgroups for resource control: CPU, memory, and IO limits, and how containers build on them.
Efficient data copiesZero-copy techniques, sendfile, splice, and shared memory.