{
  "slug": "kll-sketch",
  "term": "KLL sketch",
  "aliases": [
    "Karnin-Lang-Liberty sketch"
  ],
  "definition": "A KLL sketch is a randomized streaming summary that uses weighted compaction to estimate quantiles or ranks with an additive rank-error contract.",
  "note": "Compaction retains weighted representatives instead of every input value. The error concerns positions in the ordered observations, not milliseconds. The original paper distinguishes single-query from all-query guarantees and separates mergeable and non-mergeable constructions; do not combine their strongest properties. [kll-paper]\n\nA narrow rank interval can cross a large gap in values. DDSketch instead targets relative-value accuracy. Neither contract is automatically a confidence interval for a wider population. [kll-bounds] [ddsketch-paper]\n\nWith duplicate values, several sorted positions share one value. Record inclusive/exclusive rank and the quantile selection convention. [rank-conventions]\n\nHesela's exact constructed example has 10,000 distinct durations. Its nearest-rank p99 is 10 ms, while the next observation is 1000 ms at rank 0.9901. This is synthetic arithmetic, not an observed KLL output or a device benchmark. No k setting or failure probability is inferred. [hesela-rank-gap]",
  "related": [
    "quantile-sketch",
    "quantile",
    "ddsketch",
    "latency-histogram-bin"
  ],
  "citations": [
    {
      "id": "kll-paper",
      "title": "Karnin, Lang and Liberty. Optimal Quantile Approximation in Streams (2016), definitions 1-2, sections 2 and 4, Table 1. arXiv:1603.05346.",
      "url": "https://arxiv.org/abs/1603.05346",
      "accessed": "2026-11-28"
    },
    {
      "id": "ddsketch-paper",
      "title": "Masson, Rim and Lee. DDSketch. PVLDB 12(12), 2195-2205 (2019), section 1 and definition 1. DOI 10.14778/3352063.3352135.",
      "url": "https://www.vldb.org/pvldb/vol12/p2195-masson.pdf",
      "accessed": "2026-11-28"
    },
    {
      "id": "kll-bounds",
      "title": "Apache DataSketches: Understanding KLL Bounds, discontinuities and error dimensions.",
      "url": "https://datasketches.apache.org/docs/KLL/UnderstandingKLLBounds.html",
      "accessed": "2026-11-28"
    },
    {
      "id": "rank-conventions",
      "title": "Apache DataSketches: Sketching Quantiles and Ranks Tutorial, duplicates and inclusive/exclusive ranks.",
      "url": "https://datasketches.apache.org/docs/QuantilesAll/SketchingQuantilesAndRanksTutorial.html",
      "accessed": "2026-11-28"
    },
    {
      "id": "hesela-rank-gap",
      "title": "Hesela: p99 accuracy, rank error is not latency error. Constructed example and downloadable tests.",
      "url": "https://hesela.com/analyses/quantile-rank-error-latency-gap/",
      "accessed": "2026-11-28"
    }
  ],
  "status": "research",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-28",
  "provenance": [
    "Primary-source synthesis and exact synthetic arithmetic. No KLL execution or storage benchmark."
  ]
}
