When it does not fit

A choice the fences cannot make

At half a bit a key a levelled store's range-filter memory has two good divisions, one for a store whose levels all meet the same queries and one for a store whose newest level meets few. A switch between them on the ratio of the newest level's reach to the largest's was predicted to land within three points of the fitted division on the shuffled store and ten on the others. It holds on the two stores it was shaped on and fails on a third filled two clusters at a time, 15.9 points behind, choosing the worse division at four checkpoints of six. At three quarters of a bit the floored division is within 1.7 points everywhere and the switch's premise is gone. Priced on a sample of queries instead, the same choice between the same two divisions stays within 3.6 points on every store at both budgets.

A levelled store keeps its keys in levels of growing size, each with a range filter, and a range query that a level’s filter rules out costs that level nothing to read. The filters share a budget of bits a key. A division chosen before the queries arrive found the best way to split it by searching every assignment against the store’s own sample of queries, and every essay since has tried to reach that fitted division with a rule a store can apply when it writes a level, from what it knows then.

The rule that has survived is the size rule: each level gets a base number of bits plus a slope times how many factors of four smaller it is than the largest level, the base chosen to spend the budget, and every setting snapped to a grid of nought, half a bit, one, two, three, four, six, eight, twelve and sixteen bits a key. A floor under every level added a floor of half a bit a key and brought it within five points of the fitted division from one bit a key up, on a store filled in shuffled order and on one filled a cluster at a time.

At half a bit a key the two stores pulled apart. A level scaled by the queries it meets found the shuffled store best served by the size rule with no floor and a gentler slope, about three and a half, which leaves its deepest level bare and was 2.2 points behind the fitted division; and the clustered store best served by the floor, which gives every level exactly half a bit and was 9.1 behind. It also found the quantity that tells the two stores apart. A level’s reach is the share of the workload’s queries that can land between its fences — half the share of the key space it spans plus half the share of the stored keys inside it, since half the queries start at a uniform point and half at a stored key. On the shuffled store every level reaches about 91% of queries; on the clustered store the newest level reaches 3%.

Its closing section proposed the obvious composite. Compute the ratio of the smallest level’s reach to the largest’s when a level is written, use the gentle unfloored division when the ratio is a half or more and the floored one below. It predicted, at half a bit and at three quarters, within three points of the fitted division on the shuffled store and within ten on the clustered — and, as the test it was not shaped on, within ten on a third store. It named the way it could fail: a store whose ratio sits near the switch, where a small error in the ratio is a whole division’s difference.

A third store

The third store holds the same sixteen clusters of keys, 2^20 of them, in the same cluster order as the clustered store, but merged two clusters at a time: the store sees a pair of clusters with their keys interleaved, then the next pair. That is an order between the shuffled store, which sees every cluster at once, and the clustered one, which sees one. It is filled into the same levelled store — a buffer of 4,096 keys, each level four times the one above, each level’s filter rebuilt with every write, as the filter rebuilt with every write laid out — and stopped at the same six points of its fill.

Three quarters of a bit is not on the grid, so it has no even split, and the fitted division and every rule still snap each level’s setting to the grid. That makes it a budget at which the floor of half a bit is affordable with a quarter of a bit to spare, which is the one thing it was chosen to be.

What the ratio sees

The reach ratio puts the shuffled store above the switch at every checkpoint and the clustered store below it at every one, as designed — but the store filled two clusters at a time sits on both sides, and at half a bit the division it wants is the one its ratio does not choose at four of six checkpoints; across the three stores the ratio chooses the worse division six times in eighteenThe smallest level's share of queries that can reach it, over the largest level's, at six points of the fill on the three stores; the switch uses no floor, slope 3.5 at a ratio of 0.5 or more and floored, slope 4 below. A filled marker is a checkpoint where no floor, slope 3.5 is the better of the two at half a bit; a hollow one where floored, slope 4 is. shuffled: ⅛ 1.00 (no floor better by 18.1), ¼ 1.00 (no floor better by 14.1), ⅜ 1.00 (no floor better by 30.4), ½ 1.00 (no floor better by 25.1), ¾ 1.00 (no floor better by 34.8), full 1.00 (no floor better by 33.1); two clusters at a time: ⅛ 1.00 (floored better by 4.9), ¼ 0.20 (floored better by 3.3), ⅜ 0.45 (no floor better by 9.5), ½ 0.55 (no floor better by 10.5), ¾ 0.42 (no floor better by 15.7), full 0.04 (no floor better by 9.5); one cluster at a time: ⅛ 0.40 (no floor better by 1.7), ¼ 0.16 (floored better by 16.5), ⅜ 0.44 (floored better by 1.2), ½ 0.09 (floored better by 3.7), ¾ 0.05 (no floor better by 0.5), full 0.04 (no floor better by 9.1).00.2500.5000.7501share of the fillnewest level's reach ÷ largest level's⅛¼⅜½¾fullswitch at 0.5shuffledtwo clusters at a timeone cluster at a timefilled: no floor better · hollow: floored better, at half a bitratio of reach
Fig. 1 The newest level’s reach over the largest level’s through the fill on the three stores, with the switch at a half dashed. A filled marker is a checkpoint where the unfloored division is the better of the two at half a bit; a hollow one where the floored division is.

The ratio separates the two stores it was designed on, cleanly. The shuffled store sits at 1.00 at every checkpoint, since all its levels reach the same queries, and it wants the unfloored division at every one, by 14 to 35 points. The clustered store sits between 0.04 and 0.44, below the switch everywhere, and wants the floored division at three of the six checkpoints.

The store filled two clusters at a time is where the ratio stops being informative. It reads 1.00 at an eighth of the fill, 0.20 at a quarter, 0.45 at three eighths, 0.55 at a half, 0.42 at three quarters and 0.04 full. Half way through the fill its newest level holds a pair of clusters whose fences span 0.31 of the key space and half the store’s keys, so its reach is six times the clustered store’s newest level’s; at the end of the fill its ratio is the clustered store’s, 0.04. And the division it wants follows none of that: floored by 4.9 and 3.3 points at the first two checkpoints, unfloored by 9.5 to 15.7 at the last four.

Across the three stores at half a bit the switch picks the worse division six times in eighteen. Four are on the paired store. The other two are on the clustered store — at the end of the fill, where its fitted division leaves the deepest level bare and the unfloored rule is better by 9.1 points, and at the first checkpoint by 1.7.

The store the switch was not shaped on

On the store filled two clusters at a time, at half a bit, the division with no floor is within 4.1 points of the fitted division at every checkpoint; the switch on the reach ratio chooses the floored one at four checkpoints and falls 15.9 behind at ¾ of the fill, giving every level half a bit where the fitted division gives 12/3/2/0The store filled two clusters at a time, at half a bit a key: the share of avoidable reads avoided through the fill. ⅛: ratio 1.00, fitted 55.3 (3/1/0), no floor 51.2 (4/0.5/0), floored 56.1, switch chose no floor; ¼: ratio 0.20, fitted 63.4 (8/0), no floor 62.8 (6/0), floored 66.1, switch chose floored; ⅜: ratio 0.45, fitted 75.2 (12/2/0), no floor 74.9 (8/2/0), floored 65.4, switch chose floored; ½: ratio 0.55, fitted 78.2 (3/3/1/0), no floor 76.3 (6/4/0.5/0), floored 65.8, switch chose no floor; ¾: ratio 0.42, fitted 83.4 (12/3/2/0), no floor 83.2 (8/4/2/0), floored 67.6, switch chose floored; full: ratio 0.04, fitted 78.9 (12/4/0), no floor 78.9 (12/6/0), floored 69.4, switch chose floored.0.5000.6000.7000.8000.900share of the fillshare of avoidable reads avoided⅛¼⅜½¾fullfitted divisionno floor, slope 3.5floored, slope 4switch on the reach ratiotwo clusters at a time, half a bitbits by level in the description
Fig. 2 The store filled two clusters at a time, at half a bit a key, through the fill: the fitted division, the two divisions and the switch between them. The switch takes the floored division at four checkpoints and loses most at three quarters of the fill.

On the paired store at half a bit the unfloored division is within 4.1 points of the fitted division at every checkpoint, and within 2 at five of the six. The switch takes the floored division at the quarter, three-eighths, three-quarters and full checkpoints because the ratio is below a half there, and at three quarters of the fill it falls 15.9 points behind, giving every level half a bit where the fitted division gives its four levels 12, 3, 2 and nought bits a key, newest first.

That is the failure the proposal named, in a stronger form than it named it. The ratio did not sit near the switch and flicker; at three quarters it read 0.42, comfortably on the floored side, and the store wanted the opposite division by 15.7 points. The ratio is not a noisy measurement of the right quantity. On this store it is a clean measurement of a quantity that does not decide the division.

What the paired store’s fitted divisions have in common with the shuffled store’s is the deepest level left bare: nought at all six checkpoints, as on the shuffled store, where the clustered store’s fitted division gives the deepest level half a bit at four. A level that is mostly old clusters, on a workload half of whose queries are aimed at stored keys, is reached often and ruled out rarely by any filter half a bit a key can buy; the bits do more on the small levels. Whether that holds for a store’s deepest level depends on how its keys and the queries’ keys overlap, and the ratio between the newest level’s reach and the largest’s does not measure that.

Three quarters of a bit

At three quarters of a bit a key the question the switch was built for has gone: the floored division is within 1.7 points of the fitted division at every checkpoint on all three stores, and the division with no floor falls up to 23.5, 34.6, 35.3 points behind on the shuffled, paired and clustered stores — the shuffled store includedGap behind the fitted division at three quarters of a bit a key through the fill, for floored, slope 4 (lower lines) and no floor, slope 3.5 (upper lines), on each store: shuffled: ⅛ floored -0.3, no floor 0.0 (fitted 6/1/0), ¼ floored 0.0, no floor 23.5 (fitted 4/0.5), ⅜ floored 1.7, no floor 12.1 (fitted 16/1/0.5), ½ floored 0.0, no floor 3.5 (fitted 4/4/0.5/0.5), ¾ floored 0.0, no floor 6.3 (fitted 6/3/1/0.5), full floored 0.0, no floor 21.8 (fitted 12/4/0.5); two clusters at a time: ⅛ floored -0.1, no floor 17.9 (fitted 2/1/0.5), ¼ floored 0.0, no floor 34.6 (fitted 4/0.5), ⅜ floored 0.3, no floor 23.6 (fitted 12/1/0.5), ½ floored 0.1, no floor 17.3 (fitted 6/3/0.5/0.5), ¾ floored 0.3, no floor 14.9 (fitted 12/2/1/0.5), full floored 0.0, no floor 20.9 (fitted 12/4/0.5); one cluster at a time: ⅛ floored -0.3, no floor 16.0 (fitted 2/1/0.5), ¼ floored 0.0, no floor 35.3 (fitted 4/0.5), ⅜ floored 0.9, no floor 25.5 (fitted 16/1/0.5), ½ floored 0.2, no floor 19.3 (fitted 8/2/0.5/0.5), ¾ floored 0.3, no floor 16.2 (fitted 12/1/1/0.5), full floored 0.0, no floor 20.9 (fitted 12/1/0.5).00.1000.2000.3000.400share of the fillpoints behind the fitted division⅛¼⅜½¾fullshuffled, no floortwo clusters at a time, no floorone cluster at a time, no floorall three, flooredthree quarters of a bit a keysolid: no floor · dashed: floored
Fig. 3 At three quarters of a bit a key, the gap behind the fitted division through the fill for the floored division (dashed, all three stores near nought) and the unfloored one (solid). The floored division is right on every store, the shuffled one included.

At three quarters of a bit a key the floored division is within 1.7 points of the fitted division at every checkpoint on all three stores. The unfloored division falls up to 23.5 points behind on the shuffled store, 34.6 on the paired and 35.3 on the clustered. The switch, which reads the shuffled store’s ratio of 1.00 and takes the unfloored division there, is 23.5 points behind on the store it was supposed to suit best.

The half-bit disagreement was never a disagreement between stores about how to divide memory. It was a disagreement about what to do when the floor is the whole budget. At half a bit a key the floor of half a bit leaves nothing to divide — every level gets exactly the budget — and the only way to give any level more is to give some level nothing, which the shuffled store’s fitted division does and the floor forbids. At three quarters the floor costs two thirds of the budget and leaves a quarter of a bit a key to move, and every store’s fitted division uses it the same way: half a bit or more on every level, the remainder on the small ones, at seventeen of the eighteen checkpoints. The fitted division at three quarters gives the shuffled store’s deepest level half a bit at five checkpoints of six, which it never did at half a bit.

So the switch’s premise holds only on a narrow band of budgets, the ones at which the floor exhausts the budget or nearly does. The sizes a store passes through found a budget of a bit a key or less was where every rule went wrong; this plate narrows that to the band where a floor cannot be paid for and something else must be done, and at three quarters of a bit it can.

Any threshold

A switch at a half was the proposal’s choice, not a measured one. The next plate moves it.

At half a bit the switch does best with its threshold anywhere from 0.2 to 0.4, not the proposed 0.5: 9.5 points on the store filled two clusters at a time and 9.1 on the clustered store — inside the proposal's ten by half a point, with the threshold chosen on the stores it is scored onThe worst gap over the fill behind the fitted division for the reach-ratio switch at half a bit a key, as the threshold moves from 0.05 to 0.9: shuffled: 0.05 2.2, 0.1 2.2, 0.2 2.2, 0.3 2.2, 0.4 2.2, 0.5 2.2, 0.6 2.2, 0.7 2.2, 0.8 2.2, 0.9 2.2; two clusters at a time: 0.05 9.5, 0.1 9.5, 0.2 9.5, 0.3 9.5, 0.4 9.5, 0.5 15.9, 0.6 15.9, 0.7 15.9, 0.8 15.9, 0.9 15.9; one cluster at a time: 0.05 16.5, 0.1 16.5, 0.2 9.1, 0.3 9.1, 0.4 9.1, 0.5 9.1, 0.6 9.1, 0.7 9.1, 0.8 9.1, 0.9 9.1.00.0500.1000.1500.2000.4000.6000.800reach ratio at which the switch changes divisionworst gap over the fill, pointstwo clusters at a timeone cluster at a timeshuffledhalf a bit a key · dashed: the proposed 0.5points behind the fitted division
Fig. 4 The switch’s worst gap over the fill at half a bit a key on each store, as its threshold moves from 0.05 to 0.9, with the proposed half dashed. The shuffled store does not care; the two clustered stores are best served by a threshold between 0.2 and 0.4.

With the threshold anywhere from 0.2 to 0.4, the switch at half a bit is 2.2 points behind on the shuffled store, 9.5 on the paired store and 9.1 on the clustered. That is inside the proposal’s bounds, by half a point on the paired store. Below 0.2 the clustered store’s quarter checkpoint, whose ratio is 0.16 and which wants the floor by 16.5 points, switches to the unfloored division; above 0.4 the paired store’s three-eighths and three-quarter checkpoints switch to the floor and it loses 15.9.

A threshold chosen after the fact, on the three stores it is then scored on, at six checkpoints each, that clears a bound of ten by half a point, is not a rule that has been tested. It has been fitted. And no threshold does better than 9.5 on the worst store, because the reach ratio orders the checkpoints in a way the right division does not follow: the paired store wants the unfloored division at ratios of 0.04 and 0.42 and the floored one at 0.20; the clustered store wants the floor at 0.16 and 0.44 and the unfloored division at 0.04.

Pricing the two on the queries

The quantity both divisions approximate is the store’s own cost on its queries. One bit a key, divided and the filter each run carries set out what each level’s bits are worth: the queries the level meets, times what a false positive costs there, over the bits its keys take. The fitted division finds the best assignment by pricing every combination of grid settings on a sample of queries — the choosing seed — and charging the winner on a second sample, so that its score is not fitted to its own queries.

A store choosing between two divisions does not need every combination. It can price both on the same sample and take the cheaper, and charge it on the second sample as everything else is charged.

Worst gap behind the fitted division on every store at both budgets: the switch on the reach ratio leaves up to 23.5 points; choosing between the same two divisions by pricing both on the sample of queries the fitted division is searched on leaves at most 3.6The worst gap over the fill, in points of avoidable reads avoided, for each division and each way of choosing between them: shuffled, 0.5: no floor 2.2, floored 34.8, switch on reach 2.2, tried on queries 2.2, better of two 2.2; shuffled, 0.75: no floor 23.5, floored 1.7, switch on reach 23.5, tried on queries 1.7, better of two 1.7; two clusters at a time, 0.5: no floor 4.1, floored 15.9, switch on reach 15.9, tried on queries 1.9, better of two 1.9; two clusters at a time, 0.75: no floor 34.6, floored 0.3, switch on reach 17.9, tried on queries 0.3, better of two 0.3; one cluster at a time, 0.5: no floor 16.5, floored 9.1, switch on reach 9.1, tried on queries 3.6, better of two 3.6; one cluster at a time, 0.75: no floor 35.3, floored 0.9, switch on reach 0.9, tried on queries 0.9, better of two 0.9. "Better of two" picks whichever division is better at each checkpoint after the fact.no floorflooredswitch on reachtried on queriesbetter of twoworst gap over the fill, pointsshuffled, 0.52.234.82.22.22.2shuffled, 0.7523.51.723.51.71.7two clusters at a time, 0.54.115.915.91.91.9two clusters at a time, 0.7534.60.317.90.30.3one cluster at a time, 0.516.59.19.13.63.6one cluster at a time, 0.7535.30.90.90.90.9within three points highlighted; over ten darkpoints behind the fitted division
Fig. 5 The worst gap over the fill behind the fitted division for each division alone, for the switch on the reach ratio, for the choice made by pricing both divisions on the query sample, and for the better of the two chosen after the fact — every store at both budgets.

Chosen on the sample, the same two divisions are within 3.6 points of the fitted division on every store at both budgets: 2.2 on the shuffled store at half a bit and 1.7 at three quarters, 1.9 and 0.3 on the paired store, 3.6 and 0.9 on the clustered. In every row that is the better of the two divisions chosen after the fact, to the tenth of a point. The switch on the reach ratio is 23.5 on the shuffled store at three quarters, 17.9 and 15.9 on the paired store.

The sample gets every checkpoint where the choice matters right. It picks the worse division at one checkpoint in thirty-six: the paired store at a quarter of the fill at half a bit, where the floored division is 3.3 points better on the charging seed and the sample priced the unfloored one cheaper. A sample of queries is a sample, and a result the size of its own noise is the reminder that a choice between two options a few points apart is a choice a second sample might reverse. The choices that matter, ten to thirty-five points apart, no sample measured here gets wrong.

The clustered store, checkpoint by checkpoint

On the store filled one cluster at a time at half a bit, pricing the two divisions on a sample of queries picks the better one at six of six checkpoints and stays within 3.6 points of the fitted division; the switch on the reach ratio falls 9.1 behindThe store filled one cluster at a time at half a bit a key: the gap behind the fitted division through the fill for the switch on the reach ratio and for the choice made by pricing both divisions on the choosing seed of queries. ⅛: reach chose floored (5.3), queries chose no floor (3.6); no floor 3.6, floored 5.3; ¼: reach chose floored (0.0), queries chose floored (0.0); no floor 16.5, floored 0.0; ⅜: reach chose floored (0.0), queries chose floored (0.0); no floor 1.2, floored 0.0; ½: reach chose floored (0.0), queries chose floored (0.0); no floor 3.7, floored 0.0; ¾: reach chose floored (0.0), queries chose floored (0.0); no floor -0.5, floored 0.0; full: reach chose floored (9.1), queries chose no floor (0.0); no floor 0.0, floored 9.1.00.0500.1000.150share of the fillpoints behind the fitted division⅛¼⅜½¾fullswitch on reachtried on queriesone cluster at a time, half a bitpoints behind the fitted division
Fig. 6 The store filled one cluster at a time, at half a bit a key: the gap behind the fitted division through the fill for the switch on the reach ratio and for the choice priced on the query sample. They agree at four checkpoints; at the first and the last the sample chooses the unfloored division and is right.

Even on the store the switch was shaped on, the sample does better. The reach switch gives the clustered store the floored division at all six checkpoints, because its ratio never rises above 0.44, and that costs it 9.1 points at the end of the fill and 5.3 at the first checkpoint. The sample takes the unfloored division at both and is within 3.6 and nought. At the end of the fill the clustered store’s newest level reaches 3% of queries, the smallest reach anywhere, and its fitted division is the shuffled store’s shape — 12, 6 and nought bits a key — because a level of 4,096 keys is cheap enough to protect heavily however rarely it is reached, and protecting it heavily leaves nothing for the deepest level at half a bit. The reach ratio was designed to say protect every level, and at that checkpoint it says it about the one fill state where it is least true.

What the fences know and what they do not

A level’s fences are free: a store knows its first and last keys when it writes it, and one length for the gaps and the clusters used the same kind of knowledge to choose a filter’s prefix length. They tell a store how much of the key space a level covers and how many of its keys lie in that span. What they cannot tell it is how the workload’s queries fall relative to the keys inside the span — whether the key-aimed half land on the level’s own keys, where a filter cannot help, or between them, where it can. That is the quantity the division turns on at half a bit, because at half a bit a key the only question is which level to leave bare, and the answer is the level whose filter would rule out least for its bits.

The size rule’s slope encodes the cheapness of protecting a small level. The reach ratio encodes how often a level is asked. Neither encodes how often a level’s filter would say no to a query that reached it, and two lengths that do the work of eleven showed on the same sixteen clusters that this is the number that moves when the arrival order moves.

The cost of asking the queries

Choosing by the sample is not free, and the reason it is affordable is specific to the choice being between two. The fitted division prices every level at every one of ten grid settings and searches every combination — ten to the fourth for four levels. The two-way choice prices each level at the two settings the two divisions give it and adds them up: at most eight filters built against the sample instead of forty, and two sums instead of ten thousand. A store that keeps a sample of recent queries for any other reason already has what it needs.

What it gives up is the third and better division. In this study the better of the two is within 3.6 points of the fitted division everywhere, so there was little to give up; on a store whose fitted division is neither shape — some level at three bits that both rules snap to two or four — the two-way choice would be bounded by the better of two wrong answers.

What the measurement does not settle

Three stores of one kind. Sixteen clusters, three arrival orders that differ in how many clusters arrive together. A store whose clusters arrive in bursts of varying size, or that receives updates to old clusters, would give the ratio and the sample new cases.

One workload. Half uniform and half aimed at stored keys, a few keys wide. The sample the choice is priced on is drawn from the same workload as the charge; a workload that drifts between choosing and charging would cost the sample and not the fences.

Six checkpoints and two budgets. Every worst gap is the worst of six. The band where the floor exhausts the budget was located at half a bit and shown gone at three quarters; where between them it closes is not measured.

Still open: a level priced on its own sample

The two-way choice works because both divisions are good somewhere and the sample tells them apart. It still divides by the size rule’s shape, with the sample used only to pick between two settings of that shape. A store with a sample of queries could go further at almost no cost: price each level alone at the grid settings either side of what the size rule gives it, and move a step of bits from the level whose filter saves least per bit to the one that saves most, until no move helps — a descent from the size rule rather than a search from nothing.

The measurement that follows starts from the floored division at half a bit, three quarters and one bit a key on all three stores, takes single-step moves between levels while the sample says they help, and charges the result on the second sample. The prediction is that it ends within two points of the fitted division everywhere, in at most four moves, building fewer than a quarter of the filters the full search builds. It could fail at half a bit, where the floored division and the fitted one differ on every level at once, and a descent of single steps can stall at an assignment where no one move helps and two together would. The question is whether the division a store needs is reachable from the rule it already has by moves its own sample can price, or whether at the smallest budgets only a search finds it.

Named alongside this one

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

The objects this essay names

Each one links to every other essay that touches it.

Bloom filterDesign parameterLsm treePer levelPredictionSpace accountingWorkload