Field

What the libraries do

None of the sorts measured in the other fields is what runs when a program calls sort. A library sort is not an algorithm but a policy — a set of decisions, each with a threshold somebody typed — and the thresholds are where its behaviour actually lives.
Timsort95,770shipsIntrosort130,863shipspdqsort114,408shipsDual-pivot116,836shipsMerge sort96,145textbookHeapsort187,796textbookQuicksort, median-3119,098textbookalgorithmcomparisonsrandom, n = 8,192comparisons, counted exactly

The sort the library ships

What a standard library actually runs, measured with the same instrument as everything else here — and why a library sort is a policy with thresholds rather than a procedure with a complexity.

11010010³10⁴10⁵10⁶10⁷natural runs r in the inputcomparisonsn / minrun = 256TimsortMerge sortInsertionn + n log₂ rn = 8,192, runs built exactlycomparisons, counted exactly

A run is a property of the input

Turning the shape of an input into a measured number, so an adaptive bound has a second parameter that can be swept — and finding the point where the input's structure stops mattering.

dark: with galloping · pale: with the mode removednearly sorted33,95221,373 jumped−37.7%few distinct values57,91241,178 jumped−36.9%random95,7702 jumped+0.0%n = 8,192, MIN_GALLOP = 7comparisons, counted exactly

When galloping pays

How Timsort's galloping mode works, what it saves, what it costs when it cannot help, and why a mode entered on evidence is safe to have switched on everywhere.

algorithmspread of count ⁄ f(n) — 1.0 is exactTimsortPython, Java objects, Rust, Android1.176nIntrosortC++ std::sort1.104n log nPattern-defeating quicksortRust unstable sort, Boost, libstdc++ 141.155nDual-pivot quicksortJava Arrays.sort, primitives1.624no class grantedtolerance 1.6fitted n = 256–16,384comparisons, counted exactly

The pattern that defeats the pattern

How pattern-defeating quicksort detects a bad partition and responds, why its equal-element partition makes it linear on duplicate-heavy input, and what an omission in the implementation nearly reported as a property of the algorithm.

1010010⁵minruncomparisonsshipped: 32randomnearly sortedTimsort, n = 8,192comparisons; rings mark the measured minimum

The threshold somebody chose

Sweeping the constants inside real library sorts, finding that none of them minimises any single counter, and working out what they are actually chosen against.

H₀ = 3.8916642561k4k16kwindow, in symbolsbits per symbol0.04.38.6LZSSmean symbols covered per match4.65.15.76.98.79.6model: a window of recent text, no probabilities2.13 bits/symbol at a window of 16,384

The dictionary that builds itself

LZSS and LZ78 measured — what a dictionary coder's model actually is, why the window has an optimum rather than growing without limit, and what a compressor does on a stream with nothing to find.

fades a lazy table computed382,976fades an eager table would compute3,830,256fade multiplications (log scale)11,968 evictions, each comparing all 32 counters at one instant32 counters · half-life 4 s · bursty10× fewer

The fading nobody computes

Why an exponentially decayed counter is computed lazily, what the laziness costs at the one operation that cannot be lazy, and where floating point forgets faster than the decay does.

0%25%50%75%100%1.5×shareheadroom over the mean occupancyoverflowingstanding idledrifting · 4.0 s window · 100 Hz47% overflow at the mean

Sized for a rate that does not hold still

What a capacity chosen from mean occupancy actually delivers on a stream whose rate varies, why overflow and idle space cannot both be made small, and where the headroom that fixes one stops being worth paying.

1,00010,00010³10⁴characters of textcomparisons, built and scannedcrossing at n = 32,000both rules, exactlythe 1979 tables2 patterns of 10 · four symbolscrossing n = 32,000

The rule that pays on a long enough text

Adding a matcher's preprocessing to its scan, and finding that which shift rule is cheaper is a question about how much text there is.

1,00010,00010³10⁴characters of textsteps, precomputation plus scancrossing at 8,000published rulesexact rules2 patterns · four symbolscrossing 8,000 · was 32,000

Where the exact rules pay now

The precomputation-plus-scan arithmetic for two multi-pattern shift rules, redone once the exact rules are built from the trie's links rather than from their definition.

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

The number that would choose a cap

The measurement that decides a depth cap, why it costs nothing, and what a parameter chosen from a curve rather than from the data actually costs.

100100occurrences of the patternreadsmost frequent ", and " · 388 occurrencesthe scanthe chain12 documents · 144,617 characters3 of 6 won

What the generated collection was right about

The accounting across five strands — which conclusions transfer to real documents, which were properties of the generator, and what a model is and is not for.

0200400200400occurrences of the patternrows read, and documents in the answerrows readdocuments in the answertwo thousand short documents · 2,214 documents1.04 occurrences a document

The crossing that never arrives

The listing crossing measured on two real collections of the same prose cut two ways, and what occurrences-per-document has to be before a structure proportional to the answer is worth its bits.

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

The cap that would ship

The cap sweep re-run on real text, the knee measured on collections nobody generated, and what a system indexing a version history should set the parameter to.

both halves, one in 3215.0 steps100.0% the sizeforward sampled one in 3215.0 steps83.3% the sizeforward sampled one in 167.0 steps88.4% the sizeforward sampled one in 83.0 steps98.5% the sizeforward sampled one in 41.7 steps118.8% the size8,192 characters · 6 occurrences5.0x faster, 98.5% the size

The saving, spent

The asymmetric index at equal size to the symmetric one, with the forward sampling made four times denser, and what that does to the LF steps a locate costs.

a segment tree over the chain2.70x8,142,274 bitsa succinct range minimum over the chain1.62x4,898,356 bitsno chain at all0.84x2,534,726 bitsthe dashed rule is the index itself: a suffix array and the text131,327 characters · 256 documents2.70x → 0.84x

The apparatus that is smaller than its index

The document-listing apparatus priced in three stages, what remains once the chain is gone, and which collection shapes the whole structure is worth building for.

one text16 short documentsprosecopies of one baseprose, one textr/n 0.2996z/n 0.1273prose, many short documentsr/n 0.3053z/n 0.1301copies of one base, run togetherr/n 0.0638z/n 0.0354one copy per documentr/n 0.0768z/n 0.04188,192 characters throughoutthe outlined cell is the one that was empty

A collection is a construction

Two constructions of one repetitive collection, measured against each other on every quantity this field charges for, and what a corpus description has to say to be usable.

bits heldbalanced49,593huffman41,589the answer comes backbalanced: sorted · 26 operationshuffman: sorted · 24 operations32 documents · zipf lengths83.9% of the ordered tree

The smaller tree hands it back unsorted

The one remaining choice in a document-listing apparatus, priced in both directions, and the case where an ordering preference becomes a correctness question.

02040608000.50011.502errors permittedbranches that find nothing, per cent5.75x6.98x9.22xthe label is thesaving at that budget8 patterns · 8 characters31.3% to 74.9%

A looser budget wastes a larger share

The dead-extension share swept over the error budget, and why a pruning's value rises rather than falls as the problem gets harder.

0102030100200one sampled position in every …of both halves saved, per centplain marks: 13.5%Elias-Fano: 1.8%16,384 characters17.6x against 2.3x

The floor was the marks

A published saving retracted by replacing a component, and what a curve that flattens is usually telling a reader.

a loop over the alphabet107.9the compound walk10.0the cheapest hereone descent per step19.016 exact patterns of 12ranks per step · sigma 21

The saving that is a loss

The interval enumeration measured on a search that does not branch, and why two operation savings split by the shape of the query rather than stacking.

phrases examined per probethe linear scan207.0sorted, with a running maximum10.9 — 19xthe running maximum costs 2,821 bits — 21.6% of the index40 of 40 positions checked, and the two agree at all of them238 phrases · 6,144 characters19x on the scan

The scan the order does not touch

The other half of a phrase index's propagation, attacked by a structure rather than by an ordering, and why the two are kept on separate plates.

10010³10⁴10³10⁴10⁵characters of textoperations, construction includedcrosses at 256the NFAthe DFA64 DFA statescrosses at 256 characters

Where the table starts paying

The construction cost of a deterministic machine against the per-character cost of a non-deterministic one, and the text length at which the table becomes worth building.

All essays