A sampling pass names the ten largest entries in a store, but they explain little of the stored-data size; where is the memory?
answer
- ranking individuals, not populations
- a sum, not a maximum
- count next to bytes
- sampling favours the populous prefix
basics
~20 sMost likely in a large population of small entries under one prefix. A largest-entries list ranks individual entries, while memory is held by a distribution, so the walk must sum bytes per prefix rather than keep a maximum.
solid answer
~50 sThose are two different questions and the pass answered the other one. "Is any single entry big enough to hurt other callers?" is answered by a top-N of individual entries. "Who is holding the memory?" is answered by a sum. Six million entries of two kilobytes outweigh ten entries of a megabyte by three orders of magnitude, and not one of those six million ever appears in a largest-entries list. The repair is in the accumulator: during the walk, keep a running sum of estimated bytes *and* a count per prefix, and publish both findings side by side. If the pass is sampled, scale the per-prefix sums by the sampling rate and label them estimates — a sample converges on a populous prefix in proportion to its share, and may never draw a lone outlier at all.
go deeper
Notice that a list of the biggest entries and a total per prefix are different answers. A million small entries never appear in a top-ten list.
Explain the arithmetic: a populous prefix of small entries can outweigh a handful of huge ones by orders of magnitude, so attribution needs a sum, not a ranking.
Produce both findings from one pass, keep count alongside bytes, and state what sampling does to each — it preserves the prefix totals and loses the outliers.
Decide which finding the organisation is actually paying for: outlier hunting protects latency, per-prefix accounting protects headroom, and they escalate to different people.
## Two questions that look like one Operationally there are two distinct findings, and confusing them is the most common way an attribution exercise ends with nothing actionable. - **"Is one entry big enough to hurt other callers?"** A single very large entry is an operational hazard in its own right: it is expensive to transfer, expensive to remove, and on a server that executes one operation at a time it delays everybody while it is handled. Whether an oversized entry is a design fault, and what to do about it, is its own subject — here it is only something the walk can find. - **"Which prefix is holding the memory?"** This is an accounting question, and the answer is a sum. It has no relationship to the first. A **sampling pass over entries** that reports the largest entries it saw answers the first question. It is blind, by construction, to the second. ## Why a top-N is blind to a heavy prefix The arithmetic is the whole insight. Suppose the tier holds: - ten entries of one megabyte each — about ten megabytes, and every one of them lands in a top-ten list; - six million entries of two kilobytes each under a single prefix — about twelve gigabytes, and not one of them is ever ranked. The list is correct and useless. The memory is a *distribution*, and a ranking of individuals cannot see a population. The same blindness runs the other way: a prefix that is light in total can still contain the one entry that stalls a caller, so a rollup alone does not replace the top-N either. Both findings are needed, and they answer different pagers. ## The accumulator that answers both During a single walk, per prefix, keep: 1. a **running sum of estimated bytes** — who holds the memory; 2. a **count of entries** — whether growth is population or size; 3. the **largest entry seen**, with its key — the outlier hunt, for free, on the same pass. The derived average (bytes divided by count) is what makes the report readable: two prefixes at the same total behave completely differently at a hundred bytes each and at ten megabytes each, and the remedies have nothing in common. | Finding | Answers | Blind to | |---|---|---| | Largest individual entries | whether one entry can stall a caller or a transfer | a prefix made of millions of small entries | | Heaviest prefixes by summed bytes | who is holding the memory | one rare outlier inside an otherwise light prefix | | Entry count per prefix | whether a population or an entry size is growing | skew hidden inside a single prefix | ## What sampling does to each finding Sampling is what makes the pass affordable, and it treats the two findings very differently: - **Per-prefix sums survive sampling well.** A sample drawn across the keyspace lands in a prefix roughly in proportion to that prefix's share of the entries, so scaling by the sampling rate converges quickly on the shape — which prefixes dominate, and by roughly what factor. - **Outliers survive sampling badly.** A single enormous entry is one member out of millions and may never be drawn. If outliers are genuinely the point, either walk exhaustively, or check a size threshold on every key as you pass it and record only the exceedances, which is cheap. Quote a scaled sample as an estimate with its rate attached. A per-prefix figure presented to three significant figures from a one-in-a-thousand sample is a claim the measurement cannot support. ## Reporting it so the two are not confused Publish them as two tables under two headings, never as one merged list. State the walk's window and whether it was full or sampled. Where the store could not report per-entry sizes and you measured fetched values instead, say so, because those numbers exclude whatever the entry costs beyond its bytes and are not comparable to the server's own total. The residual gap between your summed estimates and that total is itself worth printing: it is the honest error bar on the whole exercise, and a reader who sees it will trust the rest.
- Which of the two findings does a sampled pass give you more reliably?The per-prefix totals. A sample lands in a prefix roughly in proportion to its share of the entries, so the scaled sums converge on the shape quickly. A lone outsized entry is one member among millions and may never be drawn, so outlier hunting needs an exhaustive pass or a size threshold checked on every key.
- Why report entry count per prefix next to bytes?Because the two move for different reasons. Bytes rising with a flat count means entries got bigger; count rising with flat average bytes means a population grew; and a count that only ever rises points at lifetimes rather than at size. One column turns a total into a diagnosis.
A list of the heaviest crates in a warehouse tells you which one needs two people to lift. It does not tell you that aisle seven, stacked floor to ceiling with small identical boxes, is carrying most of the floor's load.
saying these in an interview costs you the question
- Reports the largest entries as the memory breakdown
- Assumes the heaviest prefix must contain the biggest entry
- Quotes a scaled sample as an exact total
- Keeps a maximum per prefix instead of a running sum
- Assumes a sampling pass will surface every outlier