#quantile #sketch #port #golang #direct #dd-sketch #ddsketch

sketches-ddsketch

A direct port of the Golang DDSketch implementation

8 releases

0.3.0 Jun 1, 2024
0.2.2 Feb 4, 2024
0.2.1 Apr 10, 2023
0.2.0 Jun 27, 2022
0.1.1 Sep 21, 2019

#54 in Algorithms

Download history 212576/week @ 2024-07-19 216237/week @ 2024-07-26 202310/week @ 2024-08-02 187632/week @ 2024-08-09 187890/week @ 2024-08-16 201976/week @ 2024-08-23 176006/week @ 2024-08-30 193382/week @ 2024-09-06 186650/week @ 2024-09-13 214351/week @ 2024-09-20 218355/week @ 2024-09-27 233474/week @ 2024-10-04 216817/week @ 2024-10-11 208408/week @ 2024-10-18 205426/week @ 2024-10-25 253016/week @ 2024-11-01

925,476 downloads per month
Used in 179 crates (7 directly)

Apache-2.0

24KB
557 lines

sketches-ddsketch

This is a direct port of the Golang DDSketch quantile sketch implementation to Rust. DDSketch is a fully-mergeable quantile sketch with relative-error guarantees and is extremely fast.

DDSketch

  • Sketch size automatically grows as needed, starting with 128 bins.
  • Extremely fast sample insertion and sketch merges.

Usage

use sketches_ddsketch::{Config, DDSketch};

let config = Config::defaults();
let mut sketch = DDSketch::new(c);

sketch.add(1.0);
sketch.add(1.0);
sketch.add(1.0);

// Get p=50%
let quantile = sketch.quantile(0.5).unwrap();
assert_eq!(quantile, Some(1.0));

Performance

No performance tuning has been done with this implementation of the port, so we would expect similar profiles to the original implementation.

Out of the box we see can achieve over 70M sample inserts/sec and 350K sketch merges/sec. All tests run on a single core Intel i7 processor with 4.2Ghz max clock.

Dependencies

~165KB