What the libraries do

The cap that would ship

The published sweep put the knee at four to eight. On four real collections it is at nine to twelve, a cap of one costs forty-eight times the free parse rather than twenty-one, and the number a system should actually set is none of those.

The cap on a parse’s depth is a parameter, and a parameter has to be set to a number.

The number that would choose a cap is the essay that asked what that number should be, and answered it from a sweep over a generated collection: the knee is at four to eight, and a cap of one costs 86% of the text in phrases.

Every real collection here disagrees.

Where each collection stops paying for its capThe knee: the smallest cap whose phrase count is within a twentieth of the free parse's. The cap ladder reported four to eight, on a generated collection at 8,192 characters. On real text it is nine to twelve, and the two version histories are the slowest — which is what one would expect once the depth profile is drawn, because the knee is near the worst depth and the worst depth is the number of generations plus what one document had on its own. The row for the generated collection is the ladder's own number, re-measured here at the same size as the others.ten revisions of one filecap 10worst 14 · mean 5.7fourteen revisions of anothercap 10worst 17 · mean 7.2twelve unrelated essayscap 10worst 14 · mean 4.9eight source modulescap 10worst 78 · mean 5.9a generated collectioncap 10worst 13 · mean 4.6within a twentieth of the free parsefour to eight was the model
Fig. 1 The smallest cap whose phrase count is within a twentieth of the free parse’s, on five collections. The published answer was four to eight.

The measurement

Same sweep, same quantity, same construction: for each cap, parse the collection with sources deeper than the cap forbidden, and report the phrase count as a multiple of the free parse’s.

What a cap costs, on five collectionsThe phrase count under a cap, as a multiple of the phrase count without one, against the cap. Every number the cap ladder published came from the generated collection, which is the line marked as such; the real version histories are far steeper. A cap of one costs 35x on fourteen revisions of another against 21x on the model, and the two collections of unrelated documents are flatter than either. The knee — the smallest cap within a twentieth of the free parse — is at 10, 10, 10, 10, 10 respectively, against the four to eight the ladder reported.110110cap on the depthphrases ÷ free parseten revisionsfourteen revisionstwelve essayseight modulesthe model5 collections · free parse = 1worst 35x at a cap of one
Fig. 2 The phrase count under a cap, as a multiple of the free parse. Five collections: two real version histories, twelve unrelated essays, eight source files, and the generated collection every published number came from.

The knees, at the five-per-cent threshold: ten on the ten-revision history, twelve on the fourteen-revision one, nine on the essays, twelve on the source code, and ten on the generated collection re-measured at the same size.

So the published four-to-eight was not a property of the generator either. It was a property of the generator at the size the quadratic construction could reach — a few thousand characters — and the same model at a hundred thousand characters has a knee at ten. Two things moved: the collection became real, and the collection became large enough to measure.

What a tight cap costs on real text

The other end of the sweep is where the two disagree most.

A cap of one — every phrase copies from a literal, nothing chains — costs 24.5 times the free parse’s phrase count on the ten-revision history and 48.1 times on the fourteen-revision one, against 21.4 on the generated collection and 6.4 on the essays.

That spread is the finding. A cap of one is a factor of six on unrelated prose and a factor of fifty on a version history, because a version history is made of chains: every character that survived a revision is copied from the revision before, and forbidding chains means re-encoding all of it as fresh matches.

The model and the history, cap for capfourteen revisions of another against a generated collection matched in size, at five settings of the cap. The two agree nowhere that matters: at a cap of four the real history pays 11x and the model 3.99x, a gap of 2.75. The generated collection is copies of one base text with a fraction of the characters replaced, so every document is one generation from the original and the chains are short by construction; a real history is each revision copied from the one before it, and the chains are as long as the history.cap 1 · real48xcap 1 · model21xcap 2 · real26xcap 2 · model8.93xcap 4 · real11xcap 4 · model3.99xcap 8 · real1.68xcap 8 · model1.24xcap 12 · real1.02xcap 12 · model1.00xfourteen revisions of another · a generated collectionx2.75 apart at a cap of four
Fig. 3 The fourteen-revision history against the generated collection matched to it in size, cap for cap. At a cap of four the real one pays eleven times the free parse and the model pays four.

At a cap of four the gap is 2.75. At a cap of two it is 2.89. At a cap of eight it has closed to 1.35, and by twelve both are at the free parse. So the model is a good approximation exactly where the cap is loose enough not to matter, and wrong by a factor of three where the parameter is interesting.

Why the knee is where it is

The histogram says it, and this is the payoff for having drawn one.

The shape of a real history’s depth shows a bell: mean depth 5.71 on the ten-revision history, peak at 6, worst 14. A cap at D truncates everything deeper than D, so the cost of a cap is roughly the share of the collection above it — and the share above the peak is half the collection.

That places the knee just past the point where the tail becomes thin, which on a bell is a little above the mean and well below the worst. Measured: mean 5.71, knee 10, worst 14.

And one revision, one level says where the worst comes from: the generation count plus the file’s own offset, saturating once the oldest surviving passage stops deepening. So the knee is predictable from two numbers a system can measure — the depth of one document, and how many revisions it holds.

The depth profile of a real version historyEvery position of ten revisions of one file — 75,658 characters — placed at the number of copies an extraction has to follow to produce it. The shape is a bell with a peak at 6, holding 18.4% of the collection, and a thin tail out to 14. Drawn behind it is twelve unrelated essays, which is not a version history and has no generations of copying at all: its mean depth is 5.17 against this one's 5.71. Whatever produces depth in real text is mostly not what the cap ladder was about, because it is here in full when generations are absent.02468101214mean 5.71depthshare of the collectionten revisionstwelve essays75,658 characters · 2,966 phrasesworst 14, mean 5.71
Fig. 4 The distribution the knee is a property of. The cap’s cost at D is the mass to the right of D, and on a bell that mass falls off quickly only past the peak.

What to actually set

For a system indexing a version history, the recommendation from these measurements is:

Cap at the generation count plus the base document’s worst depth, which is the saturation point, and costs nothing measurable. On the fourteen-revision file that is 19, and a cap of 24 is the free parse exactly.

If a tighter bound is needed, twelve is the cheap one. It costs 1.7% of the phrase count on the worst collection here and 0.4% on the next, and it bounds an extraction at twelve chained lookups rather than nineteen. That is a good trade and it is the number this page would put in a configuration file.

Below eight, expect to pay in tens of per cent, rising to a factor of ten by a cap of four. Anything in that range is buying a much tighter extraction bound at a price that shows up in the index’s size, because the phrase count is the size of a parse-based index — an index with z in its size is the whole reason z is the measure.

What a cap would cost if it shippedThe practical end of the ladder: the extra phrases a cap costs, in per cent, at the settings worth considering. A cap is a promise about the worst case — a character costs at most that many copy-follows to produce — and on these collections the promise gets cheap between eight and twelve. At a cap of 24 every collection here is within 1.1% of the free parse while bounding an extraction at 24 follows rather than at the 78 the free parse allows.02004006005101520cap on the depthextra phrases, per centten revisionsfourteen revisionstwelve essayseight modulescaps 4 to 24worst 679.2% at a cap of 4
Fig. 5 The extra phrases each cap costs, in per cent, on four real collections. Below eight the version histories climb steeply and the collections of unrelated documents do not.

What the cap does to the collections that are not histories

Two of the five lines on the sweep belong to collections with no generational structure at all, and they behave differently enough to be worth a section.

Twelve unrelated essays: a cap of one costs 6.4 times the free parse, a cap of four costs 1.96, a cap of eight costs 1.07. That is a shallow curve, and the reason is the histogram — prose’s depths are a bell too, but a narrower one, with a mean of 5.17 and very little mass past 8. Capping prose is cheap because there is not much down there.

Eight source modules: a cap of one costs 6.6, a cap of four costs 2.07, a cap of eight costs 1.15 — and then the curve does something the others do not. It keeps declining slowly, by a per cent at a time, all the way out to 24. That long flat decline is the run tail being truncated a little at a time, and the deepest text is punctuation is what it is made of.

The practical consequence is that a system indexing documents rather than revisions can cap much more aggressively than one indexing a history. At a cap of six the essays pay 32% and the fourteen-revision history pays 332%. Same parameter, same construction, an order of magnitude apart in cost — because the parameter is bounding a chain and one collection is built of chains.

The trade, in both currencies

A cap is not free and it is not only a cost, and the plate that makes the decision is the one with both quantities on it.

What a cap buys is a bound on extraction: the number of chained lookups to produce one character. Uncapped, that is the worst depth — 14, 19, 78 depending on the collection. Capped at 12, it is 12, on every collection, whatever the text turns out to contain.

What it costs is phrases, and phrases are bits: a parse-based index stores a record per phrase, so a phrase count 1.7% higher is an index 1.7% larger. At a cap of 4 it is an index six to eleven times larger on a version history, which is not a trade anybody would take.

The shape of that curve is the argument for capping at all. Between a cap of 24 and no cap the size is identical and the guarantee improves; between 12 and 24 the size moves by a per cent and the guarantee halves. Only below eight does the curve turn, and everything to the right of the turn is free improvement.

Why the earlier number was not wrong

Worth being precise, because “the published number was four to eight and the real one is nine to twelve” reads like an error and is not one.

The earlier sweep was drawn on the collection that could be measured. The parse was quadratic then — the parse in one pass of the text is what removed that — so a sweep over ten caps meant ten parses of a few thousand characters, and a few thousand characters of a generated collection was what a figure could afford. Every number on it is exact about that object.

What changed is not the arithmetic. It is that the object is now available in two other kinds — real, and large — and both of them move the answer. The knee moves from four-to-eight to nine-to-twelve when the collection becomes real; the cost at a tight cap moves by a factor of three when it becomes a chain rather than a star.

That is the pattern this whole strand keeps producing, and it is worth naming as a working rule: a parameter recommendation inherits everything about the collection it was measured on, including the things nobody thought were parameters. The size, the shape of the derivation, whether it has runs in it.

The one row that runs the other way

A sweep with five collections and eleven settings has fifty-five numbers in it, and one of them is worth pulling out because it is the kind of thing that gets tidied away.

At the loosest settings, the source code’s phrase count under a cap of 24 is 1.1% above the free parse, and under a cap of 20 it is 1.4% — monotone, as it must be. But at intermediate caps the ordering between two collections swaps: the essays are more expensive than the source code below a cap of five, and cheaper above it. Two curves crossing in the middle of the plate.

That crossing is not noise. Prose has more mass at shallow depths than source code does — a prose document repeats words rather than lines — so a very tight cap hurts it more; source code has the run tail, so a loose cap hurts it longer. The two effects put the crossing at about a cap of five, and it is visible on the sweep as the point where two lines exchange places.

It matters because a recommendation phrased as “prose caps more cheaply than code” would be true on one side of five and false on the other. This collection’s rule about that is a limit is not a prediction: a comparison between two curves is a comparison at a point, and the point has to be stated.

What a system should measure for itself

The whole recommendation above is four numbers, and the honest advice is to measure them rather than take them.

Parse the collection once uncapped: that gives the free phrase count and the worst depth, in linear time. Parse it at two or three candidate caps: that gives the cost curve near the knee. Four parses of a hundred thousand characters is under a second here, and it produces a curve specific to the collection rather than to somebody else’s.

The reason to bother is the spread on the plate. Between the essays and the fourteen-revision history, at a cap of four, the cost differs by a factor of 5.6 — and both are real collections of real text of the same size. There is no single number, and there is not even a single number per kind of collection: the two version histories differ from each other by a factor of two at the same cap.

What generalises is the shape, not the setting. The curve is steep below the mean depth, has a knee a little above it, and is flat past the worst — and that is a statement a system can act on by measuring two numbers, which is cheaper than trusting one.

What a cap costs, on five collectionsThe phrase count under a cap, as a multiple of the phrase count without one, against the cap. Every number the cap ladder published came from the generated collection, which is the line marked as such; the real version histories are far steeper. A cap of one costs 35x on fourteen revisions of another against 21x on the model, and the two collections of unrelated documents are flatter than either. The knee — the smallest cap within a twentieth of the free parse — is at 10, 10, 10, 10, 10 respectively, against the four to eight the ladder reported.110110cap on the depthphrases ÷ free parseten revisionsfourteen revisionstwelve essayseight modulesthe model5 collections · free parse = 1worst 35x at a cap of one
Fig. 6 Five collections, one plate, no single answer. What is shared is the shape; what differs is where the knee sits and how much a tight cap costs.
Where each collection stops paying for its capThe knee: the smallest cap whose phrase count is within a twentieth of the free parse's. The cap ladder reported four to eight, on a generated collection at 8,192 characters. On real text it is nine to twelve, and the two version histories are the slowest — which is what one would expect once the depth profile is drawn, because the knee is near the worst depth and the worst depth is the number of generations plus what one document had on its own. The row for the generated collection is the ladder's own number, re-measured here at the same size as the others.ten revisions of one filecap 10worst 14 · mean 5.7fourteen revisions of anothercap 10worst 17 · mean 7.2twelve unrelated essayscap 10worst 14 · mean 4.9eight source modulescap 10worst 78 · mean 5.9within a twentieth of the free parsefour to eight was the model
Fig. 7 And the knees again, without the model, since the recommendation is about real collections and the model’s row is there to be compared rather than followed.

What the cap does not bound

One more thing belongs in a recommendation, because a bound that is quoted for the wrong operation is worse than none.

The cap bounds the number of chained copies an extraction follows. It does not bound the work: following a copy means a lookup in whatever structure holds the phrases, and that lookup is a predecessor query or a grid search, costing its own logarithm. The character that costs a chain makes the distinction and this page inherits it — a cap of twelve promises twelve lookups, not twelve memory accesses.

It also does not bound the length of what is copied. A phrase of ten thousand characters at depth 3 is three hops for the first character and three hops for the last, but producing the whole phrase means copying ten thousand characters. Extraction of a substring is bounded by its length plus its depth, and only the second term is what the cap touches.

And it says nothing about the search that finds the occurrences in the first place. A parse-based index answers “where does this occur” through machinery the cap does not enter — an index with z in its size has a grid in it, and the grid’s cost is a function of the phrase count, which the cap makes larger. That is the second-order cost of a tight cap and nothing here measures it: more phrases means a bigger grid, and a bigger grid means slower queries, so a cap chosen for extraction is paid for at query time as well as in bits.

Which is the honest closing note. The recommendation above — twelve, or the saturation depth, measured per collection — is a recommendation about one axis of a structure with three, and the other two are named here and not swept.

One more revision is one more level of depthThe worst and mean depth of the first k revisions of one real file. A single revision, with no generations of copying at all, already reaches depth 8: that is the file's own internal repetition, and it is the larger term for the first several generations. From there every added revision adds exactly one to the worst depth — 9 times in a row — until the twelfth, after which nothing gets deeper and the last revisions only add width. The mean rises steadily and far more slowly, at about 0.36 a generation, because most characters are copied from the revision before rather than through the whole chain.05101520510revisions in the collectiondepthone revision alone: 8worst depthmean depthfourteen revisions of another9 generations added exactly one
Fig. 8 The number the recommendation is built on: the worst depth against the generation count, which saturates and therefore makes a cap a constant rather than a parameter that grows.

The knee transfers and the cost below it does not

Two spreads on this page point in opposite directions, and setting them beside each other says which of the numbers here is safe to reuse.

The knees are nine, ten, twelve and twelve across four real collections — a spread of 1.33. The cost of a cap of one on the same four is 6.4, 6.6, 24.5 and 48.1 — a spread of 7.5. The parameter is stable across collections that differ by a factor of seven in what ignoring it costs.

That is not a coincidence of these four. The knee is a property of where a depth histogram’s tail thins out, and every real collection measured here has a bell with a mean between 5.2 and 5.7 — prose, source code and two version histories, all landing in a 0.5-wide window. The cost at a tight cap is a property of something else entirely: how much of the collection is chained, which is a fact about how the documents were derived and differs by construction between a version history and a pile of unrelated files.

So the two numbers have different domains. Nine to twelve is a statement about the shape of depth in real text and travels; “a cap of four costs eleven times the free parse” is a statement about a fourteen-revision history and travels nowhere.

Which suggests a cheaper instruction than the one this page gives. The recommendation above is to parse once uncapped and twice near the candidate caps — four parses. But the knee is a quantile of the depth histogram, and the uncapped parse already produces the histogram: cap where the mass above the cap is a few per cent, and the four collections here return nine, ten, twelve and twelve without a single capped parse being run.

That reduces the whole procedure to one pass, and it makes the recommendation portable in the right way. A system reports its own histogram’s high percentile rather than borrowing a number, gets the same answer this page got where the collection resembles these, and gets a different and correct answer where it does not — a collection of documents with no repetition at all would have a histogram concentrated near zero and a knee to match, and no sweep would be needed to discover it.

The one calibration worth doing once is which percentile. The cost at a cap is the mass above it times what re-encoding that mass costs, and the second factor is small near the knee and large far below it — which is why the cost curve is flat above the knee and steep below. Fixing the percentile that lands on a five-per-cent cost is a measurement, and it is the same measurement on every collection because it is a property of the re-encoding rather than of the text.

None of which changes the earlier caution. A histogram’s high percentile is still a summary of a distribution, and the shape of a real history’s depth is the reason the mean would be the wrong one to take — the mean sits at 5.71 where the useful cap is 10, and a cap at the mean costs half the collection. Expected is not average is the standing form of that, and here it is unusually sharp: the two statistics differ by a factor of two and the cost between them differs by a factor of a hundred.

What a reader building this should keep

Three numbers and one instruction.

The knee is at nine to twelve on real text, not the four to eight measured on a generated collection at a size the quadratic construction could reach.

A cap of twelve costs 1.7% of the phrase count on the most expensive collection measured here, and bounds an extraction at twelve chained copies rather than at nineteen.

And a cap of four costs between two and eleven times the free parse, depending entirely on whether the collection is a version history or a pile of unrelated documents.

The instruction: parse the collection once uncapped and twice near the candidate caps, which is under a second on a hundred thousand characters, and read the knee off the resulting curve. The spread between two real version histories at the same cap is a factor of two, so there is no number this page could give that would be right for a collection it has not seen.

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.

CapCorpusDepthExtractionGenerated collectionGuaranteeKneeParsePhrase countPracticeVersion history