CComputer Science, Built

Act XI · The Research Frontier

Part 61 of 61

Doing Research

Researchstarts at this level52 min of film13 chaptersprerequisites: Part 2, Part 7, Part 54, Part 60

Where do the results this series quoted come from, and how would you make one without fooling yourself?

One C program, compiled once, is timed while an unused environment variable grows from nothing to 4 KiB, and its median time moves by up to 7%. Mytkowicz, Diwan, Hauswirth and Sweeney showed in 2009 that such changes move where the stack begins and can decide which compiler setting looks faster. The part rebuilds their experiment and turns on its own result: 4,000 noise-only experiments typically spread 10%, and 89% of them exceed the 6.7% observed, because Linux already starts the stack at a random address on every run. So the medians moved, and nothing shows that the environment moved them. From there the part is method: thirty runs of the Job with a bootstrap interval, why speedups are averaged geometrically, how benchmarks become targets and analyses fork, and what a computer search proves (Goldbach to 2,000,000, Euler's conjecture refuted by one line of integers, Polya's by a failure at 906,150,257). It practises reading in three passes, reviewing an invented paper, choosing a problem with Hamming and Polya, and writing an argument whose figures carry the claim. It ends on the eleven open problems the series met, drawn as a sky over the tower, on seven bridges to AI, Built and Analysis, Built, and on the ledger's 22 rows, from 281 seconds to 31.5 milliseconds.

What you need. Means, medians and the idea of a confidence interval; the rest is the series itself.

Mathematics, ideas and history
measurement bias, rigorous performance evaluation, reproducibility, reading and reviewing, Hamming's advice, the open-problems map
What we build or compute
measurement bias reproduced on this machine; the map of open problems

What you will be able to do

Degree

  • Explain why one timing of a program is not a result, and report repeated runs with a median and an interval.
  • Read a paper in three passes and say what its claim, its evidence and its baseline are.

Graduate

  • Compute a percentile bootstrap interval for a mean time, and predict how its width changes with four times the runs.
  • Show that the geometric mean of speedup ratios does not depend on the reference machine, while the arithmetic mean can favour either side.
  • Compute the chance that at least one of twenty null comparisons passes a 5% test.

Research

  • Design a noise-only control for a measured effect, and state what a spread inside the noise does and does not show.
  • Say what a finite computer search proves about a conjecture and what it cannot, with Goldbach, Euler's sum of powers and Polya as the cases.
  • Choose an open problem from the map, state its record, and name a special case small enough to attack.

Industry

  • Run a performance comparison with interleaved runs, randomized setup and a stated number of runs, and report the totals for a fixed workload.
  • Review a systems paper: summary, strengths, weaknesses, questions, and what is not said about runs, baselines and limitations.

Contents

Each chapter has a home level. Choose a track to see what to read and watch: Degree 22 min · Graduate 36 min · Research 52 min · Industry 36 min.

  1. 0Where results come fromDegree1 min
  2. 1What research isDegree4 min
  3. 2Measurement biasIndustry5 min
  4. 3Measuring rigorouslyDegree5 min
  5. 4Benchmarks and reproducibilityIndustry4 min
  6. 5Proof as researchResearch5 min
  7. 6Reading and reviewingDegree4 min
  8. 7Finding problemsResearch4 min
  9. 8WritingIndustry5 min
  10. 9The open-problems mapResearch2 min
  11. 10Where the series meetResearch4 min
  12. 11The pebble, the last timeDegree5 min
  13. The series map, and the final reading listAll tracks2 min

Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · 中文 · Build the film.

Lecture

The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film. A dashed box stands for a number the film computes when it is rendered (hover over it to see what is computed); the README's figures for each chapter, where it lists them, follow the chapter's text.

Where results come fromDegree1 min

Here is one C program, compiled once, timed on this machine. The only thing we change between runs is the size of an environment variable the program never reads, from nothing to four kilobytes. The median time moves by up to 7 percent. In 2009 Todd Mytkowicz and colleagues showed that such changes shift where the stack begins, and with it the alignment of hot data, and that this alone could decide which of two compiler settings looked faster. But is our spread that effect, or only noise? This machine randomizes where the stack begins on every run, which smears the effect out, and chapter two will show that noise alone could explain what we see. Telling the two apart, and not fooling yourself, is what this part is about.

This series has quoted perhaps a thousand results. Where do they come from? Every one began as a question sharp enough that an answer could be wrong. Then a method: a proof, a measurement, or something built. Then evidence good enough to convince a sceptic who wants you to be wrong. And a paper, written so that others can check it. This last part is about doing that yourself.

1What research isDegree4 min

Research begins with a question, but not just any question. Does the environment affect speed? As asked, no experiment could ever say no. Sharpen it: which variable, which program, which machine, and compared with what. Now the answer could come out either way, and that is what makes it worth asking. A sharp question becomes a hypothesis; the hypothesis makes a prediction; and a test checks the prediction. If the test could have refuted it and did not, the hypothesis survives, for now. If it is refuted, you have learned something, and you come back with a better one. In 1934 the philosopher Karl Popper made this the mark of a scientific claim: that some observation could prove it wrong. A question whose answer you already know is not research, and neither is a claim that no result could ever contradict.

Computer science answers questions with three kinds of evidence. The first is proof: a chain of steps from accepted axioms, like Turing's proof in 1936 that no program decides halting, from Part 25. A reader checks every step, or, since Part 54, a proof assistant does. The second is experiment: a controlled comparison, repeated, like the measurement-bias study at the heart of this part. It is checked when someone else runs it again and gets the same answer. The third is construction: build the thing and show that it works, like Dennis Ritchie and Ken Thompson's 1974 paper on Unix, the system behind Part 31. It is checked when others use it and it holds up. Most papers mix the three: a system built, measured, and a theorem about why it works. What a paper claims decides which evidence it owes.

Results travel as papers, and papers have a shape. A title and authors; an abstract; an introduction; background; the idea or design; the evaluation, or the proofs; related work; a conclusion; and references. The order varies by field, but the parts recur. The abstract tells the whole story in about four sentences: the context, the problem, what we did, and what we found. Each remaining part answers one of the three questions every reader, and every reviewer, asks. Does it matter? That is the introduction's job: the problem, why it matters, and a list of contributions. Is it right? That is the evaluation or the proofs, with their limits stated. Is it new? That is related work: what was already known, and exactly what this paper adds. Chapter six reads papers with these questions in mind.

Here is this part's own experiment, written as a paper would be. The question: does an unused environment variable, or the order of linking, change the time of one C program on this machine? The method: thirty-three sizes, five runs each, interleaved; three link orders, fifteen runs each; medians compared with the run-to-run noise. The evidence: the medians spread by about seven percent across sizes and under one percent across link orders, both within the noise. Threats to validity, the section honest papers never skip: a shared machine, one program, one compiler, and address randomization switched on. The conclusion: no effect shown here, which is not the same as no effect. The next chapter takes that experiment apart.

2Measurement biasIndustry5 min

Why would a variable nobody reads matter? When Linux starts a program, it copies the environment strings and the arguments to the very top of the new stack, then the pointers to them, and only below those do the program's own frames begin. So every byte added to the environment pushes every frame down. Write the address of a hot local variable as the top, minus the environment, minus everything else. The calling convention keeps the stack aligned to sixteen bytes, so the address moves in sixteen-byte steps. Within a sixty-four-byte cache line, from Part 9, it can sit in four places, and within a four-kilobyte page in two hundred and fifty-six. An object split across two lines costs two accesses, and a load whose address matches an earlier store's in its low twelve bits can be held up by the processor, which compares only those bits at first. Which case you get depends on the environment.

Here is the first experiment from the hook again, with more of what we measured. For each of thirty-three environment sizes, from nothing to four kilobytes in steps of one hundred and twenty-eight bytes, we ran the program five times, interleaved, so that slow changes in the machine fall on every setting alike. The yellow dots are the medians; they spread by about seven percent. The blue dots are the fastest of each five; they spread by about five. Now, at the right, fifteen more runs of one unchanged setting, the empty environment, taken just after. They range over twenty-two percent, three times the whole spread of the medians. Before we blame the stack for anything, we have to know how much the machine moves on its own.

The second experiment changes nothing in the source, only the order in which the linker is handed the three object files. The linker lays the code out in that order, so every function lands at a new address. That changes how the hot loop lines up with the blocks in which the processor fetches instructions, and which branch-predictor entries its branches share. Here are fifteen runs of each order, with the environment empty. The medians differ by under one percent, far inside the scatter of the runs. On this machine, for this small loop, link order shows no effect we can detect. That is not the same as no effect: an effect smaller than the noise would look exactly like this.

This is what Todd Mytkowicz, Amer Diwan, Matthias Hauswirth and Peter Sweeney reported at ASPLOS in 2009, under the title Producing Wrong Data Without Doing Anything Obviously Wrong. They found measurement bias on every processor and both compilers they tried, and in most of the SPEC CPU2006 C programs. Changing the environment size or the link order could change whether the compiler's O3 setting looked faster than O2. Of more than a hundred recent papers they surveyed, none had adequately accounted for it. They proposed two remedies. Setup randomization: measure under many randomly chosen setups, and report the distribution, not one lucky point. And causal analysis: when you believe an effect has a cause, change that cause alone, and check that the effect follows. In 2013 Charlie Curtsinger and Emery Berger built Stabilizer, which keeps re-randomizing the layout while the program runs.

So what does our measurement show? Suppose nothing but noise were acting. Draw thirty-three medians of five from the forty-five runs with an empty environment, measure their spread, and repeat that four thousand times. Noise alone typically gives about ten percent. Our seven percent sits well inside it. We have shown that the medians moved by seven percent while an unused variable grew, and by under one percent across link orders. We have not shown that the environment caused it. And there is a reason it may not have: on this machine, with address randomization on, Linux starts the stack at a different place on every run, in sixteen-byte steps. We checked: a tiny C program printed twenty different addresses in twenty runs. That is a setup randomization done for us, and it smears the alignment effect into every setting's noise. To find a cause, you would switch it off and intervene.

3Measuring rigorouslyDegree5 min

We ran the Job in plain Python times on the same text, about million characters. Each dot is one run. Nothing changed between them, and still they spread out. Report the best run and you claim ; report the worst and you claim , percent slower; the mean is . In 2007 Andy Georges, Dries Buytaert and Lieven Eeckhout surveyed how Java performance papers reported their timings, and found many gave a single number, the best of several runs or a mean, with no measure of how uncertain it was. They showed that such methods can mislead, even about which of two systems is faster, and argued for repeated runs and confidence intervals instead.

Georges and his colleagues also separated two questions. A runtime with a just-in-time compiler, like Part 15's, starts slowly, interpreting, and speeds up as it compiles the hot code. Start-up performance is the time of the first iterations: to measure it, start the runtime many times and time the first iteration of each. Steady-state performance is the time after warm-up: within each run, iterate until the timings settle, average those, and still repeat across several fresh runs, because each run can compile the code a little differently. Our Job, in order. The Python we use has no just-in-time compiler, and the times show no trend: the slowest is run number eighteen. Warm-up is not the story here; the machine's own noise is.

How sure is a mean? The textbook formula assumes the times follow a bell curve. The bootstrap, Bradley Efron's idea from 1979, assumes much less. Start with our runs and their mean. Now treat the sample as if it were the whole world: draw runs from it at random, with replacement, so that some appear twice and some not at all, and take the mean of that resample. Do it again, and again; each resample gives a slightly different mean. After thousands of resamples the means form a distribution, and its middle ninety-five percent is a ninety-five percent confidence interval: here from to . The same recipe works for a median, or for the ratio of two programs' times, where no textbook formula is at hand.

How many runs are enough? Here is the bootstrap interval after three, five, ten, twenty and thirty of our runs. It narrows: sixty-two milliseconds wide after three runs, twenty after thirty. Why that rate? Independent runs have variances that add, so the variance of a mean of n runs is the variance of one run divided by n. Take the square root: the spread of the mean falls as one over the square root of n. The interval is about four of those wide, so to halve it you need four times the runs. The dashed lines are that prediction, and our intervals follow it. Notice, too, that the centre drifts. The formula assumes the machine does not change while you measure; a shared machine does, which is why we interleave settings, and why an interval is only as honest as that assumption.

Last, how to average speedups. Two programs on two benchmarks: A takes one second on the first and four on the second; B takes two on each. Divide B's times by A's and average: one and a quarter, so B is a quarter slower. Divide A's by B's instead and average: also one and a quarter, so A is a quarter slower. Both cannot be true. The geometric mean is the n-th root of the product of the ratios. Flip every ratio and it flips exactly, so it gives the same verdict whichever way round you divide, and whichever machine you normalize to. In logarithms it is an ordinary mean, where twice as fast and twice as slow cancel. Here it says one: a tie. Philip Fleming and John Wallace made this argument in 1986. But see what it does not say: run both benchmarks once each, and B finishes in four seconds, A in five. For a fixed workload, total time is the honest summary.

4Benchmarks and reproducibilityIndustry4 min

A benchmark is a promise: a program whose speed stands for the speed of the programs you care about. Reinhold Weicker's Dhrystone, from 1984, was small and synthetic. It fitted in a cache, and much of its time went into a few string operations that compilers and libraries could tune for it. The SPEC consortium, founded in 1988 by computer makers, chose real programs instead, and replaces its suite every few years. Yet its first suite included matrix300, a matrix multiplication. As Hennessy and Patterson recount, compilers learned to transform it so thoroughly that it measured that one trick, and it was dropped from the next suite. Later, libquantum, in the 2006 suite, became notorious for compiler speedups far beyond what other programs saw; it is not in the 2017 suite. Each time, a score rose while the programs people ran did not.

Economists have a name for this. In 1975 Charles Goodhart observed that a statistical regularity tends to collapse once it is used as a lever of control; the anthropologist Marilyn Strathern later put it as: when a measure becomes a target, it ceases to be a good measure. A benchmark begins as a measure of what we want: fast real programs. Make the score a target, and effort flows into whatever raises it, including tuning for the benchmark itself. The score keeps rising, and the real programs stop following it. Sometimes it is deliberate. In 2013 several phones were found raising their clock speeds when they recognized a benchmark app, and in 2015 Volkswagen's diesel cars were found detecting the emissions test, and running cleaner only then.

The same pressure acts on researchers. Between the runs and the claim lie many reasonable choices: the mean, the median or the fastest run; whether to trim outliers; which benchmarks to show. In 2011 Joseph Simmons, Leif Nelson and Uri Simonsohn showed, for psychology, that freely combining such choices can make almost anything look significant; Andrew Gelman and Eric Loken called it the garden of forking paths. An honest test at the five percent level raises a false alarm one time in twenty, and stays quiet nineteen times in twenty. Over k independent tries, the chance that all stay quiet is that, to the power k, so the chance of at least one is one minus it, and with twenty tries about sixty-four percent. In systems research, pick our fastest environment size against our slowest, and you have a seven percent speedup from a variable the program never reads. The remedies: decide the analysis before you see the results, report every benchmark and every run, and randomize the setup.

The last defence is to let others check. The ACM distinguishes three levels. A result is repeatable when the same team gets it again with the same setup; reproducible when another team gets it using the authors' artifacts; and replicable when another team gets it with a setup of its own. In 2016 Christian Collberg and Todd Proebsting reported trying to obtain and build the code behind hundreds of systems papers; for many, they could not. Since 2011, many conferences have run artifact evaluation: a committee runs the authors' code and data, and papers earn badges for artifacts that are available, that work, and whose results were reproduced. This series keeps the same rule. Every measured number on screen is computed by code in the repository, cached, and recomputed by one command, so that anyone can check it.

5Proof as researchResearch5 min

A conjecture is a statement someone believes and nobody has proved. In letters in 1742, Christian Goldbach and Leonhard Euler arrived at this one: every even number above two is a sum of two primes. Then comes evidence: by 2014 it had been checked for every even number up to four times ten to the eighteenth, and it is still a conjecture. It can leave that state in only two ways. A counterexample refutes it, as a computer search refuted a conjecture of Euler's in 1966. Or a proof makes it a theorem, as for the four colours in 1976, in Part 18. And then the proof itself is checked: in 2005, by a proof assistant.

What does a search prove? Here is our Goldbach check, simplified: sieve the primes, then for each prime in turn strike out the even numbers it completes. At the end, nothing is left. That run proves a theorem: every even number from four to two million is a sum of two primes. Finitely many cases, every one checked. Change one symbol, to any size at all, and it is Goldbach's conjecture, which no search can reach. What the search gives is a feel for the margin. The hardest case below two million, , needs only , the th prime; a counterexample would need every prime below half of n to fail.

Our Collatz check is cleverer than it looks. Halve an even number, treble an odd one and add one. From seven the path climbs to fifty-two, then falls to five. There the program stops, because every start below seven already reaches one. That is strong induction, from Part 2: assume the claim for every smaller start; show that the path from n drops below n; then it holds for n. The computer proves that step for each n below one million, so every start below one million reaches one. Proving the step for every n is the whole Collatz problem.

Search shines when a conjecture is false. In 1769 Euler conjectured that it takes at least k k-th powers to add up to a k-th power: three cubes, four fourth powers, five fifth powers. So four fifth powers should never sum to a fifth power. In 1966 Leon Lander and Thomas Parkin searched by computer and found four that do. Check it: twenty-seven, eighty-four, one hundred and ten and one hundred and thirty-three, each to the fifth. The sum is exactly one hundred and forty-four to the fifth. Their note is a few lines long; it needed nothing else. Fourth powers fell in 1988: Noam Elkies found a counterexample, and Roger Frye's search found the smallest.

Sometimes the small cases lie. Give every number a sign: minus one if it has an odd number of prime factors, counted with repeats, plus one if even. Twelve is two times two times three: minus one. Primes get minus one; four, two times two, gets plus one. Keep a running total. It touches zero at two, four, six, ten and sixteen, and never rises above. George Pólya conjectured that it never does. In 1958 Brian Haselgrove proved it false without finding where, and in 1980 Minoru Tanaka found the first failure, near nine hundred and six million. A search to two million would have confirmed the conjecture more than four hundred times over.

Each way of checking a proof asks you to trust something different. Part 2 proved that among six people, three are friends or three are strangers, in two lines, by pigeonholes. You trust the argument and its readers. Part 2 also checked all thirty-two thousand seven hundred and sixty-eight colourings by brute force. The four colour theorem, Thomas Hales's 1998 proof of Kepler's conjecture, and Part 26's two-hundred-terabyte proof work this way: you trust a program, its compiler and the machine. A proof assistant checks every inference, and you trust only its kernel, sixty-nine lines in Part 54. Four colours were checked this way in 2005, and Kepler by Hales's Flyspeck project in 2014. A theorem is only as sure as the least reliable thing you trust.

6Reading and reviewingDegree4 min

In 2007 Srinivasan Keshav published a short note called How to Read a Paper. Its advice is to read in three passes. The first takes five to ten minutes: the title, the abstract and the introduction; the section headings, but not what is under them; the conclusion; and a glance at the references. That is enough to decide whether to go on. The second pass takes up to an hour. Read everything except the proofs and the fine details, and read the figures with care: are the axes labelled, are there error bars, does each figure show what the text claims? Mark the references you have not read. The third pass is for a paper you must understand completely, or review. Keshav's instruction is to re-create the work: make the same assumptions as the authors, rebuild it, and compare. For a beginner, that can take many hours.

The first pass ends with five questions, which Keshav calls the five Cs. Here is an abstract to try them on. It is invented, for illustration. Category: what kind of paper is this? A systems paper: a new design, measured. Context: which other papers and which theory does it build on? Hash tables, from Part 17, and a related-work section we have not yet read. Correctness: do the assumptions appear to be valid? From an abstract, you cannot yet tell. Contributions: what does it add? One design and one speedup. Clarity: is it well written? Short, but vague in places. After five minutes you know whether to read on, and what to read for.

In the second pass, look for what is not said. Read the claim again, phrase by phrase, and ask what you would need in order to believe it. On thirty novels: which texts? Thirty novels are one sample of text, and chapter four showed how benchmarks fail. Two point one times faster: from how many runs, with what interval? Our own Job, run thirty times on the same text, spread by eleven percent. And if there were several inputs, how was the speedup averaged? Than the standard counter: which one, tuned by whom, on which machine? In chapter two, an unused environment variable moved our medians by six point seven percent. Little extra memory: how much is little? An adjective stands where a number belongs. And notice what is missing entirely: limitations, threats to validity, the code. When a paper names no weakness of its own, the reviewer has to find them.

The third pass is the hardest, and the one that teaches most. This part made one in chapter two, on the 2009 paper by Todd Mytkowicz, Amer Diwan, Matthias Hauswirth and Peter Sweeney: that link order and the size of the environment bias measurements. Rebuilding forces every unstated choice into the open. Which program? Which machine, and how busy? How many sizes, and how many runs? We had to answer each one ourselves, and we found an answer: thirty-three sizes, five runs each, a spread of six point seven percent, within the noise. And one question the reading alone would never have raised: does the stack start at the same address on every run? On this machine it does not. So the rebuild did not refute the paper. It found the paper's own remedy, setup randomization, already switched on.

7Finding problemsResearch4 min

In 1986 Richard Hamming, who spent three decades at Bell Labs, gave a talk called You and Your Research. Its best-known story is about lunch. Hamming sat with the chemists and asked what the important problems of their field were. A week later he asked which important problems they were working on. And later still: if what you are doing is not important, why are you working on it? He was careful about what important means. Time travel, teleportation and antigravity would matter enormously, he said, but they are not important problems, because we have no attack. A problem is important when it would matter and you can see a way in. Great scientists, he observed, keep ten to twenty such problems in mind, and when a new idea bears on one, they drop other things and go after it.

George Pólya's How to Solve It, from 1945, is a short book about finding solutions. It has four phases: understand the problem, devise a plan, carry it out, and look back. For the plan, it offers questions. Do you know a related problem? A special case, or a more general one? Can you draw a figure, or work backwards? Pólya's own example: bring up exactly six quarts of water with a four-quart pail and a nine-quart pail. Start from the goal. Six in the big pail is nine less three. The small pail takes exactly three if it already holds one. And one is nine less four, less four again. Read the chain forwards: that is the solution. Part 2 searched every state of a jug puzzle; working backwards needs no search.

A limit study measures the headroom before you spend years chasing it. Part 7 asked how good branch prediction could be on the Job. Two-bit counters mispredict eight point eight branches in a hundred; our TAGE, at nine kilobytes, five point seven. With no storage limit at all, two point five. So storage alone can win about three more in a hundred, and the rest needs a different kind of predictor. Amdahl's law is a limit study in one line: make a fraction p of the work s times faster. Let s grow without bound, and the gain is capped at one over one minus p. The Job spent ninety-nine point seven percent of its instructions in one linear search, so removing it could give at most three hundred and fifty times. The ledger shows the headroom was real: fifty-eight seconds in Part 13, under a second with Part 17's hash table.

Working backwards scales up to research: start from the ideal, and ask what stands in the way. For a cache the ideal is known. In 1966 Laszlo Belady described it: evict the block that will be needed furthest in the future, and no policy misses less. What stands in the way is that the future is unknown. So the problem is to predict reuse from the past, and every policy, from least recently used onwards, can be measured by how close it comes. The Job too: the ideal is to touch each byte once, and Part 60 built that in hardware, about thirty-one milliseconds. Part 17's hash table spends about twenty-nine cycles on each byte, so the problem is less work per byte. The ideal says what success would be worth, the obstacle names the problem, and Hamming's test asks whether you have an attack.

8WritingIndustry5 min

Writing up research is making an argument, and in 1958 the philosopher Stephen Toulmin drew the shape of one. Take this part's own result from chapter two. The claim is what you want the reader to accept: an unused environment variable did not measurably change the program's speed. The data are the facts it rests on: the medians spread by six point seven percent across thirty-three sizes, five runs each. The warrant is why those data support the claim: noise alone, with no variable at all, gives spreads this large. The backing is why the warrant holds: four thousand simulated experiments. The qualifier says how far the claim reaches: on this machine, for this program. And the rebuttal says when it would fail: unless address randomization is hiding a real effect. Weak papers stop at the claim and the data.

A paper makes many claims, and each one needs its own evidence. Here is a test you can run on any draft, shown on chapter six's invented paper. First, list every claim the introduction makes, including the ones in passing. Then find, for each claim, the section, figure or theorem that supports it. Skim hashes each word once: that is the algorithm, in section three. Two point one times faster: figure four, if it has intervals and names its baseline. Little extra memory, and works for any language: nothing in the paper supports either. Each such claim must be cut, or the evidence added. A reviewer will run this test whether you do or not. A good introduction makes it easy, by saying where each contribution is shown.

A figure should carry the claim, and the same data can be made to carry opposite ones. These are chapter two's three link orders. On the left, only the medians, with the axis cut just below the smallest. The tallest bar stands seven point six times taller than the shortest, and the title announces that link order changes speed. On the right, the same experiment: every one of the forty-five runs, the medians marked, and an axis that shows the spread. The medians differ by under one percent; the runs within each order spread by eighteen to thirty-five percent. And its title states the claim the figure supports. Edward Tufte, in 1983, put the rule this way: the representation of numbers should be directly proportional to the quantities they represent. Show the spread, label the units, and let the reader check you.

This series holds itself to a rule: every number on screen is computed by our own code, or is published and named. Here is how a computed number travels. An instrument, a Python module with its own tests, does the work: here, the measurement-bias experiment. A compute script runs each item once and stores the result in a cache, as JSON, under the part's name. A scene loads it. A scene never computes the experiment and never types a number in. And the narration is formatted from the same value, so the sentence you hear cannot disagree with the measurement. Rerun the instrument on another machine, and every chart and every sentence that depends on it changes with it. You need not trust us; you can check.

Three kinds of number appear in this series, and each wears its label. Computed numbers come from our instruments, on this machine, and say so: the six point seven percent spread, the hardest Goldbach case below two million, the limit of three hundred and fifty. Published numbers are named, with their authors and year, in the narration: Goldbach checked to four times ten to the eighteenth, Pólya's conjecture failing near nine hundred and six million. Illustrative numbers are marked on screen: the invented paper's two point one, chapter three's one second and four. Readers trust a writer who shows them how to check. Hamming put it bluntly: doing the work is not enough; you must write clearly and give talks, so that people will read and listen. Justin Zobel's Writing for Computer Science is the handbook for the first.

9The open-problems mapResearch2 min

What is still unknown, and where would you start? Here is every open problem the series met, as a sky over the tower. Each star is a question nobody has answered, labelled with the parts where we met it and the year it was first asked. Some are decades old: P against NP since 1971, the exponent of matrix multiplication since Strassen's surprise in 1969, the gate counts of circuits since Shannon in 1949. Some have moved recently: the fifth Busy Beaver number was proved in 2024, and the record for matrix multiplication keeps creeping down. None of them is closed, and each is someone's life's work. The rest of this chapter asks how a person would start on one.

One honest way to start is with the small cases. In letters of 1742, Goldbach and Euler arrived at the conjecture that every even number above two is a sum of two primes. Our sieve checks every even number up to 2,000,000 in under a second, and finds that the hardest is 1,077,422, whose smallest prime partner is the largest. The Collatz problem, from 1937, says that halving even numbers and tripling-plus-one the odd ones always reaches one. Every start below a million does; the slowest takes 524 steps. Checking small cases never proves a theorem about all numbers, but it finds counterexamples, suggests patterns, and shows where a proof will have to work hardest.

How do you choose? Richard Hamming asked his colleagues what the important problems in their field were, and then why they were not working on them. Every problem marked with a star in this series has a smaller version that someone could finish. Many breakthroughs bring a new tool to an old problem: topology to agreement, spectra to flows, SAT to proofs. And a limit study, like Part 7's, tells you whether there is headroom worth having. So this last research problem is yours to define: pick one star from the series, find its smallest open special case, and settle it.

10Where the series meetResearch4 min

This series has two older siblings: AI, Built, thirty-one parts on how machines learn, and Analysis, Built, ten parts on the mathematics of limits, from the real numbers to the spectral theorem. They share more than a style. These are the thirty novels that AI, Built's first part chose, from Pride and Prejudice to Ulysses. AI, Built trains its models on them, and scores every model on a passage none of them was trained on. This series' Job counts their words: about twenty-five million bytes, about four point six million words, from Part 6's Pebble to Part 60's circuit. Analysis, Built reads no novels at all, but it proves the theorems that the other two keep leaning on.

Draw the three series as towers, one floor for each part: AI, Built on the left, this series in the middle, Analysis, Built on the right. The first bridge is the one every model crosses. Part 23 set gradient descent against Newton's method; AI, Built's Part 11 trains every network with descendants of that step: momentum, Adam, and learning-rate schedules. Part 57 asked when learning is possible at all, with PAC bounds and the VC dimension; AI, Built's Part 8 asks the same question of real models, with Rademacher complexity and double descent. Part 60 built a systolic array and put it on the roofline; AI, Built's Part 17 puts GPUs on the same roofline, and tiles matrix products to climb it. And Shannon's paper of 1948 sits under both. Part 28 proved his channel theorem with typical sets; AI, Built's first part met the same typical sets on the way to cross-entropy, the loss every language model is trained on.

On the other side stands analysis. The lowest bridge is the oldest. Turing's paper of 1936 was called On Computable Numbers: a real number is computable if a machine can write out its digits. Analysis, Built's first part builds the real numbers and proves, with Cantor's diagonal, that they are uncountable. Machines can be listed, so almost every real number is one that no machine can write. Part 19's fast Fourier transform, from Cooley and Tukey in 1965, computes the Fourier transform of Analysis, Built's Part 9, taken on a finite cycle of points instead of the whole line. And Part 52's iterations, Newton's method above all, converge for the reasons Analysis, Built's Part 2 proves: Cauchy sequences, and Taylor's theorem with its remainder, which also says how fast.

Some ideas stand on all three towers at once. Take the step that trains every model. Taylor's theorem, from Analysis, Built's Part 2: f at x plus h is f at x, plus the slope times h, plus half the second derivative at some point in between, times h squared. Now take Part 23's step: h is minus eta times the slope. The middle term becomes minus eta times the slope squared. If the curvature is never more than L, the last term is at most L over two, times eta squared, times the slope squared, so f falls by at least eta times one minus L eta over two, times the slope squared. Choose eta equal to one over L, and every step lowers f by at least the slope squared over two L. That inequality is why a learning rate has a ceiling, an early lesson of AI, Built's Part 11: step further than two over L, and the guarantee is gone. In many dimensions the slope becomes the gradient, the derivative of Analysis, Built's Part 4.

11The pebble, the last timeDegree5 min

Part 1 began with a game for someone who knows nothing about numbers: two piles of pebbles, and one rule. If the piles differ, take from the bigger as many as the smaller has. Twenty-four and eighteen become six and eighteen, then six and twelve, then six and six, and six is their greatest common divisor. In 1928 Hilbert and Ackermann asked whether every mathematical question could be settled like that, by a mechanical procedure that moves symbols the way the player moves stones: the Entscheidungsproblem. In 1936 Turing answered no, and to prove it he first had to say exactly what a mechanical procedure is. His answer was a machine, and everything else in this series was built on it.

Then the series climbed, from the mathematics at the bottom. Part 3 built every gate from one kind, NAND, and by Part 6 those gates were Pebble, a thirty-two-bit computer that ran the Job. Pipelines, caches and four cores made it fast; a linker, a compiler, types and garbage collectors let us speak to it; algorithms told it what to do. PebbleOS shared it among programs and kept their data on a disk; our own TCP, Raft and MapReduce joined many Pebbles; and the web, services and the cloud put the whole thing in front of people. Beside the stack stand two columns: the limits, what no machine can compute or keep secret, and the practice, how people build such things together. And in Part 55 we asked whether any of it could be trusted, and watched a compiler lie about itself, and a second compiler catch it.

The Job kept score the whole way: count the words of the thirty novels, and list the twenty most common. Here is every row of the ledger, twenty-two of them, on a scale where each step is a factor of ten. Part 6's single-cycle Pebble needed two hundred and eighty-one seconds. Part fifteen's lambda-calculus machine took two point four hours, and caches, compilers, hash tables, kernels, networks and clusters pushed the bar back and forth. The last row is Part 60's word-counting circuit: about thirty-one milliseconds, if the text arrives a byte every cycle. Most rows are computed by the machines the series built; a few were timed natively on this one.

So how much faster did the series make the Job? Divide the first row by the last: seconds over about milliseconds, a speedup of about times. That ratio is a product of steps, one from each row to the next, and they did not all point the same way. of them went slower, because each row changed what was measured as well as how fast it ran, adding a kernel, a network or a cluster. The largest step forward was -fold, from Part to Part ; the largest step back, -fold, from Part to Part . And the typical step, by chapter three's rule for averaging ratios, is the root of the total: about times faster, row after row.

At the top of the tower the floors stop, and the sky of chapter nine begins: P against NP, one-way functions, the exponent of matrix multiplication, the sixth Busy Beaver, and the rest, each met somewhere on the way up. Hilbert hoped that one procedure could settle every such question. Turing's answer means that no machine ever will, so this sky will never be empty: there will always be a question for someone to start on.

Every floor of that tower, and every star above it, began the way Part 1 did: with a small stone, moved by a rule. The Romans called such a stone a calculus. It is still the smallest thing a computer is made of: a mark that is either there or not, moved one rule at a time.

The series map, and the final reading listAll tracks2 min

The last act went past the degree, to the first year of research. Eigenvalues that know a graph's shape; theorems about when learning is possible; three meanings for every program; the limits of what distributed processes can compute; hardware built for a single job; and, in this part, the methods by which every result in the series was made.

And that is the whole map: sixty-one parts. It began with two piles of pebbles and a rule, and it ends on questions nobody can yet answer. Every layer was built on the one below it, and every one of them was built here, from gates to a cluster, from a proof to a protocol.

Six problems, the last of the series, with full solutions in the part's notes. Pause on any of them. The fifth is a build problem: repeat this part's own experiment with the stack held still, and decide, with a permutation test, whether the effect that noise hid is really there. The last, marked with a star, is the research problem of chapter nine, and it is the series' last word: pick one open problem, find its smallest open case, and settle it.

If you want to keep going, here is a shelf. For the machine, Harris and Harris, Patterson and Hennessy, and Bryant and O'Hallaron. For languages, Abelson and Sussman, Appel, and Pierce. For algorithms, the book by Cormen, Leiserson, Rivest and Stein, and Kleinberg and Tardos. For theory, Sipser, Arora and Barak, and Motwani and Raghavan. For systems, the Arpaci-Dusseaus, Kurose and Ross, and Kleppmann. For software, Brooks and Ousterhout. And for research itself, Hamming's lecture and Pólya's How to Solve It.

This is the end of Computer Science, Built. Thank you for watching all of it. The open problems are real, and some of them will be solved by people who started exactly where this series did, with a few pebbles and a rule. Take one, and start.

Where it goes next. This is the last part: nothing follows it in this series. Its bridges lead out to AI, Built (gradient descent, generalization, the roofline, typical sets) and to Analysis, Built (computable numbers, Fourier, convergence), and its map sends each open problem back to the part that met it, from Part 26's P versus NP to Part 54's verified software.

Key results

The part's results in one place, for revision.

Where a local lands\(\displaystyle \text{address}=16\,\bigl\lfloor (T-e-c)/16\bigr\rfloor+k\)
An interval for the mean\(\displaystyle \bar x\ \pm\ 1.96\,\frac{s}{\sqrt n}:\qquad\allowbreak 4n\ \text{runs }\allowbreak \text{halve }\allowbreak \text{the }\allowbreak \text{width}\)
Averaging speedups\(\displaystyle \Bigl(\prod_{i=1}^{n}\frac{a_i}{b_i}\Bigr)^{1/n}=\frac{\operatorname{GM}(a_i/r_i)}{\operatorname{GM}(b_i/r_i)}\)
Forking paths\(\displaystyle P(\text{a }\allowbreak \text{false }\allowbreak \text{alarm }\allowbreak \text{in }\allowbreak \text{20 }\allowbreak \text{tests})=1-0.95^{20}\approx 0.64\)
Euler refuted (Lander, Parkin)\(\displaystyle 27^{5}+84^{5}+110^{5}+133^{5}=144^{5}\)
One descent step\(\displaystyle f\bigl(x-\tfrac{f'(x)}{L}\bigr)\ \le\ f(x)-\frac{f'(x)^{2}}{2L}\quad\allowbreak \text{if } f''\le L\)

Try it

Lab 61 · How not to fool yourself with a stopwatch

Simulate a timing experiment in which no setting differs (33 settings, the median of 5 runs each) and compare the spread of the medians with its exact expectation; count how often 20 null comparisons produce a 'significant' one; watch a bootstrap interval narrow with runs; and settle Goldbach's small cases.

Figure produced by Lab 61: How not to fool yourself with a stopwatch
Produced by the lab below, seed 0, in 0.5 s.
python -m videos.cs.labs 61 needs numpy, scipy, matplotlib · download lab61.py · source on GitHub
2 identical settings: mean gap, slowest - fastest median   2.48% of the run time   (exact 2.42%)
33 identical settings: mean gap, slowest - fastest median  8.94% of the run time   (exact 8.95%)
33 settings: experiments whose 'speedup' exceeds 8%        79%   (2 settings: 1%)
at least one of 20 null comparisons 'significant'          64.0%   (1 - 0.95^20 = 64.2%)
bootstrap 95% interval for the mean, 5 ... 80 runs         53  38  21  19  14 ms wide
2 x 1.96 s / sqrt(n)                                       62  40  21  20  14 ms
A against B, B against A: arithmetic mean of ratios        1.25 and 1.25   (geometric: 1.00 and 1.00)
Goldbach, every even number from 4 to 2,000,000            holds: True; hardest 1,077,422 = 601 + 1,076,821

With nothing differing, the slowest of 33 medians is several percent behind the fastest, and one comparison in twenty passes a 5% test: a spread or a significant result means little until it is set beside what noise alone produces.
The code (114 lines; it asserts its own result)
"""Lab 61: measure what noise alone does to a timing experiment, to twenty comparisons and to a mean of speedups."""

from videos.coursekit import labs  # noqa: I001  (must stay first: it lets explainer.cs import without manim)

import numpy as np
from scipy import integrate, special, stats

from explainer.cs.research import method

TITLE = "How not to fool yourself with a stopwatch"
GOAL = ("Simulate a timing experiment in which no setting differs (33 settings, the median of 5 runs each) and "
        "compare the spread of the medians with its exact expectation; count how often 20 null comparisons produce a "
        "'significant' one; watch a bootstrap interval narrow with runs; and settle Goldbach's small cases.")
TASKS = [
    "Report the fastest of each five runs instead of the median (np.min). Does the noise-only spread of 33 settings "
    "shrink or grow, and what does the minimum assume about the noise?",
    "Make the noise skewed (1 + sigma * rng.exponential()) as real run times are. Which of the lab's assertions "
    "still hold, and which closed form needs replacing?",
    "Raise the comparisons from 20 to 100 and apply Bonferroni's threshold 0.05 / 100. What is the chance of a "
    "false alarm now, and what did it cost in power?",
]


def expected_range(k: int, r: int = 5) -> float:
    """E[max - min] of k independent medians of r standard normal runs (r odd), by quadrature."""
    h = (r + 1) // 2

    def integrand(x):
        g = special.betainc(h, h, stats.norm.cdf(x))  # the CDF of the median of r
        return 1 - g ** k - (1 - g) ** k

    return integrate.quad(integrand, -8, 8)[0]


def run(seed=0):
    rng = np.random.default_rng(seed)
    lab = labs.Lab()

    # 1. noise alone: K settings that do not differ, the median of r runs each, 4,000 experiments
    sigma, r, reps = 0.04, 5, 4000
    spread, theory = {}, {}
    for k in (2, 33):
        med = np.median(1 + sigma * rng.standard_normal((reps, k, r)), axis=2)
        spread[k] = (med.max(axis=1) - med.min(axis=1)) / med.min(axis=1)
        theory[k] = sigma * expected_range(k, r)
        measured = (med.max(axis=1) - med.min(axis=1)).mean()
        lab.row(f"{k} identical settings: mean gap, slowest - fastest median", f"{measured:.2%} of the run time   "
                                                                              f"(exact {theory[k]:.2%})")
        assert abs(measured / theory[k] - 1) < 0.06, "the range of k medians has a known expectation"
    assert spread[33].mean() > 3 * spread[2].mean(), "more settings, more spread, with no effect anywhere"
    lab.row("33 settings: experiments whose 'speedup' exceeds 8%", f"{(spread[33] > 0.08).mean():.0%}   "
                                                                    f"(2 settings: {(spread[2] > 0.08).mean():.0%})")

    # 2. the garden of forking paths: 20 comparisons of two identical settings, 30 runs each
    studies, tests = 3000, 20
    a = 1 + sigma * rng.standard_normal((studies, tests, 30))
    b = 1 + sigma * rng.standard_normal((studies, tests, 30))
    p = stats.ttest_ind(a, b, axis=2, equal_var=False).pvalue
    hit = (p < 0.05).any(axis=1).mean()
    lab.row("at least one of 20 null comparisons 'significant'", f"{hit:.1%}   (1 - 0.95^20 = {1 - 0.95 ** 20:.1%})")
    assert abs(hit - (1 - 0.95 ** 20)) < 0.035, "twenty looks at noise find something about two times in three"

    # 3. a bootstrap interval for the mean narrows like 1 / sqrt(runs)
    times = 0.907 + 0.028 * rng.standard_normal(80)
    ks = (5, 10, 20, 40, 80)
    width, predicted = [], []
    for k in ks:
        lo, hi = method.bootstrap(times[:k], np.mean, B=2000, seed=seed)
        width.append(hi - lo)
        predicted.append(2 * 1.96 * times[:k].std(ddof=1) / np.sqrt(k))
        assert lo < times[:k].mean() < hi
    lab.row("bootstrap 95% interval for the mean, 5 ... 80 runs", "  ".join(f"{1000 * w:.0f}" for w in width) + " ms wide")
    lab.row("2 x 1.96 s / sqrt(n)", "  ".join(f"{1000 * w:.0f}" for w in predicted) + " ms")
    assert all(abs(w / q - 1) < 0.25 for w, q in zip(width[1:], predicted[1:])), "the bootstrap agrees with the formula"
    assert 0.35 < width[4] / width[2] < 0.7, "four times the runs, about half the width"

    # 4. averaging speedups, and two conjectures' small cases
    sm = method.speedup_means()
    lab.row("A against B, B against A: arithmetic mean of ratios", f"{sm['arith_b_over_a']:.2f} and "
                                                                    f"{sm['arith_a_over_b']:.2f}   (geometric: "
                                                                    f"{sm['geo_b_over_a']:.2f} and {sm['geo_a_over_b']:.2f})")
    assert sm["arith_b_over_a"] > 1 and sm["arith_a_over_b"] > 1, "each looks slower than the other"
    assert abs(sm["geo_b_over_a"] * sm["geo_a_over_b"] - 1) < 1e-12 and abs(sm["geo_b_over_a"] - 1) < 1e-12
    gb = method.goldbach(2_000_000)
    lab.row("Goldbach, every even number from 4 to 2,000,000", f"holds: {gb['all_hold']}; hardest {gb['worst']:,} = "
                                                               f"{gb['worst_p']} + {gb['worst'] - gb['worst_p']:,}")
    assert gb["all_hold"] and (gb["worst"], gb["worst_p"]) == (1_077_422, 601)
    assert 27 ** 5 + 84 ** 5 + 110 ** 5 + 133 ** 5 == 144 ** 5 == 61_917_364_224, "Lander and Parkin against Euler"
    lab.note = ("With nothing differing, the slowest of 33 medians is several percent behind the fastest, and one "
                "comparison in twenty passes a 5% test: a spread or a significant result means little until it is "
                "set beside what noise alone produces.")

    fig, ax = labs.figure(2, size=(11, 4.4))
    bins = np.linspace(0, max(spread[33].max(), 0.01), 60)
    ax[0].hist(spread[2], bins=bins, color=labs.GREY, alpha=0.7, label="2 settings")
    ax[0].hist(spread[33], bins=bins, color=labs.BLUE, alpha=0.7, label="33 settings")
    for k, color in ((2, labs.GREY), (33, labs.BLUE)):
        ax[0].axvline(theory[k], color=color, ls="--", lw=1.4)
    ax[0].axvline(np.nan, color=labs.MUTED, ls="--", lw=1.4, label="exact mean gap")
    ax[0].set(xlabel="(slowest median - fastest median) / fastest", ylabel=f"experiments of {reps:,}",
              title="No setting differs: the spread of the medians")
    ax[0].set_xticks(np.arange(0, bins[-1], 0.02))
    ax[0].xaxis.set_major_formatter(lambda x, _: f"{x:.0%}")
    ax[0].set_axisbelow(True)
    ax[0].legend()
    ax[1].plot(ks, 1000 * np.array(width), "o-", color=labs.GOLD, label="bootstrap interval's width")
    ax[1].plot(ks, 1000 * np.array(predicted), "s--", color=labs.MUTED, label="2 x 1.96 s / sqrt(n)")
    ax[1].set(xscale="log", yscale="log", xlabel="runs", ylabel="width of the 95% interval (ms)",
              title="Four times the runs, half the width", xticks=ks, xticklabels=[str(k) for k in ks])
    ax[1].minorticks_off()
    ax[1].set_yticks([10, 15, 20, 30, 40, 60], labels=["10", "15", "20", "30", "40", "60"])
    ax[1].legend()
    lab.fig = fig
    return lab

Now change it

  1. Report the fastest of each five runs instead of the median (np.min). Does the noise-only spread of 33 settings shrink or grow, and what does the minimum assume about the noise?
  2. Make the noise skewed (1 + sigma * rng.exponential()) as real run times are. Which of the lab's assertions still hold, and which closed form needs replacing?
  3. Raise the comparisons from 20 to 100 and apply Bonferroni's threshold 0.05 / 100. What is the chance of a false alarm now, and what did it cost in power?

Problems, with solutions

Try each problem before opening its solution.

  1. No effect, and a spread. Thirty-three settings, five runs each, and no real effect: show why the spread of the 33 medians grows with the number of settings, and estimate the runs per setting that bring it under 2%.

    Solution

    With no effect, the 33 medians are independent draws from one distribution: that of a median of 5 runs, with some standard deviation s. The spread is their range over the smallest. The expected range of k independent normal draws is d(k)·s, with d(2) = 1.13, d(5) = 2.33 and d(33) = 4.16. It grows without bound, roughly like 2√(2 ln k), because every extra setting is another chance of an extreme value. So the spread grows with the number of settings even though no setting differs. On chapter 2's data: the 45 runs with an empty environment have median 0.1391 s, and a median of 5 drawn from them has s = 3.1 ms. That predicts a spread of 4.16 × 3.1 / 139 ≈ 9.5%, close to the 9.9% typical of chapter 2's 4,000 noise-only experiments. Two settings would typically spread only 1.5%. If s fell like 1/√r with r runs per setting, getting under 2% would take r ≈ 5 × (9.9 / 2)² ≈ 120. Resampling the pool directly gives a smaller answer. The typical spread is 2.3% at 30 runs, 2.0% at 35 and 1.9% at 40 (95th percentile 2.9%), so about 40 runs a setting. The rule overestimates because a median of 5 is still pulled about by the pool's long right tail (runs up to 0.177 s), and a median of 40 ignores it. The resampling can only reproduce the tail the 45 runs happened to show. At 33 × 40 runs of about 0.14 s, the whole experiment takes about three minutes. Better still, compare settings with a test rather than the range (problem 5).

  2. Geometric means. Prove that the geometric mean of speedups does not depend on the reference machine, and build two programs on which the arithmetic mean of ratios favours each machine in turn.

    Solution

    Write G(a) = (∏ aᵢ)^{1/n}. G is multiplicative, G(aᵢbᵢ) = G(a)G(b), and G(1/a) = 1/G(a). Machine X's score against a reference R is G(t_{R,i}/t_{X,i}) = G(t_R)/G(t_X). The ratio of two scores is therefore G(t_Y)/G(t_X), from which t_R has cancelled: every reference gives the same ranking. For the arithmetic mean A, take chapter 3's two programs: X takes 1 s and 4 s, Y takes 2 s and 2 s, and a score is the mean of t_R/t (bigger is better). With X as the reference, X scores (1 + 1)/2 = 1 and Y scores (1/2 + 2)/2 = 1.25: Y is 25% "faster". With Y as the reference, X scores (2 + 1/2)/2 = 1.25 and Y scores 1: X is 25% "faster". The geometric mean scores them 1 and 1 under either reference (G(1, 4) = 2 = G(2, 2)). In general, Cauchy–Schwarz gives (Σ rᵢ)(Σ 1/rᵢ) ≥ n², so A(r)·A(1/r) ≥ 1, with equality only when all the ratios are equal. Whenever the ratios differ, at least one way of normalizing therefore makes the other machine look faster; here both do. For a fixed workload, the totals (5 s against 4 s) remain the honest summary.

  3. The bootstrap for a median. Derive the bootstrap percentile interval for a median, and show its width falls like 1/√n; check it on chapter 3's thirty runs.

    Solution

    Sort the sample, x₍₁₎ ≤ … ≤ x₍ₙ₎. A resample of n draws with replacement has a median below or at x₍ⱼ₎ when at least (n + 1)/2 of its draws are among the j smallest values. For odd n, P(m* ≤ x₍ⱼ₎) = P(Bin(n, j/n) ≥ (n + 1)/2), so the bootstrap distribution can be computed exactly, without simulation. For even n, the median averages the two middle draws, and in practice one simulates B resamples. The percentile interval is the 2.5% and 97.5% quantiles of that distribution. For a density f that is continuous and positive at the median m, the sample median is asymptotically normal: √n(m̂ − m) → N(0, 1/(4f(m)²)). The bootstrap distribution reproduces that spread, so the interval's width is about 2 × 1.96 / (2f(m)√n) = 1.96/(f(m)√n), which falls like 1/√n. Check on the thirty runs (median 0.904 s): the bootstrap interval is 0.894 to 0.919 s, 25.0 ms wide. A normal density with the runs' standard deviation, 28.4 ms, has f(m) = 14.1 per second and predicts 25.5 ms. A kernel density estimate gives f(m) = 12.3 and predicts 29.0 ms. Over the first 3, 5, 10, 20 and 30 runs the median's interval is 62, 62, 41, 42 and 25 ms wide. Times √n, that is 108, 139, 131, 190 and 137: roughly constant, but lumpy, because a bootstrap median can only take the values of order statistics (or their midpoints). A distribution-free check: x₍₁₀₎ to x₍₂₁₎ covers the median with probability 1 − 2P(Bin(30, ½) ≤ 9) = 95.7%. That gives 0.894 to 0.920 s, almost the bootstrap's interval.

  4. Twenty comparisons. Twenty independent comparisons are each tested at α = 0.05. Derive the chance of at least one false positive, and the Bonferroni threshold that keeps it under 5%.

    Solution

    With no real effect, each test stays quiet with probability 0.95, and independent tests all stay quiet with probability 0.95²⁰. So P(at least one) = 1 − 0.95²⁰ = 0.642. Bonferroni uses the union bound, P(A₁ ∪ … ∪ A₂₀) ≤ Σ P(Aᵢ) = 20α′, so testing each comparison at α′ = 0.05/20 = 0.0025 keeps the familywise rate at or below 5% whether or not the tests are independent. Under independence the exact rate is 1 − 0.9975²⁰ = 0.0488, and the exact threshold (Šidák) is 1 − 0.95^{1/20} = 0.00256, barely larger. Bonferroni is conservative, but it needs no assumption about how the tests depend on one another.

  5. Build. Rerun chapter 2's experiment with stack randomization turned off, more runs per setting, and a permutation test: does environment size move the time on this machine?

    Solution

    Solution notes.

    • Turn ASLR off for the child only. Give _time in explainer/cs/research/method.py a flag that prefixes the command with setarch -R, which sets the ADDR_NO_RANDOMIZE personality for the child alone and needs no root. Check it with the stack_randomization probe. Here, under setarch -R, three runs of the probe printed the same address, and growing PAD by 16 or 128 bytes moved it down by exactly 16 or 128 bytes. Without it, 20 runs give 20 addresses (stack.json).

    • Use 16-byte steps. With the stack fixed, 128-byte steps leave the address modulo 64 unchanged, so chapter 2's grid tests only the 32 positions in a page and never the cache-line offset.

    • Permutation test. Keep the interleaved rounds. As the statistic, take the spread of the medians, or the one-way F statistic on log times. Shuffle the setting labels within each round (the rounds are blocks, so drift cancels), recompute the statistic, say 5,000 times, and report p = (count + 1)/(5,001).

    • What a good run shows. If the environment matters, p is small and the medians follow the address: they depend on it modulo 64 or 4,096, and repeat with that period, which is the causal check. If it does not, p is roughly uniform and the line-offset groups agree.

    • Our run (on 7 November 2026). One caveat first. The program ran about 35% slower than when the cache was measured (medians 0.186 to 0.213 s against 0.133 to 0.142 s), so the machine was not in the same state. The results:

      Design Spread of medians p (spread) p (F)
      ASLR off; 33 sizes in 128-byte steps × 15 runs 10.0% 0.26 0.28
      ASLR off; 64 sizes from 0 to 1,008 bytes in 16-byte steps × 8 runs 14.4% 0.52 0.99
      ASLR on; the first design repeated 11.2% 0.24 0.25

      In the 16-byte design, the medians of the four cache-line offsets were 0.1909, 0.1908, 0.1931 and 0.1924 s, within 1.2% of one another.

    • Conclusion. No detectable effect of environment size on this machine, for this kernel, with ASLR off or on. That is plausible from the code: at -O2, count keeps its state in registers (four pushes at entry, none in the loop), so the only stack traffic in the hot loop is the return address of each call to mix. A kernel with hot locals spilled to the stack, or with stores that can alias them in their low twelve bits, is where to look next.

  6. ★ Research. Pick one star from chapter 9's map, find its smallest open special case, and settle it.

    Discussion. Open by design: the problem asks you to choose an open question and cut it down until it is small enough to finish. Each star on the map is open because it has resisted every known method, and the obstacles do not vanish in special cases: Part 26's barriers (relativization, natural proofs, algebrization) rule out whole families of techniques, so a special case is worth having only if you can say which known obstacle it avoids. Two of the series' earlier ★ problems show the shape of a good cut. BB(6) shrinks to single six-state machines whose halting is unknown, such as Antihydra (Part 1's ★), whose fate is a Collatz-like question about the parities of ⌊3h/2⌋-iterates. Circuit lower bounds shrink to exact minimum circuits for every function of a few inputs (computed to four inputs in Part 3's ★, with the last five-input cases closed by SAT solvers) and to the Minimum Circuit Size Problem. A good partial answer (1) states the special case precisely, with a parameter that measures its size; (2) shows that it is open, from the literature, and that the cases below it are settled, by citation or by computation; (3) settles it, or settles a smaller case and says exactly what blocks the next one, which is itself a result; and (4) writes it up as chapter 8 asks, with every claim matched to its evidence and the threats to validity stated. A search proves a finite statement exactly and can find a counterexample; it never proves the infinite one, so the write-up must say which kind of result it is. Where to start in the repository: goldbach and collatz in explainer/cs/research/method.py show the pattern of a search that proves a finite statement and keeps the records that show where a proof would have to work hardest; Part 26's SAT solver is the tool for finite combinatorial cases; and Part 54's kernel is the place to check a proof once you have one.

Notes and sources

Where it comes back

This is the last part of Computer Science, Built: sixty-one parts in eleven acts, from two piles of pebbles and a rule to the open problems on chapter 9's map. One program, the Job, kept score the whole way, and its ledger runs from Part 6's 281 s on a single-cycle Pebble to Part 60's 31.5 ms in a circuit. Every measured number in the series is recomputed by its parts' compute.py; the series plan lists every part, and the sibling series are AI, Built (../../ai/) and Analysis, Built (../../analysis/).

Glossary

  • falsifiability, hypothesis, prediction — a claim some observation could refute; what it predicts; the test.
  • measurement bias, setup randomization, causal analysis — a systematic error from an innocuous-looking part of the setup; measuring over many random setups; changing one suspected cause alone and checking that the effect follows.
  • address-space layout randomization (ASLR) — the operating system placing the stack (and other regions) at a random address on every run.
  • threats to validity — the ways an experiment's conclusion could be wrong, stated by its authors.
  • start-up and steady-state performance, warm-up — the time of the first iterations against the time after a runtime has settled.
  • bootstrap, resample, confidence interval — drawing n values from the sample with replacement, many times, and reading an interval from the spread of the statistic.
  • geometric mean — the n-th root of a product; a mean of ratios that gives the same verdict whichever way round they are taken, and whichever reference they are normalized to.
  • benchmark, synthetic benchmark, Goodhart's law — a program whose speed stands for others'; one written to be representative; a measure that becomes a target stops being a good measure.
  • base and peak results — one set of compiler flags for every benchmark in a language; flags tuned per benchmark.
  • garden of forking paths, p-hacking, false alarm — the many analysis choices between data and claim; choosing among them until a test passes; a significant result with nothing behind it.
  • repeatable, reproducible, replicable; artifact evaluation — the same team and setup; another team with the authors' artifacts; another team with its own setup; a committee running a paper's code and data.
  • conjecture, counterexample, computer-assisted proof, trusted base — a statement believed and unproved; a case that refutes it; a proof with a program in it; what a proof asks you to trust.
  • Liouville's λ, Pólya's conjecture — (−1) to the number of prime factors counted with repetition; the claim that its running sum never rises above zero, false first at 906,150,257.
  • three-pass reading, the five Cs, referee report — Keshav's method; category, context, correctness, contributions, clarity; a review's summary, strengths, weaknesses, questions and verdict.
  • permutation test, Bonferroni correction — a p-value from reshuffling the labels the null hypothesis says do not matter; testing each of k comparisons at α/k to keep the chance of any false alarm under α.
  • limit study, headroom — the best possible, measured before the work; the gap between it and today.
  • Toulmin model: claim, data, warrant, backing, qualifier, rebuttal — the parts of an argument.

Sources

  • T. Mytkowicz, A. Diwan, M. Hauswirth and P. Sweeney, "Producing wrong data without doing anything obviously wrong!", ASPLOS 2009; C. Curtsinger and E. Berger, "Stabilizer: statistically sound performance evaluation", ASPLOS 2013.
  • A. Georges, D. Buytaert and L. Eeckhout, "Statistically rigorous Java performance evaluation", OOPSLA 2007; R. Jain, The Art of Computer Systems Performance Analysis (Wiley, 1991); B. Efron, "Bootstrap methods: another look at the jackknife", Annals of Statistics 7(1), 1979; P. Fleming and J. Wallace, "How not to lie with statistics: the correct way to summarize benchmark results", Communications of the ACM 29(3), 1986.
  • R. Weicker, "Dhrystone: a synthetic systems programming benchmark", Communications of the ACM 27(10), 1984; J. Hennessy and D. Patterson, Computer Architecture: A Quantitative Approach (on SPEC and matrix300); M. Strathern, "'Improving ratings': audit in the British university system", European Review 5(3), 1997.
  • J. Simmons, L. Nelson and U. Simonsohn, "False-positive psychology", Psychological Science 22(11), 2011; A. Gelman and E. Loken, "The garden of forking paths" (2013); C. Collberg and T. Proebsting, "Repeatability in computer systems research", Communications of the ACM 59(3), 2016; ACM, "Artifact review and badging".
  • K. Popper, Logik der Forschung (1934; The Logic of Scientific Discovery, 1959); L. Fortnow, "Time for computer science to grow up", Communications of the ACM 52(8), 2009.
  • L. Lander and T. Parkin, "Counterexample to Euler's conjecture on sums of like powers", Bulletin of the AMS 72, 1966; N. Elkies, "On A⁴ + B⁴ + C⁴ = D⁴", Mathematics of Computation 51, 1988; C. B. Haselgrove, "A disproof of a conjecture of Pólya", Mathematika 5, 1958; T. Oliveira e Silva, S. Herzog and S. Pardi, "Empirical verification of the even Goldbach conjecture and computation of prime gaps up to 4·10¹⁸", Mathematics of Computation 83, 2014.
  • G. Gonthier, "Formal proof — the four-color theorem", Notices of the AMS 55(11), 2008; T. Hales et al., "A formal proof of the Kepler conjecture", Forum of Mathematics, Pi 5, 2017; M. Heule, O. Kullmann and V. Marek, "Solving and verifying the Boolean Pythagorean triples problem via cube-and-conquer", SAT 2016.
  • S. Keshav, "How to read a paper", ACM SIGCOMM Computer Communication Review 37(3), 2007; A. J. Smith, "The task of the referee", IEEE Computer 23(4), 1990.
  • R. Hamming, "You and your research", a talk at Bellcore, 1986; G. Pólya, How to Solve It (Princeton, 1945); L. Belady, "A study of replacement algorithms for a virtual-storage computer", IBM Systems Journal 5(2), 1966; D. Wall, "Limits of instruction-level parallelism", ASPLOS 1991.
  • S. Toulmin, The Uses of Argument (Cambridge, 1958); E. Tufte, The Visual Display of Quantitative Information (Graphics Press, 1983); J. Zobel, Writing for Computer Science (3rd ed., Springer, 2014).
  • S. Aaronson, "P =? NP", in Open Problems in Mathematics (Springer, 2016); the records on the open-problems map are cited in the parts that met them.
About this partfrom its README

Part 61 of a sixty-one-part course in computer science (see the series plan and the syllabus), the sixth and last part of Act XI, The Research Frontier, and the coda of the series. The series has quoted a thousand results; this part asks where they come from, and how you would make one. We reproduce a famous measurement-bias experiment on this machine and find that, with the stack already placed at random on every run, noise alone explains what we see; then we time the Job rigorously, watch benchmarks and analyses fail, settle small cases of conjectures by computer, and practise reading, reviewing, choosing a problem and writing. It ends on the open problems the series met, gathered on one map, on the bridges to AI, Built and Analysis, Built, and on the tower one last time.

The instrument is in explainer/cs/research/ (tested in tests/test_cs61_research.py):

  • method.py: the measurement-bias experiment after Mytkowicz et al. (a word-counting C kernel in the Job's style, a hash-mixing function and a driver that fills 16 MiB with pseudo-random letters and spaces and times four passes; built once with gcc -O2, linked in three orders, and run with an unused environment variable padded from 0 to 4,096 bytes in steps of 128: five interleaved rounds over the sizes, then fifteen rounds over the link orders with the variable empty); percentile bootstrap intervals; the Job in plain Python on the thirty novels, timed 30 times, with intervals after 3, 5, 10, 20 and 30 runs; arithmetic against geometric means of two illustrative speedups; Goldbach's conjecture checked to 2,000,000 by a sieve and a strike-out pass per prime, with its records; the Collatz conjecture below 1,000,000, each path followed only until it drops below its start, with the record stopping times; a probe that prints a local variable's address from 20 fresh runs of a C program, and counts the distinct addresses, their offsets in a cache line and a page, and the kernel's ASLR setting; and the eleven open problems the series met, with their records and parts.

The scenes also read other parts' caches: Part 1's piles, Part 2's Ramsey check, Part 7's predictors and Amdahl limit, Part 54's proof kernel, Part 60's Job, and the final ledger (from Part 60, or Part 55 before it).

Chapter notes
  • Hook. One C program, compiled once, timed on this machine while only an unused environment variable grows from nothing to 4 KiB: the median time moves by up to 7%. Mytkowicz, Diwan, Hauswirth and Sweeney (2009) showed that such changes move where the stack begins, and with it the alignment of hot data, enough to decide which of two compiler settings looked faster; but with the stack randomized on every run, is our spread that effect or only noise? Where results come from: a question, a method, evidence, a paper. The plan.
  • 1. What research is. A vague question ("does the environment affect speed?") sharpened until it could come out wrong (which variable, which program, which machine, compared with what); hypothesis, prediction, test, and Popper's falsifiability (1934). Three kinds of evidence: proof (Turing 1936, Part 25; proof assistants, Part 54), experiment (Mytkowicz et al.), construction (Ritchie and Thompson's Unix paper, 1974, Part 31). The shape of a paper and the three questions it answers: does it matter, is it right, is it new. Conferences (SOSP since 1967, STOC 1969, POPL 1973) against journals (JACM, 1954) and arXiv (1991); Fortnow (2009). This part's own experiment written as a paper: 33 sizes × 5 runs and 3 link orders × 15 runs; medians spread 6.7% across sizes and 0.9% across link orders, both within the noise; the threats to validity; no effect shown, which is not the same as no effect.
  • 2. Measurement bias. Linux copies the environment strings to the top of the new stack, so every byte added moves every frame down: a hot local's address is 16⌊(T − e − c)/16⌋ + k, one of four places in a 64-byte cache line (Part 9) and 256 in a 4 KiB page; a line split (illustrative) and 4K aliasing. Experiment one: 33 sizes in 128-byte steps, 5 interleaved runs each; the medians spread 6.7%, the fastest of each five 5.3%, while 15 more runs of the one unchanged setting range over 22%, three times the medians' spread. Experiment two: three link orders, 15 runs each with the environment empty; the medians differ by 0.9%, far inside the scatter. What the 2009 paper found (bias on every processor and both compilers tried, in most of SPEC CPU2006's C programs; enough to change whether -O3 looked faster than -O2; none of the hundred-odd papers it surveyed adequately accounted for it), its remedies (setup randomization, causal analysis), and Curtsinger and Berger's Stabilizer (2013). The verdict: 4,000 noise-only experiments, each drawing 33 medians of 5 from the 45 runs with an empty environment, typically spread 10%, and 89% of them exceed our 6.7%. Shown: the medians moved. Not shown: that the environment moved them; with address randomization on, Linux starts the stack at a different 16-byte step on every run, a setup randomization done for us (the stack probe: 20 runs of a C program printing a local's address gave 20 distinct addresses, 4 offsets within a 64-byte line and 20 within a page, with randomize_va_space = 2).
  • 3. Measuring rigorously. Thirty runs of the Job in plain Python on the same 25 million characters: best 0.865 s, worst 0.962 s (11% slower), mean 0.907 s; Georges, Buytaert and Eeckhout (2007) on single-number reporting. Start-up against steady state for a JIT-compiled runtime (Part 15; illustrative), and our runs in order: no trend, the slowest is run 18. The bootstrap (Efron 1979) derived and run: a 95% interval for the mean from 0.897 to 0.917 s. More runs, narrower intervals: 62 ms wide after 3 runs, then 41, 29 and 26, and 20 ms after 30, beside the prediction ±1.96 s/√n (four times the runs for half the width); the centre drifts from 913 ms to 907 ms. Averaging speedups (illustrative times: A takes 1 s and 4 s, B 2 s and 2 s): the arithmetic mean of the ratios says each is a quarter slower than the other, the geometric mean says 1 either way round (Fleming and Wallace 1986), and for a fixed workload the totals, 5 s against 4 s, are the honest summary.
  • 4. Benchmarks and reproducibility. Dhrystone (Weicker 1984); the SPEC suites from 1989 to 2017, with matrix300 and libquantum dropped. Goodhart's law (1975, in Strathern's 1997 phrasing), the loop from measure to target, a score drifting from the real programs (illustrative), and benchmark-detecting phones (2013) and Volkswagen's diesels (2015). How SPEC keeps score: ratios to a reference machine, their geometric mean, and why the reference cancels; base and peak, disclosure, review, retirement. The garden of forking paths (Simmons, Nelson and Simonsohn 2011; Gelman and Loken 2013): 1 − 0.95²⁰ ≈ 0.64; in our data, the fastest environment size against the slowest is a 6.7% "speedup". Repeatable, reproducible and replicable in the ACM's terms; Collberg and Proebsting (2016); artifact evaluation since 2011; this series' compute, cache and load pipeline.
  • 5. Proof as research. The life of a conjecture: Goldbach (1742; checked to 4 × 10¹⁸ by 2014), Euler's sums of powers (1769; refuted 1966), four colours (1852; Kempe's failed proof, 1879; Appel and Haken by computer, 1976, Part 18; Gonthier in Coq, 2005). What a search proves: every even number from 4 to 2,000,000 is a sum of two primes, a theorem; the hardest case, 1,077,422 = 601 + 1,076,821, needs only the 110th prime. The Collatz check as strong induction (Part 2): the path from 7 climbs to 52 and falls to 5, and every start below 1,000,000 reaches 1. Euler refuted by Lander and Parkin: 27⁵ + 84⁵ + 110⁵ + 133⁵ = 144⁵ = 61,917,364,224; Elkies (1988) and Frye's 95800⁴ + 217519⁴ + 414560⁴ = 422481⁴, both checked in exact integers. When the evidence misleads: Liouville's λ for n ≤ 20, its running sum touching zero at 2, 4, 6, 10 and 16; Pólya's conjecture, Haselgrove (1958), Tanaka's first failure at 906,150,257 (1980). What a proof asks you to trust: Part 2's pigeonhole argument; Part 2's check of all 2¹⁵ = 32,768 colourings (0 escape), the four colour theorem, Hales on Kepler (1998) and Part 26's 200-terabyte Pythagorean-triples proof (2016); a kernel (Coq's four colours, 2005; Flyspeck, 2014; Part 54's 69 lines and 11 rules).
  • 6. Reading and reviewing. Keshav's three passes (2007). The five Cs on an invented abstract ("Skim", 2.1 times faster on thirty novels). Finding what is not said, phrase by phrase: which texts; how many runs (our Job's 30 runs spread 11%); which baseline (an unused variable moved our medians 6.7%); how much is "little"; no limitations, threats or code. The third pass as this part's rebuild of the 2009 paper, which asked whether the stack starts at the same address on every run (here it does not) and so found the paper's own remedy, setup randomization, already switched on. Writing a review of the invented paper (summary, strengths, weaknesses, questions, verdict and confidence); Smith's "The task of the referee" (1990).
  • 7. Finding problems. Hamming's "You and Your Research" (1986): the lunch questions, important means it would matter and you have an attack, ten to twenty problems in mind. Compound interest taken literally (illustrative): 1.1ⁿ = 2 at n = ln 2 / ln 1.1 ≈ 7.3 years. Pólya's How to Solve It (1945): six quarts from a 4- and a 9-quart pail, worked backwards (6 = 9 − 3; the 4 takes 3 if it holds 1; 1 = 9 − 4 − 4), against Part 2's search of every state. Limit studies: the Job's branches on Part 7's predictors, 8.8% mispredicted by 2-bit counters, 5.7% by TAGE at 9 KB, 2.5% with no storage limit; Amdahl's law with 1 − p = 0.002854, so S ≤ 350; the ledger's 58 s in Part 13 against 0.81 s with Part 17's hash table, about 72 times. Working backwards from the ideal: Belady (1966) for caches (Parts 9, 32); for the Job, Part 17's hash table at about 29 cycles a byte against one byte a cycle, 31 ms (Part 60).
  • 8. Writing. Toulmin's argument (1958) on this part's result: claim, data (6.7% across 33 sizes, 5 runs each), warrant, backing (the 4,000 simulated experiments), qualifier, rebuttal (unless address randomization hides a real effect). Every claim and its evidence, on the invented paper. Figures that carry the claim, from chapter 2's link orders: medians only on an axis cut at 0.138 s, the tallest bar 7.6 times the shortest, against all 45 runs, where the medians differ by under 1% and each order's runs spread 18% to 35%; Tufte (1983). How a computed number travels, from method.py through compute.py and bias.json to load("bias") and the spoken 7%. Three kinds of number, three labels (computed here, published, illustrative); Hamming on writing; Zobel.
  • 9. Frontier: the open-problems map. The eleven open problems the series met, as a sky over the tower, each with the year it was asked and its parts: P versus NP (1971; Part 26), one-way functions (1976; Parts 29, 30), the exponent of matrix multiplication (1969; ω < 2.372 in 2024; Parts 19, 52), BB(6) (1962; BB(5) = 47,176,870 proved in 2024; Part 25), dynamic optimality (1985; Tango trees, 2004; Part 17), the unique games conjecture (2002; the 2-to-2 theorem, 2018; Parts 23, 56), BPP = P? (1980; PRIMES in P, 2004; Parts 20, 27), circuit lower bounds (1949; about 3.1n gates, 2022; Parts 3, 26), a memory model for C (2011; out-of-thin-air; Part 33), practical quantum advantage (1994; error correction below threshold, 2024; Part 53), verified software at scale (1969; seL4 and CompCert; Part 54). Start with the small cases: Goldbach to 2,000,000 (22 records of the smallest prime needed, the last 1,077,422 with 601), Collatz below 1,000,000 (the longest, 837,799, takes 524 steps). Choosing a problem: important and attackable; a special case first; a new tool for an old problem; measure the headroom. The ★ research problem.
  • 10. Where the series meet. The thirty novels of AI, Built Part 1 (Pride and Prejudice … Ulysses), on which that series trains and scores its models (held-out passage: The Maltese Falcon, chapter 2), and which this series' Job counts: 24,971,526 bytes, 4,609,954 words. Seven bridges between the towers: Part 23 and AI, Built 11 (gradient descent), 57 and 8 (generalization), 60 and 17 (the roofline), 28 and 1 (typical sets); Part 1 and Analysis, Built 1 (computable numbers and Cantor's diagonal), 19 and 9 (Fourier), 52 and 2 (convergence). One step on three towers: Taylor's theorem gives f(x − f′(x)/L) ≤ f(x) − f′(x)²/2L when f″ ≤ L, run on log cosh x with L = 1, and the 2/L ceiling on the learning rate. More crossings, dashed: Part 18 and AI, Built 5 (PageRank, Markov chains), 20 and 3 (Johnson–Lindenstrauss), 54 and 25 (Lean).
  • 11. The pebble, the last time. Part 1's piles, 24 and 18 to 6 and 6, gcd 6; Hilbert and Ackermann (1928) and Turing (1936). The tower the series built, floor by floor, with its two columns and Part 55's question of trust. The ledger, all 22 rows on a log scale: Part 6's single-cycle Pebble 281 s, Part 15's λ-core 2.4 hours, Part 60's word-counting unit 31.5 ms; 3 rows timed natively. First row against last: 281.04 s / 0.031464 s ≈ 8,932, a product of 21 steps, 9 of them slower; the largest step forward ×1,699 (Part 15 to 16), the largest back ÷149 (Part 13 to 15); the geometric mean, 1.54 per step (chapter 3's rule). The sky above the top floor, and calculus, a small stone.
  • Outro. Act XI in six lines; the series map, sixty-one parts; six problems, the series' last; the final reading list; thank you.

Companion material in this repository

The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
  1. What research is: a question, a method, evidence; the shape of a paper; conferences and journals in CS.
  2. Measurement bias (Mytkowicz, Diwan, Hauswirth & Sweeney 2009), reproduced: link order and environment size change the Job's measured speed on this machine.
  3. Statistically rigorous performance evaluation (Georges, Buytaert & Eeckhout 2007): confidence intervals, repeated runs, warm-up; the statistics of speedups (geometric means, and why).
  4. Benchmarks and their failures; reproducibility and artifact evaluation; p-hacking in systems research.
  5. Proof as research: how a conjecture becomes a theorem; counterexample search by computer; formal proof (callback to Parts 2, 54).
  6. Reading and reviewing: the three-pass method; how to review; how to find what is not said.
  7. Finding problems: Hamming's "You and Your Research" (1986); limit studies as a way to find headroom (Part 7's).
  8. Writing: the structure of an argument; figures that carry the claim; the series' own conventions as a case study.
  9. The open-problems map: P vs NP and one-way functions; ω; BB(6); dynamic optimality; the UGC; derandomization; circuit lower bounds; a memory model for C; practical quantum advantage; verified software at scale; each with its record and the part that met it.
  10. The bridge to AI, Built and Analysis, Built: where the series meet.
  11. The pebble, the last time: from Hilbert's question to the frontier.
  12. Outro: the series map, the final reading list.

Computed: the measurement-bias experiment on this machine (link orders × environment sizes); bootstrap confidence intervals for the ledger's measured rows; a counterexample search (an open conjecture's small cases, checked); the open-problems map with each record and date. Visuals: the same program's runtime jumping as an environment variable grows; confidence intervals tightening with runs; the open-problems map as a sky over the tower. In practice: research roles in industry labs, performance engineering, writing design documents and papers, reviewing. Reading: Hamming 1986; Mytkowicz et al. 2009; Georges et al. 2007; Jain, The Art of Computer Systems Performance Analysis; Keshav, "How to read a paper" (2007); Pólya, How to Solve It; Zobel, Writing for Computer Science; Aaronson, "P =? NP" (2016).


中文讲义

本讲的中文部分(与英文版对应)。

习题与解答
  1. 没有效应,却有离散。 33 种设置,每种运行 5 次,而且并没有真实的效应:说明为什么 33 个中位数的离散度随设置的数目增大,并估计每种设置需要 运行多少次才能使它降到 2% 以下。

    解答

    没有效应时,33 个中位数是从同一个分布中独立抽取的:即 5 次运行的中位数的分布,设其标准差为 s。离散度是它们的极差除以最小值。k 个 独立正态值的极差的期望是 d(k)·s,其中 d(2) = 1.13,d(5) = 2.33,d(33) = 4.16。它无界地增长,大约像 2√(2 ln k),因为每多一种设置就多一次 出现极端值的机会。所以即使没有任何一种设置真的不同,离散度也随设置的数目增大。用第 2 章的数据:环境变量为空的 45 次运行的中位数是 0.1391 秒, 从中抽取的 5 次运行的中位数的标准差 s = 3.1 毫秒。由此预测离散度为 4.16 × 3.1 / 139 ≈ 9.5%,接近第 2 章 4000 次纯噪声实验的典型值 9.9%。 只有两种设置时,典型离散度只有 1.5%。如果 s 随每种设置的运行次数 r 按 1/√r 下降,要降到 2% 以下需要 r ≈ 5 × (9.9 / 2)² ≈ 120。直接对这些 运行重抽样,得到的答案更小:30 次时典型离散度为 2.3%,35 次时 2.0%,40 次时 1.9%(第 95 百分位为 2.9%),所以每种设置大约 40 次。这条规则 高估了,因为 5 次运行的中位数仍会被这批运行的右侧长尾(最慢的达 0.177 秒)拉动,而 40 次的中位数不理会它。重抽样只能再现这 45 次运行恰好 显示出的尾部。33 × 40 次、每次约 0.14 秒,整个实验大约三分钟。更好的做法是用检验而不是极差来比较各种设置(第 5 题)。

  2. 几何平均。 证明加速比的几何平均与参考机器无关,并构造两个程序,使比值的算术平均依次偏向每一台机器。

    解答

    记 G(a) = (∏ aᵢ)^{1/n}。G 是可乘的:G(aᵢbᵢ) = G(a)G(b),且 G(1/a) = 1/G(a)。机器 X 相对参考机器 R 的得分是 G(t_{R,i}/t_{X,i}) = G(t_R)/G(t_X)。因此两个得分之比为 G(t_Y)/G(t_X),t_R 已经消去:无论选哪台参考机器,排名都一样。对算术平均 A,取第 3 章 的两个程序:X 用 1 秒和 4 秒,Y 用 2 秒和 2 秒,得分是 t_R/t 的平均(越大越好)。以 X 为参考,X 得 (1 + 1)/2 = 1,Y 得 (1/2 + 2)/2 = 1.25: Y “快” 25%。以 Y 为参考,X 得 (2 + 1/2)/2 = 1.25,Y 得 1:X “快” 25%。几何平均在两种参考下都给出 1 和 1(G(1, 4) = 2 = G(2, 2))。一般地, 由柯西–施瓦茨不等式,(Σ rᵢ)(Σ 1/rᵢ) ≥ n²,所以 A(r)·A(1/r) ≥ 1,当且仅当所有比值相等时取等号。因此只要比值不全相等,至少有一种归一化方式会 让另一台机器显得更快;这里两种都会。对于固定的工作量,总时间(5 秒对 4 秒)才是诚实的概括。

  3. 中位数的自助法。 推导中位数的自助法百分位区间,证明它的宽度按 1/√n 下降,并用第 3 章的 30 次运行检验。

    解答

    把样本排序,x₍₁₎ ≤ … ≤ x₍ₙ₎。有放回地抽取 n 个值的重抽样,其中位数不超过 x₍ⱼ₎,当且仅当至少 (n + 1)/2 个抽取值落在最小的 j 个值中。 n 为奇数时,P(m* ≤ x₍ⱼ₎) = P(Bin(n, j/n) ≥ (n + 1)/2),所以自助分布可以精确算出,无需模拟。n 为偶数时,中位数是中间两个抽取值的平均,实践中 模拟 B 次重抽样。百分位区间就是这个分布的 2.5% 和 97.5% 分位数。若密度 f 在中位数 m 处连续且为正,样本中位数渐近正态: √n(m̂ − m) → N(0, 1/(4f(m)²))。自助分布再现了这个离散程度,所以区间宽度约为 2 × 1.96 / (2f(m)√n) = 1.96/(f(m)√n),按 1/√n 下降。在 30 次运行上 检验(中位数 0.904 秒):自助区间为 0.894 到 0.919 秒,宽 25.0 毫秒。以这些运行的标准差 28.4 毫秒为参数的正态密度,f(m) = 每秒 14.1,预测 宽度 25.5 毫秒。核密度估计给出 f(m) = 12.3,预测 29.0 毫秒。取前 3、5、10、20、30 次运行,中位数区间的宽度依次为 62、62、41、42、25 毫秒。 乘以 √n 后为 108、139、131、190、137:大致恒定,但有起伏,因为自助中位数只能取次序统计量(或它们的中点)的值。一个不依赖分布的检验:x₍₁₀₎ 到 x₍₂₁₎ 覆盖中位数的概率是 1 − 2P(Bin(30, ½) ≤ 9) = 95.7%。它给出 0.894 到 0.920 秒,几乎就是自助法的区间。

  4. 二十次比较。 二十次独立的比较,各以 α = 0.05 检验。推导至少出现一次假阳性的概率,以及使它保持在 5% 以下的 Bonferroni 阈值。

    解答

    没有真实效应时,每次检验以 0.95 的概率不报警,独立的检验全都不报警的概率是 0.95²⁰。所以 P(至少一次) = 1 − 0.95²⁰ = 0.642。 Bonferroni 用的是并集上界:P(A₁ ∪ … ∪ A₂₀) ≤ Σ P(Aᵢ) = 20α′。所以每次比较都以 α′ = 0.05/20 = 0.0025 检验,无论检验之间是否独立,整族的错误率都 不超过 5%。在独立的假设下,精确的错误率是 1 − 0.9975²⁰ = 0.0488,精确的阈值(Šidák)是 1 − 0.95^{1/20} = 0.00256,只大一点点。Bonferroni 偏保守,但它不需要对检验之间的相关性作任何假设。

  5. 动手。 关闭栈随机化,每种设置多运行几次,再加一个置换检验,重做第 2 章的实验:在这台机器上,环境的大小会改变运行时间吗?

    解答

    解答要点。

    • 只对子进程关闭 ASLR。 给 explainer/cs/research/method.py 中的 _time 加一个开关,在命令前加上 setarch -R。它只为子进程设置 ADDR_NO_RANDOMIZE,不需要 root 权限。用 stack_randomization 探针检查。在这里,用 setarch -R 运行三次探针,打印出的地址相同;把 PAD 加长 16 或 128 字节,地址恰好下移 16 或 128 字节。不用它时,20 次运行给出 20 个地址(stack.json)。

    • 用 16 字节的步长。 栈固定以后,128 字节的步长不改变地址模 64 的值,所以第 2 章的网格只检验了页内的 32 个位置,从未检验缓存行内的偏移。

    • 置换检验。 保留交错的轮次。统计量取各中位数的离散度,或对数时间的单因素 F 统计量。在每一轮之内打乱设置的标签(轮次是区组,漂移因此抵消), 重新计算统计量,比如 5000 次,报告 p = (计数 + 1)/5001。

    • 好的结果是什么样。 如果环境有影响,p 会很小,而且中位数跟着地址走:它们取决于地址模 64 或模 4096 的值,并以这个周期重复,这就是因果检验。 如果没有影响,p 大致均匀分布,各缓存行偏移组的结果一致。

    • 我们的运行(2026 年 11 月 7 日)。 先说一个保留:程序比测量缓存时慢了约 35%(中位数 0.186 到 0.213 秒,缓存中是 0.133 到 0.142 秒), 所以机器的状态并不相同。结果如下:

      设计 中位数的离散度 p(离散度) p(F)
      关闭 ASLR;33 种大小,步长 128 字节 × 15 次 10.0% 0.26 0.28
      关闭 ASLR;0 到 1008 字节的 64 种大小,步长 16 字节 × 8 次 14.4% 0.52 0.99
      开启 ASLR;重复第一种设计 11.2% 0.24 0.25

      在 16 字节的设计中,四种缓存行偏移的中位数为 0.1909、0.1908、0.1931 和 0.1924 秒,彼此相差不到 1.2%。

    • 结论。 在这台机器上、对这个内核,无论 ASLR 开或关,都检测不到环境大小的影响。从代码看这是合理的:在 -O2 下,count 把状态放在寄存器里 (入口处四次压栈,循环中没有),所以热循环里唯一的栈访问是每次调用 mix 的返回地址。下一步该看的是把热局部变量溢出到栈上的内核,或者带有 低 12 位可能与它们混叠的存储操作的内核。

  6. ★ 研究。 从第 9 章的地图上挑一颗星,找出它最小的、尚未解决的特殊情形,并解决它。

    讨论。 这道题本身就是开放的:它要求你选一个未解决的问题,把它切小,直到小得可以做完。地图上的每颗星之所以未解决,是因为它抵挡住了所有已 知的方法,而这些障碍在特殊情形中并不会消失:第 26 讲的几道壁垒(相对化、自然证明、代数化)排除了整类的技术,所以一个特殊情形只有在你能说明 它绕开了哪一道已知障碍时才值得做。本系列前面的两道 ★ 题已经给出了好的切法。BB(6) 可以缩小为一台台停机与否尚不清楚的六状态机器,比如反 九头蛇(第 1 讲的 ★),它的命运是关于 ⌊3h/2⌋ 迭代奇偶性的一个类似 Collatz 的问题。电路下界可以缩小为少数几个输入的每个函 数的精确最小电路(第 3 讲的 ★ 算到四个输入,五个输入的最后几种情形由 SAT 求解器解决),以及最小电路规模问题(MCSP)。好的部分结 果应当:(1)精确地陈述这个特殊情形,并给出衡量其大小的参数;(2)根据文献说明它尚未解决,并通过引用或计算说明比它小的情形都已解决;(3)解 决它,或者解决一个更小的情形并准确说明是什么挡住了下一个,这本身就是一个结果;(4)按第 8 章的要求写出来,每个论断都对应它的证据,并写明对 有效性的威胁。搜索能精确地证明一个有限的命题,也能找到反例,但永远证明不了无限的命题,所以文章必须说清楚结果属于哪一种。在本仓库里从哪里开始: explainer/cs/research/method.py 中的 goldbach 和 collatz 展示了这种模式:搜索证 明一个有限的命题,并记录下那些显示证明在哪里最费力的纪录;第 26 讲的 SAT 求解器是处理有限组合情形的工具;有了证明之后,第 54 讲的 内核是检查它的地方。

Build the film

python -m videos.cs.cs61.compute        # the part's numbers, into .cache/cs61
python tools/build.py cs61                  # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py cs61 Hook   # one chapter, silent, with a contact sheet

Scenes: videos/cs/cs61. Setup: see the course page. Source of these notes: the README and the scenes' narration.

Build it
python -m videos.cs.cs61.compute
python -m unittest tests.test_cs61_research
python tools/build.py cs61

The ledger item copies the final ledger from Part 60's cache (or Part 55's), so run that part's compute first. The bias and timing items measure this machine, so a machine that is busy while they run will give other numbers, and the narration will follow them.