This chapter connects the choice of an algorithm §14.1 or data structure to the operations it must support and to the cost of each operation, and states the assumptions under which those costs hold. It begins with asymptotic complexity §14.2, the growth of cost with the size of the input, in the worst case, in the average case and in the amortized sense, which averages over a sequence of operations. It then describes the common structures: arrays §14.5 and linked lists §14.6; hash tables §14.7, their load factors §14.9 and their collisions, which differ from the collisions that matter in cryptography; balanced search trees §14.10, interval structures and half-open intervals §14.12; sets and multisets §14.13; queues, ring buffers §14.15 and priority queues §14.16; and graphs, with reachability §3.21 search and the topological ordering §14.19 of directed acyclic graphs §14.17. Memoization §14.20, caching and cache invalidation §14.21, callbacks §14.22 and event loops §14.23 complete the first part.
The second half is about observing a running program. Runtime instrumentation §14.24 adds code or hardware events that record what a program does, either statically, when the program is built, or dynamically, while it runs, through probes and hooks, function wrappers §14.27, trampolines §14.28, breakpoints §14.29 and watchpoints. The chapter compares tracing every event with sampling some of them and explains sampling bias §14.31, lost trace records §14.32, patching a running program at a quiescent point §14.34, and how to know which code the instrumentation covers. The final entries are about performance: benchmark harnesses, whether computation or communication is the bottleneck, queueing delay §14.38 and Little’s law §14.39, and deamortization §14.40, which spreads the migration of a table to a larger array over many operations so that no single operation is slow while every lookup still finds the right entry.