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

sketches-ddsketch

A direct port of the Golang DDSketch implementation

7 releases

0.2.2 Feb 4, 2024
0.2.1 Apr 10, 2023
0.2.0 Jun 27, 2022
0.1.3 May 26, 2022
0.1.1 Sep 21, 2019

#59 in Algorithms

Download history 57697/week @ 2023-12-23 126786/week @ 2023-12-30 168773/week @ 2024-01-06 129800/week @ 2024-01-13 114767/week @ 2024-01-20 118073/week @ 2024-01-27 127068/week @ 2024-02-03 143956/week @ 2024-02-10 109110/week @ 2024-02-17 128933/week @ 2024-02-24 127782/week @ 2024-03-02 128767/week @ 2024-03-09 137780/week @ 2024-03-16 124388/week @ 2024-03-23 126820/week @ 2024-03-30 112439/week @ 2024-04-06

525,938 downloads per month
Used in 123 crates (6 directly)

Apache-2.0

23KB
542 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

~180KB