What the libraries do

The number that would choose a cap

A depth histogram is one linear pass — 3.16 operations a character over thirty-two thousand of them — and it says the whole text sits at a mean depth of 3.98 with a worst of ten. Nobody prints it, and every choice of cap in this collection was made without it.

A depth cap is a parameter, and the ladder that introduced it swept it and drew a curve. What no essay in that ladder printed, and what every reader deciding a value would want, is a single histogram of the text’s own depths.

It is one linear pass over the parse the parse in one pass of the text builds. It costs 3.16 operations a character, which over thirty-two thousand characters is a hundred thousand operations and about a fiftieth of a second.

How deep the copying goes, over the whole textEvery position of a 32,768-character collection, by how many generations of copying separate it from a literal. The deepest is 10 and the mean is 3.98, and reading a character at depth d means following d phrases to produce it. This is the measurement that would choose a cap — a cap below the mean will cost phrases everywhere and a cap above the worst costs nothing at all — and it is one linear pass over the parse, 3.16 operations a character, which is why nobody prints it and everybody should.depth 0190.1%depth 19642.9%depth 24,92915.0%depth 37,00921.4%depth 48,47325.9%depth 56,24119.0%depth 63,31010.1%depth 71,2503.8%depth 84221.3%depth 91240.4%depth 10270.1%positions32,768 characters · 1172 phrasesmean 3.98
Fig. 1 Every position of a thirty-two-thousand-character collection, by how many generations of copying separate it from a literal.

What the histogram says

Over sixteen copies of a two-thousand-character text: eleven distinct depths, a worst of ten, a mean of 3.98.

Read against the sweep, that settles the parameter immediately. A cap of twelve or more changes nothing at all, because nothing is deeper than ten. A cap of four sits at the mean, so it will bite on roughly half the positions. A cap of one leaves only literals and things copied from literals, which is why it costs 86% of the text in phrases.

Nothing about that reading needs the sweep. The sweep says what each cap costs; the histogram says which caps are live.

Reading the shape rather than the summary

The mean and the worst are the two numbers usually quoted, and neither is the useful one.

What decides a cap’s cost is the share of positions above it, because those are exactly the positions whose phrases have to be shortened or replaced. At a cap of six, the share above is a few per cent and the parse grows by a third; at a cap of four it is about a quarter and the parse grows by a factor of 2.6.

That relationship is not linear and it is not a curve anybody publishes, because it is a property of one text. What it does mean is that the tail of the histogram is the part to read: a text whose depths pile up at three and trail off to ten behaves quite differently from one spread evenly over the same range, even with the same mean.

How deep the copying goes, over the whole textEvery position of a 24,576-character collection, by how many generations of copying separate it from a literal. The deepest is 10 and the mean is 3.68, and reading a character at depth d means following d phrases to produce it. This is the measurement that would choose a cap — a cap below the mean will cost phrases everywhere and a cap above the worst costs nothing at all — and it is one linear pass over the parse, 3.15 operations a character, which is why nobody prints it and everybody should.depth 0190.1%depth 19623.9%depth 24,62818.8%depth 36,26325.5%depth 46,19625.2%depth 53,67715.0%depth 61,8577.6%depth 76982.8%depth 82080.8%depth 9530.2%depth 10150.1%positions24,576 characters · 941 phrasesmean 3.68
Fig. 2 A third collection — twenty-four shorter copies — whose depth histogram has a longer tail. The mean is similar and the caps that bind are not.

Why the two are different questions

A sweep answers “what does this dial do”. A histogram answers “what is this text like”.

The distinction matters because the sweep’s answer is expensive and collection-specific, and the histogram’s is cheap and transfers. Sweeping ten caps means building ten parses; the histogram is computed from the one parse a phrase index needs anyway.

And the sweep’s shape depends on the histogram. A text whose depths run to twenty-two — which is what the ladder’s own collection produced — has a wide band of caps that do something, and a text whose depths stop at ten has a narrow one. Two sweeps of the same shape at different scales are two histograms.

Where the positions sit, with a cap of 8 and withoutHow many of the 2,048 positions cost each number of phrase follows. Without a cap the distribution runs to 13 with a mean of 5.45; with a cap of 8 it stops there and the mass moves down, at a mean of 3.63. The tail is what the cap removes and the tail is small — which is the argument for the cap and against it at once, since a small tail is cheap to remove and was cheap to carry.024681012positionsphrases followed to produce the characterno capcap 8a text that repeats itself · 2,048 charactersmean 5.45 to 3.63
Fig. 3 The ladder’s own collection, whose depths run to twenty-two. The same sweep over this text has a wider live band, for a reason a histogram makes obvious and a curve does not.

What one linear pass means

The histogram is computed by walking the finished parse and assigning each position a depth: zero for a literal, and one more than its source’s for a copied character.

That is one pass over the phrases and one arithmetic operation per character. The parse itself is the expensive part, at about three operations a character — and the parse was needed regardless, because a depth is a property of a parse and there is nothing to measure before one exists.

So the marginal cost of the histogram is close to zero: it is the parse’s own bookkeeping, kept rather than discarded.

A measurement that is a by-product of work already being done should be reported. That is a weak-sounding rule and it is the one this essay is about, because the alternative — recomputing it later, or not having it — is what produces a parameter chosen from a curve.

Per character, which is where the difference is a shapeThe same two columns divided by the length of the text. The automaton's work is 3.24 operations a character at 512 and 3.10 at 8,192 — flat, which is what amortised constant means when it is measured rather than proved. The comparisons go from 15 a character to 162, a straight line on these axes with a slope of one. That line is why every measurement about a depth cap in this collection was taken on a few thousand characters. Both axes are logarithmic.1,00010100charactersoperations a charactercomparisonsautomatonrepetitive · 8 copies3.10 a character
Fig. 4 The pass the histogram rides on, per character. Flat at about three, which is why the histogram over a large collection is affordable at all.

What a cap is actually buying

It is worth restating, because the histogram changes what the answer looks like.

Extracting a character at depth d costs d phrase follows. The free parse’s mean depth is 3.98 and its worst is ten, so the typical extraction is already four follows and the cap is buying insurance against the tail.

That reframes the dial. It is not a performance knob — capping at eight moves the mean by very little and costs 6% of the phrases — it is a guarantee, and its price is what a guarantee costs.

A reader who cares about average extraction cost should not be capping at all. A reader who has a bound to meet should cap at their bound and read the price off the sweep. Those are different people and the histogram is what tells them which they are.

The one thing a cap does move on average

There is a second-order effect worth recording, since the argument above says the mean barely moves.

Capping does not only truncate the tail: it changes which sources are chosen everywhere, because a phrase that would have copied from a deep region copies from a shallower one instead. So the whole distribution shifts down a little, not just its top.

Measured at a cap of eight over the thirty-two-thousand-character collection, the mean falls from 3.98 to about 3.4 — a sixth — for 6% more phrases. That is a genuine improvement in average extraction cost and it is nowhere near the size of the guarantee it comes with, which is what makes “insurance” the right word.

A parameter chosen from a curve

This collection has an essay about exactly this failure in another field. The threshold somebody chose is about a sort’s cutoff — the size below which a library switches to insertion sort — and its finding is that the published value is a number from a machine nobody has any more, carried forward because nobody re-measured.

A cap chosen by looking at where a sweep’s curve turns is the same shape of decision, and the formula everybody sizes filters with records a third instance of it. The curve’s knee is at four to eight on the collections measured here, and a reader taking eight from that has taken a number about these collections.

The histogram is the thing that transfers. “Cap at the worst acceptable extraction cost, and here is what this text’s depths actually are” is advice; “cap at eight” is a number from somebody else’s data.

It is also worth noticing that a cap is one of three input-dependent parameters this collection has now measured this way. The sampling rate of a compressed index trades locates against bits by a factor of thirty; the block length of a compressed bit vector has an interior optimum; and a depth cap trades phrases against a bound on extraction.

In all three, the sweep is the plate everybody draws and the data’s own distribution is the plate nobody does. A sampling that costs more than the array is the sharpest instance: a sampling rate chosen from a curve rather than from the query mix produces a structure whose samples outweigh what they index.

What the ladder should have printed

The ladder’s essays each drew a sweep, and the sweep is the right plate for the argument each was making — the trade is monotone, the tightest cap brings back the linear term, the cost is a property of the text.

What none of them drew is the histogram of the collection the sweep was taken on. That is the plate a reader needs in order to know whether the sweep’s shape will hold for them, and it is the cheapest plate in the strand.

A parameter’s plate should show the data as well as the dial. This collection’s convention since the grid strand has been that a cap, a threshold or any input-dependent parameter is drawn as a curve with the parameter along it, and the essay names the measurement that would choose a value. The second half of that convention is what this essay is: the measurement, named and now drawn.

The cap, swept over 65,536 charactersThe same sweep the cap strand published, at 32x the size — which is what the linear construction buys. The free parse is 2,179 phrases; a cap of 24 costs 1.00x of that and a cap of 1 costs 26x, which is 86.2% of the text — so the term proportional to the text that the whole family exists to remove has come back. The shape holds at this size: the earlier measurement, on a text a thirtieth as long, reported the same collapse at the same caps. Both axes are logarithmic.11010⁴cap on the depthphrasesno capcap 165,536 characters · 16 copies26x at cap 1
Fig. 5 The dial. Read alone it invites a reader to pick the knee; read beside the histogram it says which caps are live for this text.

What it costs to have been without it

It is worth being fair to the ladder here, because “nobody printed the histogram” reads as a criticism and the ladder’s essays are not wrong.

Every conclusion in that ladder is about a dial, and a dial’s behaviour is what a sweep shows. That a tighter cap costs more phrases, that a cap of one brings back the term proportional to the text, that the same cap costs two texts different amounts — all of those are statements about the parameter and all are correctly supported.

What the missing histogram cost is transferability. A reader of those essays learns what a cap does and cannot tell whether their own text’s depths reach the caps being discussed. That is not an error in the essays; it is a gap in what they equip a reader to do, and it is the gap this one fills.

What a quadratic construction was setting is the other half of the same repair: the ladder’s sizes were chosen by its construction’s cost, and its plates were chosen by what its construction could afford to compute.

What the two collections say together

Two histograms have been measured in this strand, on collections built the same way with different parameters.

Sixteen copies of a two-thousand-character base: depths to ten, mean 3.98. Eight copies of a two-hundred-and-fifty-six-character base: depths to twenty-two.

The second is the smaller collection and has the deeper chains, which is the finding the cap that binds on one text and not another records in a different form: depth measures generations of copying, and a collection of many short copies produces more generations than one of few long ones.

So the parameter that decides a text’s depth profile is not its size and not its repetitiveness. It is how the repetition is arranged — and no summary statistic in this collection captures that. Not the run count, not the phrase count, not the entropy at any order.

Why nobody prints it

It is worth asking, because the answer is not carelessness.

A depth histogram is not a property of a text. It is a property of a text and a parse of it, and the parse is the expensive object. Before the parse is linear, computing a histogram over anything larger than a few thousand characters is the same two hours the sweep costs — so the measurement that would say which caps are live is exactly as expensive as trying every cap.

That is a real reason and it is now gone. At three operations a character the histogram is available over a collection of any size a reader has, and it is available before deciding anything.

A cheap measurement that used to be expensive is a habit that has to be rebuilt. The instrument changed and the practice has not caught up, which is the shape of most of what this collection files under practice.

One construction follows the text and the other follows its squareThe same parse, built two ways, over a collection growing from 512 to 8,192 characters. The quadratic construction compares characters: 7,906 at the small end and 1,324,336 at the large, which is 168x for 16x of text. The automaton follows transitions and walks suffix links: 1,659 to 25,420, which is 15x. The two units are different acts and the ratio between them is not a speed-up; what the plate shows is that one grows with the text and the other with its square. Both produced identical parses, phrase for phrase, at every size. Both axes are logarithmic.1,00010⁴10⁵10⁶charactersoperationscharacter comparisonstransitions and linksrepetitive · 8 copies346 phrases at 8,192
Fig. 6 The change that made it cheap. One line is why the measurement was not taken and the other is why it can be now.

What a reader with a real collection should do

Three steps, and the first two are nearly free.

Parse it and keep the depths. The parse is what a phrase index needs anyway, and the depths are its own bookkeeping. Over a million characters that is about three million operations.

Read the histogram’s tail. The worst depth is the cap above which nothing happens; the share above any candidate cap is what that cap will cost in shortened phrases, approximately and before any second parse.

Then settle whether there is a bound to meet. If extraction cost is a guarantee in somebody’s requirements, cap at it and pay. If it is an average, do not cap: the mean is already four and capping at eight moves it to three and a half for six per cent more phrases.

None of that requires a sweep, and none of it requires the ten parses a sweep costs. The sweep is a plate for an essay; the histogram is an instrument for a decision.

The frontier a ceiling on the chain traces outEach point is one cap, on a collection of 16 copies of 512 characters of English-like. Left is a cheap character and up is a large structure, so the curve runs from the cap of one — depth 1 everywhere, 514,570 bits, a phrase count 47x the unbounded parse's — to no cap at all, at 8,635 bits and a worst chain of 16. Nothing on this curve dominates anything else on it, which is what makes it a frontier and not a ranking. Both axes are logarithmic.11010⁴10⁵worst copy chain, phrases followedbits124816no capcap on each pointEnglish-like · 16 copies of 512z 157 to 7,351
Fig. 7 The trade a reader is deciding about, as the ladder drew it. Which point on it they want is a question about their requirements and their text, and only the second of those is measurable here.

What is checked

The histogram is one pass, asserted as an operations-per-character figure below twelve — so that a change making it quadratic would fail here rather than quietly making this essay’s argument false.

It has more than three distinct depths, which is the check that it is measuring something rather than reporting a degenerate parse.

And the depths themselves are computed from the finished parse rather than from the construction that produced it, for the reason the whole cap ladder insists on: a construction that both enforces a bound and reports whether it holds is a check of nothing.

How deep the copying goes, over the whole textEvery position of a 32,768-character collection, by how many generations of copying separate it from a literal. The deepest is 14 and the mean is 4.21, and reading a character at depth d means following d phrases to produce it. This is the measurement that would choose a cap — a cap below the mean will cost phrases everywhere and a cap above the worst costs nothing at all — and it is one linear pass over the parse, 3.17 operations a character, which is why nobody prints it and everybody should.depth 0190.1%depth 19953.0%depth 24,81714.7%depth 36,87921.0%depth 47,83923.9%depth 55,47316.7%depth 63,1639.7%depth 71,6124.9%depth 89062.8%depth 95031.5%depth 103251.0%depth 111680.5%depth 12500.2%depth 13100.0%depth 1490.0%positions32,768 characters · 1104 phrasesmean 4.21
Fig. 8 The same histogram on a collection of eight longer copies. Fewer generations, shallower distribution, and a different set of live caps.

The histogram is one suffix sum from being the instrument

The plate this essay argues for is a histogram, and the quantity it argues is the useful one is the share of positions above a candidate cap. Those are not the same plate, and the second is one suffix sum from the first.

A histogram gives the mass at each depth. The decision needs the mass strictly above each depth, which is the histogram summed from the top down — one pass over eleven numbers. The result is a curve falling monotonically from one to zero, and reading a cap off it is reading a quantile: cap where the tail is as thin as the phrase premium a reader is willing to pay.

That is a better instrument than the histogram for two reasons, and the second is the one that decides how the plate should be drawn.

It is the quantity the cost tracks. The essay’s own numbers say a cap of six leaves a few per cent above it and costs a third more phrases; a cap of four leaves about a quarter above it and costs 2.6 times. Both readings are of the tail rather than of the mode, and a histogram makes a reader do the summing by eye — which is exactly the operation an eye is worst at, because the tail is where the bars are shortest.

And it is comparable across texts. This strand has two collections whose depths reach ten and twenty-two, and their histograms cannot be put on one frame usefully: the horizontal axes differ by a factor of two and the vertical scales are counts of different totals. Their tail curves can. Both run from one to zero, both are read as quantiles, and putting them together shows the thing the essay says and the histograms do not — that similar means sit above very different live bands, because the same quantile lands at a different depth.

That last point is the whole argument for the form. Two texts with a mean of about four and worst depths of ten and twenty-two have the same summary statistic and different answers, and a curve of “share above dd” against dd separates them at a glance while the means do not. It is expected is not average’s standing complaint about a mean, met with the specific replacement rather than a warning — the tail curve is the whole distribution, and the cap is a point on it.

It also connects this essay’s recommendation to the one the practice field eventually arrives at. The cap that would ship sets the cap where the mass above it is a few per cent, and finds nine to twelve across four real collections whose tight-cap costs differ by a factor of seven. That is the quantile reading, applied to real text, and its stability across those four is the evidence that the quantile is what transfers where the depth is not.

So the convention this essay asks for has a second half. Draw the histogram, and draw its tail. The first says what the text is like; the second is the plate a reader points at when choosing a number, and it costs one suffix sum over a dozen integers on top of a measurement that was already free.

The general habit

There is a rule hiding in this that is worth stating on its own, because it applies well beyond depth caps.

Every input-dependent parameter has a distribution behind it, and the distribution is usually cheaper to measure than the parameter is to sweep.

A sort’s cutoff has a distribution of subproblem sizes behind it. A hash table’s load factor has a distribution of probe lengths. A sketch’s width has a distribution of item frequencies — and the items that survive k counters is the essay where measuring that distribution turned out to decide a structure’s whole behaviour.

In each case the sweep is the plate that gets drawn, because a sweep looks like an experiment and a histogram looks like a description. The sweep is the more expensive of the two and the less useful to a reader with their own data.

How deep the copying goes, over the whole textEvery position of a 32,768-character collection, by how many generations of copying separate it from a literal. The deepest is 10 and the mean is 3.98, and reading a character at depth d means following d phrases to produce it. This is the measurement that would choose a cap — a cap below the mean will cost phrases everywhere and a cap above the worst costs nothing at all — and it is one linear pass over the parse, 3.16 operations a character, which is why nobody prints it and everybody should.depth 0190.1%depth 19642.9%depth 24,92915.0%depth 37,00921.4%depth 48,47325.9%depth 56,24119.0%depth 63,31010.1%depth 71,2503.8%depth 84221.3%depth 91240.4%depth 10270.1%positions32,768 characters · 1172 phrasesmean 3.98
Fig. 9 The description, once more. It cost a fiftieth of a second and it is what a reader with their own collection would compute first.

What this leaves the strand

Four essays: a parse in one pass, a sweep at thirty-two times the size, a relaxation measured, and a histogram that costs nothing.

The deferral that opened it asked for a linear-time bounded-depth parse because the quadratic construction was setting every sweep size in the ladder. It got a linear-time parse, a different bounded-depth parse whose difference is measured, and one measurement that nobody had because nobody could afford it.

What it did not get is a cap enforced exactly in linear time, and the cap an automaton cannot see is why: the query a state would have to answer is about a quantity the parse itself produces, which is a dependency rather than a missing structure.

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.

Depth capExtractionHistogramLempel zivMeasurementParameterPhrasePracticeRepetitionSuffix automatonThresholdTrade off