The tuples a merge does not give back
A quantile summary is bought for its size. It answers rank queries to a stated tolerance while holding a few hundred tuples instead of twenty thousand values, and everything interesting about it is a statement about how few tuples that is.
The promise that does not survive the tree measured what a merge does to its accuracy and noted, in passing, that the merged summary also kept about seven times the tuples. Seven times what, at what shard count, tending to what — none of that was answered, and it is the half of the result a deployment pays for continuously rather than at query time.
Why a merge cannot compress back
The structure keeps a sorted list of tuples, each carrying a value, the number of items it stands for, and how uncertain its rank is. A compression pass walks the list and folds a tuple into its neighbour whenever the combined weight and uncertainty stay inside the cap the tolerance allows at that rank. That is what keeps a single pass at a few hundred tuples over any number of values.
A merge interleaves two such lists. A tuple from one summary knows its rank among that summary’s items exactly as well as it did before, and knows nothing about its rank among the other summary’s items beyond which two of its tuples it falls between. So it inherits that gap as extra uncertainty, and the merged list is compressed with the merged cap.
Both halves of that move the wrong way at once. The uncertainties go up, which makes each tuple harder to fold; and the caps go up too, since the cap is proportional to the item count and the merged summary has twice as many items. If the second effect dominated, compression would recover everything. It does not.
The reason is that a tuple’s inherited uncertainty is charged against it, while the enlarged cap is shared with everything else in the neighbourhood. Two tuples that would have folded now carry two inherited gaps between them, and the cap has to cover both. The arithmetic works out to a merged list that is longer than either input relative to its own item count, every time, and the excess accumulates as the tree deepens.
The shape, fitted
Seven times at thirty-two shards is a point. The sweep is the shape, and the shape is fitted here rather than described, for the reason fitting a class to measurements gives: a growth claim read off the code is a guess about the code, and a growth claim read off measurements is a claim about the measurements.
At a tolerance of one per cent, high-biased, the counts are 779, 1151, 1677, 2454, 3637 and 5450 tuples at 2, 4, 8, 16, 32 and 64 shards, against a single summary’s 512. The fitted power law has an exponent of 0.559 and a multiplier of 527, and the worst departure of any point from the fitted line is 1.2 per cent.
The multiplier is the thing to notice. 527 against a single summary’s 512 — within three per cent, and the same coincidence holds at every tolerance measured: 283 against 277, and 942 against 958. So the shape is
with near 0.56 and the constant supplied by the un-merged structure. A merged summary is the single-pass summary, multiplied by a power of the shard count.
It does not converge. There is no shard count past which the growth flattens, over the range measured, and the fit is close enough that a flattening would be visible. Doubling the machines multiplies the answer’s size by about 1.47, indefinitely as far as these measurements can see.
The honest limit applies here in its usual form and is worth restating rather than assumed. A fit across a measured range refutes and measures a constant; it does not establish a limit. What is claimed is that the counts follow this shape from two shards to sixty-four at three tolerances, and that anything with a plateau in it is refuted over that range.
What the exponent depends on
Two dials were available and only one of them moves it.
Halving the tolerance moves the multiplier and leaves the exponent alone: 0.582, 0.559 and 0.541 at tolerances of two, one and half a per cent, against multipliers of 283, 527 and 942. The multipliers double as the tolerance halves, which is the usual behaviour of the un-merged structure, unchanged by merging.
Changing the error function moves the exponent. High-biased and low-biased summaries both sit at 0.56; plain Greenwald–Khanna, whose cap does not depend on where in the distribution the tuple sits, is at 0.737 with a worse fit residual of 6.5 per cent.
That inversion is worth a moment. The biased summaries exist because a uniform tolerance is the wrong promise for a tail — a promise about the rank sets out why an absolute rank error of two hundred is useless at the ninety-ninth percentile — and they buy the tail’s resolution by keeping more tuples up there. So they start large. Under merging they then grow more slowly than the structure they were bought to replace, and the crossing never happens over this range: at sixty-four shards the unbiased summary holds 1,475 tuples and the biased one 5,450.
The structure with the better promise is the one whose merge is expensive, in absolute terms throughout, and by a smaller factor at large shard counts than at small ones. Neither of those is stated anywhere in either structure’s guarantee, which is a guarantee about ranks.
The compression that runs at the wrong moment
There is a tempting repair, and following it to where it fails explains the growth better than the arithmetic does.
A single-pass summary compresses on a schedule — once every arrivals — and the schedule is what keeps its size flat. A merged summary compresses once, at the merge. So the obvious question is whether compressing harder afterwards would recover the size, and the answer is that there is nothing left to compress: the pass has already folded everything the caps permit, and running it again is a no-op.
The tuples that remain are not lazily kept. Each of them is a tuple whose uncertainty, after inheriting a gap from the other side, is too large to fold into its neighbour without breaking the promise. Folding them anyway is available and is a different structure with a different guarantee.
That is the same structural point the summary that has to forget makes about expiry — the state a structure holds is the state its guarantee requires it to hold, and reducing it means changing the guarantee rather than being cleverer. What the merge has done is push the uncertainty budget into a shape where fewer folds are legal, and no amount of re-running the same rule reverses that.
In bits, which is what is bought
Tuples are the structure’s own unit. The unit a deployment is billed in is bits, and the conversion is fixed — a value and two counters per tuple — so the growth is the same growth with a constant on it. It is worth drawing anyway, because the comparison that matters is not against one summary.
At sixty-four shards the deployment is holding 1.2 million bits across its summaries and the merged answer keeps 523,000. So the merge is a compression, by a factor of 2.3 — and the thing it compresses to is 10.6 times what a single summary over the same values would have needed.
Both numbers are true and they support opposite sentences. The merge more than halves the state is true. The merge costs ten times the state is true. The first compares against the shards and the second against the summary the shards are standing in for, and the second is the comparison the state a merge is standing in for argued is the only honest one — for exactly the same reason, one level along.
The accuracy, so that the trade is a trade
None of this would matter if the extra tuples bought accuracy. They do not buy much.
The merged summary’s realised errors are small — a handful of ranks at the quantiles that matter, against a promise of a hundred at the median. What has grown is the state, not the error, and the state has grown by a factor of ten while the error has stayed inside a bound that itself moved.
So the trade is: pay ten times the space to get an answer whose accuracy is roughly what the single-pass summary would have given, having never had the values in one place. That is a defensible bargain for a system that genuinely cannot collect the stream, and it is not the bargain the structure’s specification describes. It is also the second time this collection has found a merge whose cost is in a currency its guarantee does not mention: the state a merge is standing in for found the counter tables giving up accuracy at constant space, and the quantile summaries give up space at nearly constant accuracy. Same operation, opposite axis, and in both cases the axis that moves is the one nobody was watching.
The reason the two structures differ that way is structural rather than incidental. A counter table has a fixed width, so a merge that cannot represent what it holds must lose accuracy; a tuple list grows, so a merge that cannot represent what it holds keeps more tuples. A structure with a fixed allocation converts merge damage into error, and a structure that grows converts it into space — which is a sentence about allocation policy rather than about quantiles, and it is the kind of thing space is the other axis exists to collect.
That last plate opens the question the shape that moves the bill takes up: the tuple counts above were all measured with the shards combined pairwise in a tree, which is one of three orders a deployment might use, and the choice is worth more than a doubling of the shard count.
Where the tuples sit
One more property, because it decides whether the extra state is doing anything.
The merged summary’s extra tuples are not spread evenly along the distribution. They cluster where the caps are tightest, which for a high-biased summary is the upper tail — precisely the region the biased error function was chosen to resolve. So the growth is concentrated in the part of the structure a deployment cares most about, and it is not obviously waste.
It is also not obviously value. The realised rank errors up there are already far inside the promise, so the extra tuples are resolving a region that was not short of resolution. What has happened is that the merge’s inherited uncertainties are largest where the caps are smallest, so the fold fails most often exactly where the structure is densest.
The merge is not the only thing that grew
One more quantity moves with the shard count and it is easy to miss because it is not the structure’s own.
Every shard holds a summary while the merge is being computed. At sixty-four shards that is sixty-four summaries of a sixty-fourth of the values each, and a summary of items is not a sixty-fourth the size of a summary of — it is a good deal more than that, because the tuple count of one of these structures grows slowly with the item count rather than proportionally.
Measured here, sixty-four shards hold 12,630 tuples between them against a single summary’s 512. So the deployment’s total state at the moment of the merge is twenty-five times what one machine would have held, before any merging has happened at all.
That is the same accounting that makes the merged answer’s ten times look modest, and it is the reason the comparison is drawn against the shards rather than against the single summary alone. A distributed summary is expensive in three places — the shards, the merge, and the answer — and only the third of them is what anybody calls the structure’s size.
The exponent sits halfway between the two things it could have been
An exponent of 0.56 is a measurement without a scale until it is set against the two exponents the merge could conceivably have had, and both of those are known.
A merge that lost nothing would keep what the shards keep. A Greenwald–Khanna summary’s tuple count is — governed by the tolerance, nearly independent of how many items it has seen — so shards hold about times one shard’s list however the stream is divided. That is an exponent of 1.
A merge that lost nothing worth keeping would produce the summary a single machine would have built over the union, whose size does not move with at all. That is an exponent of 0.
Measured: 0.56, which sits almost exactly between them.
That is the quantitative form of the sentence this essay has been circling. The merge is neither a concatenation nor a re-summarisation; it recovers about half of what having the values in one place would have recovered, measured on the exponent, at every tolerance and both biased error functions.
The three-way comparison also settles the two true sentences that support opposite readings. At sixty-four shards the deployment holds 12,630 tuples, the merged answer keeps 5,450, and one summary over the same values would have kept 512. The merge more than halves the state and the merge costs ten times the state are both readings of that row — and the exponents say they will keep diverging: the first comparison improves with , because 1 exceeds 0.56, and the second worsens, because 0.56 exceeds 0.
So a deployment scaling out sees its merge look better and its answer look worse, from the same measurement. Which of the two a capacity plan should quote is the state a merge is standing in for’s question and its answer is the second: the merge is standing in for the single summary, and the single summary is what its specification describes.
The framing also says what a better merge rule would have to achieve, which is more useful than saying it does not exist. Anything that folds more aggressively moves the exponent towards zero and gives up promise; anything that folds less moves it towards one and gives up nothing but space. The exponent is the dial, it is currently at 0.56 for the biased structures and 0.74 for the unbiased one, and the difference between those two is the clearest evidence in this essay that the number belongs to the cap function rather than to the merge.
And it puts the fold shape in proportion. The shape that moves the bill measures a chain against a tree at thirty-nine per cent, which on this scale is a change to the constant and not to the exponent — worth taking, worth once, and not a way out of a growth that doubles the answer’s size every three doublings of the fleet.
What a capacity plan can now say
Before this, the available statement was the merge keeps more tuples than one summary would. What is available now:
A shape. Tuples go as the single-pass count times the shard number to a power near 0.56, over two to sixty-four shards, at three tolerances, with a worst residual of two per cent.
A constant that is already known. The multiplier is the un-merged structure’s own tuple count, which is the quantity every published account of these summaries gives. So a deployment that knows what one summary costs knows what the merge of costs, without running the merge.
A dependence on the value distribution that is not there at all. The counts come out identical on lognormal, uniform, Pareto and bimodal inputs, to the tuple, because the structure is rank-based and never looks at a value except to order it. That is the property the error that is on the rank established for the un-merged summary, and it survives merging intact.
A dependence that is the wrong way round. Tightening the tolerance buys resolution and leaves the growth exponent alone; changing the error function changes the exponent, and the function with the better tail promise is the one that starts larger and stays larger.
The remaining question this leaves is what the exponent is, as opposed to what it measures at. The residuals drift slightly with the number of values — the fitted exponent moves from 0.52 to 0.57 as the stream grows from four to thirty-two thousand — which on this site’s own reading is the signature of a power law that is not quite one, in the way the constant the notation drops describes for the sorts. Whatever the true form has in it, it is a slowly growing factor and not a plateau, and none of these measurements is consistent with the merge settling down.
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.
- The cheap tail and the expensive merge curve fitting · greenwald–khanna · guarantee · merge tree · mergeable summary · quantile summary · rank error · shard · space overhead · state bits
- The shape one structure will not fold greenwald–khanna · merge tree · mergeable summary · partition · quantile summary · rank error · shard · space overhead · state bits
- An error measured against the answer greenwald–khanna · guarantee · honest limit · rank error · state bits · summary
- The floor a merge does not settle at curve fitting · honest limit · merge tree · mergeable summary · partition · shard
- What a fold charges per level guarantee · merge tree · mergeable summary · partition · quantile summary · shard
- The bill a partition only divides guarantee · merge tree · mergeable summary · partition · shard
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.
Curve fittingGreenwald–KhannaGuaranteeHonest limitMerge treeMergeable summaryPartitionQuantile summaryRank errorShardSpace overheadState bitsSummary