When the algorithm flips a coin

A reserve sized for the spill

A split threshold table gives every line the same room, the mean number of closed blocks plus some standard deviations. Giving each line room for the mean and each group of 64 lines a shared reserve at one standard deviation of the group's total was predicted to cost about 3.24 bits a block for 2.006 lines a lookup, under the best ungrouped line. The reserve it predicts holds 52 values where the group's lines spill 145: it is full in every group, the spills go on to a third line, and the table lands on the ungrouped curve. Sized for the spill instead, the reserve puts the table under that curve at every room, by two to three hundredths of a bit a block.

An offset that only has to reach its neighbours worked on the table that tells a blocked filter where each block’s threshold closed. The table keeps one bit a block for whether the threshold closed and a four-bit value for each block that did, packed into 512-bit lines that a lookup reads in one go, the line a blocked filter confines its positions to. Every line is given room for the mean number of closed blocks plus some standard deviations, and the values that do not fit move to a shared overflow area that costs a lookup a second line. That essay found that grouping lines to shorten the offset into the overflow did not pay: an ungrouped offset sized for the overflow the table actually has gave a cheaper table at equal lines a lookup, and that fitted ungrouped line became the curve to beat.

Its closing section turned from the offset to the room. Every line gets the same room because every line’s count of closed blocks is drawn from the same distribution, and the room is the part of the table worth trading. A group of lines could pool its room as it had pooled its offsets: give each line room for the mean, and give each group of 64 lines a reserve for its lines’ excess, at one standard deviation of the group’s total. The total over 64 lines varies, in proportion, an eighth as much as one line’s count, so a group should need an eighth of the per-line room for the same chance of spilling past its reserve. The prediction was about 3.24 bits a block for about 2.006 lines a lookup, below the fitted line. The named risk was the reserve itself: it is a line of its own, read by every lookup that spills, and a partly empty reserve is paid for.

The arithmetic of the total is right, and the total is not what a reserve has to hold.

Lines at the mean, and a reserve a group

The filter, the keys and the accounting are the earlier essays’: 64-bit blocks whose uneven loads the thresholds repay, 16 bits a key, four-bit threshold values, 524,288 keys in about 124,500 blocks, two filters a seed and two seeds, 100,000 absent queries a filter, and the table’s cost counted as whole lines plus everything outside them. In the pooled table each line holds room for the mean number of closed blocks among its CC blocks, ⌈Cp⌉\lceil Cp \rceil values for this filter’s closed share pp, so a line’s room is about half the time too small. Lines are grouped 64 at a time, and each group has a reserve of value slots. A line’s values beyond its room go first into its group’s reserve, in order, and only when the reserve is full into the shared overflow.

Each line carries where its spills begin in its group’s sequence of spills, in as few bits as address the largest group’s; each group carries, once, where its part of the shared overflow begins. A lookup whose value stayed in its line reads one line. One whose value is in the reserve reads its line and the reserve’s line, or two if the value straddles a boundary. One whose value went past the reserve reads its line, the group array’s line and the overflow’s. The reserve is sized two ways: as proposed, rr standard deviations of the group’s total of closed blocks, and for the spill, the group’s expected spill plus rr standard deviations of it, both computed from the binomial distribution of a line’s closed blocks.

A reserve that is always full

A reserve of one deviation of a group's total holds 52 values, and a group of 64 lines sized for the mean spills about 145: it is full in every group, and 1.7% of lookups on a closed block go past it to the shared overflow; sized for the expected spill it holds 177, is 81% full, and 0.0% go pastFor each reserve size, groups of 64 lines whose room is the mean: the slots a group's reserve holds, the share of all reserve slots that are used (bar), and the share of lookups on a closed block whose value lies past the reserve in the shared overflow. 0.5 σ of the total: 26 slots, 100% full, 2.3% past; 1 σ of the total: 52 slots, 100% full, 1.7% past; 2 σ of the total: 103 slots, 100% full, 0.8% past; 4 σ of the total: 205 slots, 69% full, 0.0% past; spill + 0 σ: 144 slots, 92% full, 0.2% past; spill + 1 σ: 177 slots, 81% full, 0.0% past; spill + 2 σ: 202 slots, 71% full, 0.0% past. A line's expected spill is 2.27 values, its deviation 3.54.0%25%50%75%100%bar: share of the reserve's slots in use · right: lookups past the reserve0.5 σ of the total26 slots2.3%1 σ of the total52 slots1.7%2 σ of the total103 slots0.8%4 σ of the total205 slots0.0%spill + 0 σ144 slots0.2%spill + 1 σ177 slots0.0%spill + 2 σ202 slots0.0%124,488 blocks, groups of 64rows: the reserve's size
Fig. 1 For each reserve size, groups of 64 lines at the mean: slots a reserve holds, the share of slots used, and the share of lookups on a closed block whose value lies past the reserve. Half a deviation of the total: 26 slots, 100% full, 2.3% past. One: 52, 100%, 1.7%. Two: 103, 100%, 0.8%. Four: 205, 69%, 0.02%. The expected spill: 144 slots, 92% full, 0.24% past; plus one deviation of it: 177, 81%, 0.03%; plus two: 202, 71%, 0.01%.

A reserve of one standard deviation of a group’s total holds 52 values, the 64 lines of a group sized for the mean spill about 145, and the reserve is full in every group: 1.7% of lookups on a closed block find their value past it, in the shared overflow, three lines away. The proposed reserve is not too large, the named risk; it is a third of what it must hold.

The proposal reasoned about the group’s total. Sixty-four lines of about 164 blocks each, with about half the blocks closing, hold a total whose standard deviation is 64\sqrt{64} times one line’s, and one line’s is about 6.3 values, so one standard deviation of the total is about 50 values. That is the right spread for the total. But a line with fewer closed blocks than its room cannot lend its empty slots to a line with more, since its slots are inside its own 512 bits. What the reserve has to hold is not the group’s total above its mean but the sum of every line’s own excess, and half the lines exceed the mean. A line’s expected excess over the mean is about 2.3 values, and 64 of them are about 145, with a spread of only about 28. The spills of a group are large and steady, which is the opposite of what the proposal’s arithmetic pictured.

Sized for that, a reserve of 144 slots, the expected spill, is 92% full and sends 0.24% of closed lookups past it; one standard deviation more, 177 slots, is 81% full and sends 0.03%. The partly empty reserve the closing section feared appears exactly where the reserve is large enough to work.

Why a group’s spill is steady

The square root the proposal relied on is real, and it applies to the spill rather than the total. One line’s spill over the mean is zero about half the time and several values the rest: its expected size is 2.27 values and its standard deviation 3.54, so it varies by one and a half times its own mean. Summed over 64 lines, independent because the hash that places the keys is drawn at random from a family, the mean grows 64 times and the deviation eight times, so the group’s spill is 145 values give or take 28: it varies by a fifth of its mean. Pooling makes the spill eight times steadier relative to its size, which is exactly the factor the closing section named. What it does not do is make the spill smaller, and the proposal’s reserve was sized as if it did.

That difference is the whole result. A per-line room has to cover a line’s spill at the line’s own variability; to keep one line in a hundred from spilling, a line needs about two and a half deviations of room over the mean, and every line pays for them. A group reserve has to cover the group’s spill at the group’s variability; to keep one group in a hundred from overflowing, it needs about the expected spill plus two and a half of its own deviations, 215 slots, which spread over 64 lines is 3.4 values a line, against the 15 or so a line would need alone at the same chance. The saving is in the margin, not in the mean, and the mean is most of what a reserve holds.

The measured saving is far smaller than that arithmetic suggests, because the ungrouped line does not keep its lines from spilling either. It sends its spills to an overflow area and pays a second line and an offset for them, so what pooling can save over it is only what a reserve costs less than that overflow, slot for slot and line for line, and that is a few hundredths of a bit a block.

Back on the curve, and under it

At 124,488 blocks, lines sized for the mean with a reserve a group of 64 sized for the group's expected spill sit under the fitted ungrouped line at every room: 3.192 bits a block for 2.0137 lines a lookup where the fitted line costs 3.224, and 3.243 for 2.0078 against 3.263; the reserve sized as proposed, a deviation of the group's total, is always full and costs 3.180 for 2.0231, 0.006 under the lineThe split threshold table at 524,288 keys, two seeds a point: bits a block, as whole lines plus reserves, group offsets and overflow, against lines a lookup. The ungrouped line with its offset fitted to its overflow, room at -1, -0.5, 0, 0.5, 1, 1.5, 2 deviations: -0.5 3.182 at 2.0241, 0 3.215 at 2.0150, 0.5 3.265 at 2.0075, 1 3.337 at 2.0031, 1.5 3.400 at 2.0009, 2 3.478 at 2.0003. Lines at the mean, a reserve of 0.5, 1, 2, 4 deviations of the group's total: 0.5 3.180 at 2.0257, 1 3.180 at 2.0231, 2 3.180 at 2.0183, 4 3.203 at 2.0135. Lines at -0.5, 0, 0.5, 1 deviations with a reserve for the group's expected spill plus one deviation of it: -0.5 3.191 at 2.0261, 0 3.192 at 2.0137, 0.5 3.243 at 2.0078, 1 3.313 at 2.0034.3.203.303.403.5022.012.02lines read a lookuptable bits a blockungrouped, offset fittedpooled, reserve for spillspooled, reserve as proposed124,488 blocks, groups of 64 lineswhole lines; two seeds
Fig. 2 Bits a block against lines a lookup at 124,488 blocks. The fitted ungrouped line: 3.182 at 2.0241 (room half a deviation under the mean), 3.215 at 2.0150 (the mean), 3.265 at 2.0075, 3.337 at 2.0031, 3.400 at 2.0009. Pooled, reserve for the spill plus a deviation, lines at the mean and half and one deviation over: 3.192 at 2.0137, 3.243 at 2.0078, 3.313 at 2.0034. Pooled as proposed: 3.180 at 2.0257, 2.0231 and 2.0183, 3.203 at 2.0135.

With the reserve sized for the spill, the pooled table sits under the fitted ungrouped line at every room measured: 3.192 bits a block for 2.0137 lines a lookup where the line costs 3.224 at the same lines, 3.243 for 2.0078 against 3.263, and 3.313 for 2.0034 against 3.331. The saving is two to three hundredths of a bit a block, about 1% of the table. It is the first layout on this table’s plates to get under the fitted line at equal lines a lookup, since fitting every line to its worst run of values first priced the table by its lines.

The proposed reserve lands on the curve instead. At one deviation of the total it costs 3.180 bits for 2.0231 lines, and the fitted line at 2.0231 lines costs 3.186, six thousandths more. The bits are lower than the prediction’s 3.24, because the reserve is small, and the lines are four times the predicted excess over two, because so many values go past it. The prediction’s point, 3.24 at 2.006, is almost exactly where the spill-sized reserve with lines at half a deviation over the mean sits, 3.243 at 2.0078; it was reachable, by a reserve three and a half times the size it proposed.

Below the mean the pooling stops paying. With lines half a deviation under the mean and a spill-sized reserve, the table costs 3.191 bits for 2.0261 lines, more than the fitted line there; the reserve then holds most of the values and the line is mostly offsets and empty room.

Every reserve at the mean

With every line's room at the mean, growing the reserve moves the table along the ungrouped line's curve rather than under it while the reserve is sized as a deviation of the total — 3.180 at 2.0257, 3.180 at 2.0231, 3.180 at 2.0183, 3.203 at 2.0135 — and steps under it once the reserve holds the expected spill: 3.184 at 2.0151, 3.192 at 2.0137, 3.202 at 2.0139Lines sized for the mean, groups of 64, the reserve at 0.5, 1, 2, 4 deviations of the group's total and at the expected spill plus 0, 1, 2 deviations of it; the fitted ungrouped line beside them. total 0.5: 3.180 at 2.0257, the line there 3.182; total 1: 3.180 at 2.0231, the line there 3.186; total 2: 3.180 at 2.0183, the line there 3.203; total 4: 3.203 at 2.0135, the line there 3.225; spill 0: 3.184 at 2.0151, the line there 3.215; spill 1: 3.192 at 2.0137, the line there 3.224; spill 2: 3.202 at 2.0139, the line there 3.222.3.203.303.403.5022.012.02lines read a lookuptable bits a blockungrouped, offset fittedreserve: deviations of totalreserve: spill + deviationslines at the meangroups of 64
Fig. 3 Lines at the mean, groups of 64, every reserve size. Deviations of the total, half, one, two and four: 3.180 at 2.0257, 2.0231 and 2.0183, and 3.203 at 2.0135. The expected spill plus nought, one and two deviations of it: 3.184 at 2.0151, 3.192 at 2.0137, 3.202 at 2.0139. The fitted line beside them.

Growing the proposed reserve from half a deviation of the total to two leaves the bits at 3.180 a block and only lowers the lines, from 2.0257 to 2.0183; the reserve is full at every one of those sizes, so a larger one simply keeps more of the spill out of the overflow at the same cost a slot. At four deviations of the total, 205 slots, it is larger than the spill needs, 69% full, and the bits rise to 3.203. The spill-sized reserves sit between, and the one at the expected spill alone, 144 slots, is the cheapest point under the curve: 3.184 bits for 2.0151 lines, against the fitted line’s 3.215 at 2.0150.

The plate makes the trade visible. A slot in a full reserve costs four bits and saves a value from the overflow, where it would have cost four bits too plus a third line a lookup; a slot in an empty reserve costs four bits and saves nothing. The cheapest reserve is the one that is nearly full and almost never overflows, and a reserve sized for the expected spill is that one, because the spill of 64 lines is steady enough that its mean almost bounds it.

Group size

The proposed reserve is never the right size at any group: groups of 16 cost 3.176 bits a block for 2.0202 lines a lookup, 0.020 under the ungrouped line at those lines; groups of 64 cost 3.180 bits a block for 2.0231 lines a lookup, 0.006 under the ungrouped line at those lines; groups of 256 cost 3.217 bits a block for 2.0272 lines a lookup, -0.035 under the ungrouped line at those linesLines sized for the mean with a reserve of one deviation of the group's total, at groups of 16, 64, 256 lines: bits a block (bar), lines a lookup, the reserve's slots and how full it is, and the fitted ungrouped line's bits at the same lines a lookup (tick). 16 lines: 3.176 bits at 2.0202, 26 slots 95% full, the line 3.196; 64 lines: 3.180 bits at 2.0231, 52 slots 100% full, the line 3.186; 256 lines: 3.217 bits at 2.0272, 102 slots 82% full, the line 3.182.3.163.183.203.22groups of 162.0202 lines26 slotsgroups of 642.0231 lines52 slotsgroups of 2562.0272 lines102 slotstable bits a block; tick: the ungrouped line at the same linesreserve: one deviation of the total124,488 blocks
Fig. 4 The proposed reserve, one deviation of the total, at groups of 16, 64 and 256 lines. Groups of 16: 26 slots, 95% full, 3.176 bits a block for 2.0202 lines, 0.020 under the fitted line there. Of 64: 52 slots, full, 3.180 for 2.0231, 0.006 under. Of 256: 102 slots, 82% full, 3.217 for 2.0272, 0.035 over.

At groups of 16 lines the proposed reserve comes closest to the spill it must hold and lands 0.020 bits a block under the fitted line; at 64 it is 0.006 under, and at 256 it is 0.035 over. The proposed reserve grows as the square root of the group, while the spill it must hold grows in proportion to the group. At 16 lines the two are close, 26 slots against about 36 values of spill. At 64 the reserve is a third of the spill. At 256 the spill outruns the reserve in every group by hundreds of values, which go to the overflow and cost the lines, while the larger group’s offsets cost the line two more bits.

That is the same arithmetic as the reserve plate seen from the side. A group’s total varies as G\sqrt{G}, its spill as GG, and only the second is what a reserve holds; sized by the first, a reserve fits the spill only at the one group size where the two happen to meet.

Room and spill

The closing section asked whether room, unlike an offset, can be pooled across neighbours, or whether room has to sit in the line its lookups already read. The measurement separates the two halves of a line’s room. The part every line uses, up to the mean, cannot be pooled: it is in the line, and a line’s unused slots cannot lend themselves to a neighbour. The part some lines need and some do not, the spill, can be pooled, and pooling it is what puts the table under the line, because a group’s spill is far steadier than any one line’s.

The worst of more lines priced the line sized for its worst case against the line sized for its usual case, and moved the excess to one overflow area; a bit for whether it closed had made the line’s contents a count of closed blocks in the first place. Each step since has asked how much of the variation between lines a table must pay for in every line. Pooling the spill pays for it once a group, at the group’s mean spill, which is the variation’s own size rather than a margin over it.

What the prediction got right

The closing section predicted that lines at the mean with a group reserve of one standard deviation of the group’s total would cost about 3.24 bits a block for about 2.006 lines a lookup, below the fitted ungrouped line. It costs 3.180 for 2.0231, on the line rather than below it, because its reserve of 52 slots is full in every group and 1.7% of lookups on a closed block go past it. It named the risk that the reserve would be partly empty and paid for; the proposed reserve is never empty, and the reserves that are partly empty are the ones sized to work.

What the prediction rested on, that a group’s total varies an eighth as much in proportion as one line’s, is true and is not the quantity a reserve holds. Sized for the spill, the pooled table goes under the fitted line at every room, by 0.019 to 0.032 bits a block, and reaches the prediction’s own point, 3.24 bits at 2.008 lines. Room can be pooled across neighbours in the part of it that spills.

What the table leaves out

One filter design. The earlier essays’ filter, at one size. A filter with a different closed share or block width changes how much a line spills and how steady a group’s spill is.

The reserve beside the groups. The reserves are packed together, one region for all of them, and a lookup into a reserve is charged the line it lands on. A reserve laid out next to its group’s lines would share their cache lines, which this accounting does not credit.

Two seeds. Every point is two seeds of two filters, as before, and the differences under the line are two to three hundredths of a bit a block. The ordering holds at every room measured, which is the evidence it is not noise.

Still open: a reserve inside the lines

The reserve costs a lookup a second line because it lives outside the group’s lines. But a group of 64 lines at the mean leaves, on average, as many empty slots in its under-filled lines as its over-filled lines spill, about 145 each way, and those empty slots are already paid for. A line could hold not only its own spill’s position but a neighbour’s: when a line is over its room, its extra values could go into the next line of the group with empty slots, chained, so that a spill costs a lookup the neighbouring line rather than a reserve’s.

The measurement that follows lets each line lend its empty slots to the following lines of its group, a value carried forward until a line has room, with a count in each line of how many values it holds for lines before it, and reports bits a block against lines a lookup beside the reserve. The prediction is that nearly every spill finds room within one or two lines, so that a lookup that spills reads its line and the next one, and that with no reserve at all the table costs about 3.12 bits a block for about 2.012 lines a lookup, under the spill-sized reserve by six hundredths. It could fail on runs: lines over their room come in runs, since the closed share drifts along the filter, and a value carried forward past a run of full lines costs a lookup one line for every line it passes. The question is whether the room the lines already have can be shared among them, or only the room a group adds.

What this makes readable

Essays that name this one as a prerequisite.

Named alongside this one

Essays reaching for the same objects. Nobody chose these; they are what the concept index makes visible.

What links here

Every essay whose body links to this one.

The objects this essay names

Each one links to every other essay that touches it.

Bit vectorBlocked filterCache lineDesign parameterPredictionThresholdVariance