-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial HdrHistogram C
Dmdv edited this page Jul 11, 2026
·
1 revision
Source:
docs/tutorials/hdrhistogram-c.mdin the main repository.
Tail latency is the product metric. This repo ships two histogram layers:
| Layer | Type | When to use |
|---|---|---|
ll::HdrLatencyHistogram |
Portable log2 buckets, header-only | Always-on, no deps, demos |
ll::HdrHistogramC |
Wrapper over HdrHistogram_c | Production fidelity (optional) |
CMake option STACK_WITH_HDRHISTOGRAM=ON (default) FetchContents
HdrHistogram_c 0.11.10
and links hdr_histogram_static.
LL_HAS_HDRHISTOGRAM_C=1 → full API
LL_HAS_HDRHISTOGRAM_C=0 → wrapper methods no-op / invalid()
Disable if you need a deps-free configure:
cmake -S . -B build -DSTACK_WITH_HDRHISTOGRAM=OFF#include "ll/hdr_c.hpp"
#include "ll/tsc_clock.hpp"
ll::HdrHistogramC h; // range up to ~1h in ns by default
auto t0 = ll::steady_ns();
// … work …
h.record(static_cast<std::int64_t>(ll::steady_ns() - t0));
auto p99 = h.value_at_percentile(99.0);
auto p999 = h.value_at_percentile(99.9);
auto mx = h.max();Compare with portable:
ll::HdrLatencyHistogram<> portable;
portable.record(dt);
// portable is coarser (power-of-two buckets) but zero external deps./build/example_hdr_c
ctest --test-dir build -R 'roadmap.*hdr'- Prefer HdrHistogram_c (or Java/Go HDR ports) for long-running services.
- Record in nanoseconds or cycles, not mixed units.
- Export p50/p90/p99/p99.9/max every interval — never ship on mean alone.
- Keep recording allocation-free (both wrappers avoid heap after init).
- Pair with Google Benchmark (
make bench) for micro-level queue costs.
docs/blueprint/06-telemetry.md-
include/ll/hdr_histogram.hpp·include/ll/hdr_c.hpp
Wiki mirror of repository docs. Edit docs/ in the main repo, then python3 scripts/publish_wiki.py.