What a bound is

The two parts the law was not given

The square-root law moves almost every cut of a seven-part file whenever its band of hot queries moves. A background cut once by keys, with only the part holding the band cut again, was proposed instead: a recut would rewrite a seventh of the file. It does, and it beats the law at every drift speed — 365 transfers a query against 417 at a moderate drift — but it wins with nine parts to the law's seven. Given nine, the law costs 322. Held to seven, the fixed background loses to the law at every speed. What survives the fair comparison is narrower and still useful: six parts by keys, with the band's part cut in four, ties the nine-part law on drift for a quarter of its rewriting. It loses on jumps, because a fixed background waits about three hundred queries to believe the band has left before it moves, and it pays double wherever a background cut runs through the band.

Every cut the law moves found out why a partition recut by the square-root law cannot recut cheaply. A file of four million keys is kept in seven parts, cut so that each part’s share of the keys times its share of the selection queries is the same, and nine queries in ten fall in a band 2% of the ranks wide that moves. When the band moves, the law moves 98% of its cuts, because the parts on either side of the band share out the key space the band leaves, and a cut on the far side of the file has to move for a band moving on the near side. Charging a recut only for the parts it changed saved 2%. Recutting only the three parts around the band cost up to three times as much a query, because the law’s other cuts were then in the wrong places.

That essay’s closing section proposed the opposite of the law’s habit: a background that never moves. Cut the file once into seven parts balanced by keys. Inside whichever part holds the band, keep the band in a small part of its own, cut by the law over that part alone, and leave every other part untouched. A recut would rewrite one background part, a seventh of the file, and only when the band moved within it or out of it. The prediction was that this partition would recut several times as often as the law, for a seventh of the cost each time, and come within 10% of the law’s cost a query on slow drift. It could fail where the band straddles two background parts, since half its queries would then fall in a part that is a seventh of the file and not cut for them.

Seven by keys, and the band cut inside

The setting is the earlier essays’ throughout, a model of the exact selection what a second pass buys began with, priced in blocks. The file holds ranks of 2²² keys in 4,096 pieces of 1,024, the resolution cuts are drawn at. A selection query costs one read of the part it falls in, or two reads for a part larger than half the 8,192 words of memory, the charge what a pass costs when it is a file measured for exact selection. Each stream is 20,000 queries, four streams a setting. Every hundred queries a design prices its current partition against the one it would cut from a density of recent queries decayed with a half-life of 250 queries, and recuts when the saving a query over that half-life pays for the parts the recut rewrites.

The proposed design keeps the background’s cuts fixed at every seventh of the file. Its candidate partition takes the background part carrying the most decayed density, cuts that part into three by the law over its own stretch, and leaves the others whole. If the band has moved into a different part, the recut merges the old part back and splits the new one, and pays for both.

Around a band at the 37th percentile the law spends its parts on the band and leaves the rest in a few large ones; the fixed background keeps its parts the size of a seventh or a sixth of the file wherever the band is, and cuts only the part the band is inThe parts each design writes for a still band 2% wide centred at 37% of the ranks, with each part's transfers for one selection query. the law, 7 parts: 0.0–20.7% costs 1694, 20.7–36.1% costs 1260, 36.1–37.0% costs 80, 37.0–38.0% costs 80, 38.0–58.7% costs 1694, 58.7–79.4% costs 1694, 79.4–100.0% costs 1690. 7 by keys + band in 3 (9 parts): 0.0–14.3% costs 1170, 14.3–28.6% costs 1170, 28.6–36.3% costs 630, 36.3–37.7% costs 116, 37.7–42.8% costs 424, 42.8–57.2% costs 1172, 57.2–71.4% costs 1170, 71.4–85.7% costs 1170, 85.7–100.0% costs 1170. the law, 9 parts: 0.0–17.1% costs 1402, 17.1–34.2% costs 1402, 34.2–36.3% costs 172, 36.3–37.2% costs 68, 37.2–38.0% costs 68, 38.0–50.5% costs 1024, 50.5–67.6% costs 1402, 67.6–84.7% costs 1402, 84.7–100.0% costs 1252. 6 by keys + band in 4 (9 parts): 0.0–16.7% costs 1366, 16.7–33.3% costs 1364, 33.3–36.3% costs 240, 36.3–37.1% costs 72, 37.1–38.0% costs 72, 38.0–50.0% costs 982, 50.0–66.7% costs 1366, 66.7–83.3% costs 1364, 83.3–100.0% costs 1366.the bandthe law, 7 partsthe band's part: 80169412601694169416907 by keys + band in 3 (9 parts)the band's part: 116117011706301172117011701170the law, 9 partsthe band's part: 681402140210241402140212526 by keys + band in 4 (9 parts)the band's part: 72136613649821366136413660%25%50%75%100%rank in the file; numbers are transfers a query in that part2^22 keys, blocks of 1,024a still band 2% wide
Fig. 1 The parts four designs write around a still band at the 37th percentile, with each part’s transfers a query. The law in seven parts gives the band two parts of 80 and leaves the rest in parts of 1,260 to 1,694. Seven by keys gives the band a part of 116 between remainders of 630 and 424, and keeps every other part at 1,170. The law in nine: a band part of 68. Six by keys with the band’s part cut in four: 72.

The proposed design writes nine parts, and the law writes seven. That is in the proposal’s own words, seven background parts and a part of its own for the band, and it went unremarked because the eye is on the rewriting. A part costs a reader nothing to have, and in this cost model more parts means smaller parts and cheaper queries. The law was held to seven because seven parts is what one pass can write with eight blocks of memory, one buffer a part and one for input, as parts cut where the questions are set it up. The fixed background never writes nine in one pass. It writes seven when it is first laid down and three when it splits a part. So it lives within memory, and still ends up with two more parts than the law could ever hold. A file written once for the queries after met the same ceiling from the other side: a pass that distributes keys into parts needs a block of memory for each part it is filling, and the number of parts is the memory in blocks less one. A design that writes its parts a few at a time escapes that ceiling, and the escape is worth exactly what the extra parts are worth.

That difference is the first thing to measure, because it could be the whole result. Four more designs make the comparison fair: the law given nine parts; six background parts with the band’s part cut in four, also nine; five background parts with the band’s part in three, the law’s own seven; and four background parts with the band’s part in four, also seven.

The win is the two extra parts

The fixed background beats the law's seven parts at every drift speed — 365 transfers a query against 417 at 0.1 — and loses to the law given the same nine parts, 322; cut into four instead of three, its band part ties the nine-part law on driftTransfers a query, writes included, against the band's drift speed, four seeds of 20,000 queries each. the law, 7 parts: 0.02 339.1, 0.05 366.1, 0.1 416.8, 0.2 497.2, 0.5 679.6. 7 by keys + band in 3 (9 parts): 0.02 332.9, 0.05 345.3, 0.1 365.1, 0.2 423.9, 0.5 556.2. the law, 9 parts: 0.02 265.3, 0.05 280.4, 0.1 321.7, 0.2 392.6, 0.5 536.8. 6 by keys + band in 4 (9 parts): 0.02 264.2, 0.05 278.3, 0.1 328.9, 0.2 385.9, 0.5 522.2. Five by keys with the band in three, the law's own seven parts: 0.02 414.2, 0.05 440.5, 0.1 449.9, 0.2 525.0, 0.5 703.8.200400600drift of the band, percentiles every 100 queriestransfers a query, writes included0.020.050.10.20.5the law, 7 parts7 by keys + band in 3 (9 parts)the law, 9 parts6 by keys + band in 4 (9 parts)a half-life of 250, changed parts chargeddrifting band, 2% wide
Fig. 2 Transfers a query, writes included, against drift speed. The law in seven parts: 339, 366, 417, 497, 680 at drifts of 0.02, 0.05, 0.1, 0.2 and 0.5. Seven by keys with the band in three: 333, 345, 365, 424, 556. The law in nine parts: 265, 280, 322, 393, 537. Six by keys with the band in four: 264, 278, 329, 386, 522.

The fixed background beats the law’s seven parts at every drift speed, by 2% at the slowest and 18% at the fastest — and the law given the same nine parts beats the fixed background at every speed, by 20% at the slowest and 3% at the fastest. The proposal predicted the background would come within 10% of the law on slow drift. It came in under it, and the reason is not its stillness.

Held to the law’s seven parts, the fixed background loses everywhere. Five parts by keys with the band in three costs 414 transfers a query at the slowest drift against the law’s 339, and 704 at the fastest against 680. Four by keys with the band cut in four does better: 305 at the slowest drift, under the law, and within 3% of it at every other speed but one. At a drift of 0.05 it costs 407 against 366, because on those streams the band spends a fifth of the time across one of its cuts. That is the failure the proposal named, and the next sections measure it.

The fair pair at nine parts is the law against six parts by keys with the band in four, and they are tied. At the five drift speeds the background costs 264, 278, 329, 386 and 522 transfers a query, and the law 265, 280, 322, 393 and 537. Neither is ahead by more than 3%. So the proposal’s central claim survives in a corrected form. A partition can hold its background still and recut only around the band, at no cost a query on drift, if it cuts the band’s part as finely as the law cuts the band. Three pieces were not enough. The band’s own part was 116 transfers where the law’s was 68, and nine queries in ten pay it.

Where each design’s transfers go

At a drift of 0.1 the law spends 25.9 transfers a query on rewrites and the fixed backgrounds 5.6 to 8.9, a recut rewriting 98% of the file against 14%; what the background saves in writes it pays in queries, 359.6 against the nine-part law's 300.5Transfers a query split into the queries themselves and the rewrites, at a drift of 0.1, four seeds. the law, 7 parts: 390.9 for queries, 25.9 for writes, 63.5 recuts each rewriting 98% of the file. 5 by keys + band in 3 (7 parts): 441.0 for queries, 8.9 for writes, 104.0 recuts each rewriting 20% of the file. 7 by keys + band in 3 (9 parts): 359.6 for queries, 5.6 for writes, 87.5 recuts each rewriting 14% of the file. the law, 9 parts: 300.5 for queries, 21.3 for writes, 51.8 recuts each rewriting 98% of the file. 6 by keys + band in 4 (9 parts): 320.0 for queries, 8.9 for writes, 123.8 recuts each rewriting 17% of the file.0100200300400transfers a query: queries (solid), then rewrites (pale)the law, 7 parts63.5 recuts, 98% of the file each416.85 by keys + band in 3 (7 parts)104.0 recuts, 20% of the file each449.97 by keys + band in 3 (9 parts)87.5 recuts, 14% of the file each365.1the law, 9 parts51.8 recuts, 98% of the file each321.76 by keys + band in 4 (9 parts)123.8 recuts, 17% of the file each328.9a half-life of 250drift 0.1
Fig. 3 At a drift of 0.1: transfers a query for the queries and for the rewrites. The law in seven: 390.9 and 25.9, 63.5 recuts each rewriting 98% of the file. Five by keys: 441.0 and 8.9. Seven by keys: 359.6 and 5.6, 87.5 recuts at 14% each. The law in nine: 300.5 and 21.3. Six by keys with the band in four: 320.0 and 8.9, 123.8 recuts at 17% each.

Every recut of seven parts by keys rewrites 14% of the file, against the law’s 98%, and it spends 5.6 transfers a query on rewriting against the law’s 25.9. The proposal’s arithmetic of a seventh a recut was right to the per cent: the share sits between 13% and 15% at every drift speed. The recuts were predicted to be several times as frequent. They are not: 87.5 against the law’s 63.5 at this speed, and at the slowest drift fewer, 19.5 against 35.3. A background recut happens when the band leaves the stretch its split was cut for, which on a slow drift is rarely, and a law recut whenever the decayed density has moved enough to pay for the whole file.

The nine-part pair shows the trade the stillness makes. The law spends 21.3 transfers a query rewriting and 300.5 answering; the background spends 8.9 rewriting and 320.0 answering. What the background saves by not moving its far cuts, it gives back on queries, because the far cuts are not where the law would put them. Its background parts are a sixth of the file each, 1,366 transfers a stray query, wherever the band is. The law’s are cut around the band’s position, a different size on each side of it. At this speed the two exchanges come out 2% in the law’s favour. At the fastest drift, rewriting is a larger share of the law’s cost and the background is 3% ahead; at the two slowest the designs are within a per cent of each other.

When a background cut runs through the band

On a band that stays put, six parts by keys with the band's part cut in four cost 275 transfers a query on average against the nine-part law's 282 — except where a background cut runs through the band, where they cost up to 785Transfers a query for a still band 2% wide centred at each of 49 ranks from 2% to 98%, partitions fitted once, four seeds. Background cuts at 17%, 33%, 50%, 67%, 83%. the law, 9 parts: 2% 263, 4% 262, 6% 271, 8% 270, 10% 270, 12% 278, 14% 281, 16% 281, 18% 285, 20% 290, 22% 298, 24% 305, 26% 285, 28% 295, 30% 263, 32% 261, 34% 270, 36% 287, 38% 280, 40% 291, 42% 293, 44% 296, 46% 284, 48% 284, 50% 287, 52% 297, 54% 265, 56% 269, 58% 280, 60% 283, 62% 305, 64% 284, 66% 280, 68% 284, 70% 282, 72% 281, 74% 288, 76% 266, 78% 263, 80% 255, 82% 263, 84% 264, 86% 270, 88% 278, 90% 294, 92% 299, 94% 305, 96% 308, 98% 309. 6 by keys + band in 4 (9 parts): 2% 223, 4% 244, 6% 253, 8% 250, 10% 256, 12% 260, 14% 266, 16% 437, 18% 219, 20% 242, 22% 247, 24% 256, 26% 262, 28% 258, 30% 266, 32% 234, 34% 389, 36% 234, 38% 250, 40% 254, 42% 265, 44% 256, 46% 264, 48% 241, 50% 785, 52% 230, 54% 257, 56% 254, 58% 257, 60% 256, 62% 263, 64% 275, 66% 431, 68% 215, 70% 246, 72% 250, 74% 255, 76% 254, 78% 249, 80% 261, 82% 253, 84% 391, 86% 234, 88% 246, 90% 250, 92% 266, 94% 261, 96% 269, 98% 254.0200400600800where the still band is centred, as a rank in the filetransfers a query0%25%50%75%100%the law, 9 parts6 by keys + band in 4 (9 parts)grey verticals: the background's cutsa still band, fitted once
Fig. 4 Transfers a query for a still band at each centre from 2% to 98% of the ranks, fitted once. The law in nine parts: 255 to 309, 282 on average. Six by keys with the band in four: 215 to 275 at every centre clear of a background cut, and 389 to 785 at the five centres where a cut runs through the band (16%, 34%, 50%, 66% and 84%); 275 on average.

On a band that stays put, six parts by keys with the band in four cost 275 transfers a query on average against the nine-part law’s 282 — and at the five places where a background cut runs through the band they cost up to 785, nearly three times the law. The straddle the proposal feared is real, and on a still band it is sharp. When the band is centred on a cut, half its queries fall in one background part and half in the next. The design splits only the part with more of the density, so the other half of the band is answered from a whole background part of 1,366 transfers.

Away from the cuts the fixed background is cheaper than the law at all but two of the 44 centres, by a median of about thirty transfers a query. That says something about the law, not about stillness. The square-root rule balances the product of key share and query share; it is not the minimum of a cost model that charges a part one read below half the memory and two above it. A background cut by keys, with the band’s part split finely, happens to sit closer to that minimum when nothing straddles. The figure is what the earlier pages assumed when they called the law’s partition the floor. It is a good partition, and not the best one.

One drifting stream

On one stream drifting at 0.1, six parts by keys with the band in four run a little under the nine-part law until the band reaches a background cut; for the 4 blocks it straddles the cut it costs 544 transfers a query against 270 elsewhereTransfers a query in each block of 500 queries on one seed drifting at 0.1, blocks 2 to 40. The band straddles a background cut in blocks 26, 27, 28, 29. the law, 9 parts: 235, 284, 308, 339, 293, 291, 273, 244, 212, 266, 263, 278, 294, 289, 236, 250, 238, 291, 215, 226, 276, 293, 345, 263, 283, 289, 329, 289, 316, 301, 313, 288, 354, 303, 279, 287, 289, 275, 288. 6 by keys + band in 4 (9 parts): 275, 252, 282, 327, 311, 316, 273, 255, 259, 280, 300, 294, 293, 295, 279, 274, 273, 265, 246, 227, 221, 239, 216, 225, 493, 741, 680, 264, 231, 259, 272, 250, 319, 290, 281, 261, 280, 278, 269.0200400600800102030queries, in blocks of 500 (the first block, before the fit, is left out)transfers a query in the blockthe law, 9 parts6 by keys + band in 4 (9 parts)shaded: the band straddles a background cutone seed, drift 0.1
Fig. 5 Transfers a query in each block of 500 queries on one stream drifting at 0.1, for the law in nine parts and six by keys with the band in four. Clear of the background’s cuts the background averages 270 and the law 280. In the four blocks where the band straddles a cut, the background averages 544.

On one stream drifting at 0.1, the fixed background runs ten transfers a query under the law for thirty-five blocks, and then spends four blocks across a background cut at twice the law’s cost. Those four blocks are a tenth of the stream and nearly erase the background’s lead: over the whole stream it costs 299 against the law’s 282, on this seed. Averaged over four seeds and five speeds the two designs tie, and the averaging is hiding this shape: a design that is a little better most of the time and much worse for short stretches that arrive whenever the band crosses one of five fixed lines.

A partition that moved its background a little near the band would avoid the straddle. That is a step back toward the law, whose every cut moves, and every cut the law moves measured where that ends: holding small moves back kept a quarter of the file still and cost more a query.

Jumps

When the band jumps, the law given nine parts beats both fixed backgrounds at every rate — 270 transfers a query against 302 and 367 at a jump every 5,000 queries — because the law follows a jump within a hundred and fifty queries and a fixed background waits about twice as long before it moves its splitTransfers a query, writes included, against the mean number of queries between jumps of the band, four seeds. the law, 7 parts: 1000 518.4, 2500 421.0, 5000 340.7, 10000 315.6. 7 by keys + band in 3 (9 parts): 1000 489.3, 2500 433.2, 5000 366.6, 10000 344.5. the law, 9 parts: 1000 400.1, 2500 325.8, 5000 270.2, 10000 257.0. 6 by keys + band in 4 (9 parts): 1000 465.3, 2500 364.9, 5000 301.6, 10000 282.9.200300400500queries between jumps of the band, on averagetransfers a query, writes included1,0002,5005,00010,0007 by keys + band in 3 (9 parts)the law, 7 parts6 by keys + band in 4 (9 parts)the law, 9 partsa half-life of 250, changed parts chargeda band that jumps
Fig. 6 Transfers a query, writes included, against the mean number of queries between jumps of the band. The law in nine parts: 400, 326, 270, 257 at jumps every 1,000, 2,500, 5,000 and 10,000 queries. Six by keys with the band in four: 465, 365, 302, 283. Seven by keys with the band in three: 489, 433, 367, 345. The law in seven: 518, 421, 341, 316.

When the band jumps instead of drifting, the nine-part law beats the six-part background at every rate, by 10% to 16%. A recut the law decides found the law at its best on jumps, beating every fixed recut interval, and against a fixed background it keeps that advantage. The proposal’s seven parts by keys does worse still, losing even to the law in seven parts once jumps come every 2,500 queries or less often.

Straddling does not explain this. A jump lands at a uniformly chosen rank, and the band then straddles a background cut in only 1% to 9% of the blocks. Something else is costing the background on every jump.

Three hundred queries to believe the band has moved

After a jump the nine-part law re-shapes its parts within a hundred and fifty queries; the fixed background goes on paying for a whole background part, over a thousand transfers a query, until the decayed density says the band has left its old part — about 300 queries — and is cheaper than the law from then on, 235 against 266Transfers a query in each stretch of 50 queries after a jump of the band, averaged over the 19 jumps in four seeds at a jump every 2,500 queries that were followed by 1,000 queries without another. the law, 9 parts: 50 1,095, 100 685, 150 429, 200 405, 250 360, 300 369, 350 349, 400 325, 450 310, 500 336, 550 319, 600 313, 650 301, 700 254, 750 262, 800 256, 850 254, 900 254, 950 239, 1000 210. 6 by keys + band in 4 (9 parts): 50 1,249, 100 1,190, 150 1,130, 200 1,104, 250 1,045, 300 626, 350 257, 400 240, 450 254, 500 266, 550 252, 600 256, 650 255, 700 224, 750 239, 800 238, 850 240, 900 225, 950 221, 1000 196.02505007501,0001,250queries since the band jumpedtransfers a query1002505007501,000the law, 9 parts6 by keys + band in 4 (9 parts)a half-life of 250a jump every 2,500 queries
Fig. 7 Transfers a query in each stretch of 50 queries after a jump, averaged over 19 jumps that were followed by a thousand queries without another, at a jump every 2,500 queries. The law in nine: 1,095 in the first fifty, 429 by 150, between 250 and 370 from 250 on. Six by keys with the band in four: 1,249 in the first fifty, still 1,045 at 250, 257 by 350, and 235 on average from 550 to 1,000 against the law’s 266.

After a jump, the nine-part law has re-shaped its partition within a hundred and fifty queries; the fixed background goes on answering the band from a whole background part, over a thousand transfers a query, for about three hundred. Once it moves, it is cheaper than the law, 235 transfers a query against 266 over the rest of the thousand. But at a jump every 2,500 queries, three hundred queries at four times the settled cost is a large share of the total.

The delay is in how the background chooses the part to split. It splits the part carrying the most decayed density, and after a jump the old part keeps the majority until a half-life of new queries has outweighed it. The arithmetic is short. With a half-life of 250 queries, tt queries after a jump the old band’s queries carry a weight of 2−t/2502^{-t/250} of the density’s total and the new band’s carry the rest, so the two are equal at exactly t=250t = 250. The density is read every hundred queries, so the new part first leads at a reading between 250 and 350 queries after the jump, and that is where the plate’s background drops. Only then does the split move. The half-life was chosen by a recut the law decides to keep the law within 7% of the best fixed interval on drift, and nothing about that choice was meant to set how quickly a single split changes hands. The law does not choose a part. It cuts the whole file from the mixed density, giving parts to the old band and the new one at once, and the new band gets a part of its own as soon as its queries pay for a rewrite. A design that splits one part can follow one band, and it follows the one that has been there longer.

What the counts depend on

A cost model, not a run of selection. Each query is charged by its part’s size alone, the charge the earlier pages checked against exact selection at every part size used; no selection was run here. The step in that charge at half the memory is why more parts matter so much and why the law is not this model’s minimum.

Two more parts are free here and may not be elsewhere. A reader of the file pays nothing for holding nine parts rather than seven. A system that keeps each part’s metadata, or opens a file a part, would charge for them, and then the comparison at seven parts is the one that counts.

One band, four seeds. Every stream has one band 2% wide carrying 90% of its queries. A workload with two bands would ask the fixed background to split two parts, which it does not do.

One way of choosing the band’s part. The background splits the part with the most decayed density. Choosing instead by the saving a split would make, the rule the law uses for its whole partition, would change how quickly it follows a jump; the section after this one proposes exactly that and it was not run here.

Still open: the split that follows a jump at once

The fixed background ties the nine-part law on drift and loses to it on jumps for one reason that can be named: it waits about three hundred queries, roughly one half-life, before it believes the band has moved to another part. Its rule asks which background part holds the most decayed density, and a majority is slow to change hands. The question could instead be whether a part has gathered enough recent density to pay for splitting it, asked of every part, and answered yes for the new part while the old one is still split.

The measurement that follows lets the background hold two split parts at once, the old band’s and the new one’s, at the same total of nine parts, by cutting each split part into fewer pieces while two are split. It recuts when a whole part’s density would pay for a split under the same rule the law uses, and merges a split part back when its density no longer pays for keeping it split. It runs on every jump rate and every drift speed. The prediction is that the cost after a jump falls to the law’s within a hundred and fifty queries, so that on jumps the background comes within 5% of the nine-part law, and that on drift it changes nothing, since a drifting band rarely needs two split parts. It could fail on the pieces. Two split parts in nine leave each band fewer pieces, and the band’s own part was the first thing this essay found too coarse at three. The question is whether a background can follow a jump as quickly as the law without giving back what holding still saved, or whether following quickly is exactly the law’s habit of moving every cut, under a different name.

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.

Block transferExternal-memoryHonest limitPartitionPredictionSelectionTrade offWorkload