This tutorial explains two sets of diagnostics provided by hashbrowns when you enable optional flags:
Along the way we’ll show small runs and how to tune the HashMap.
From a recent benchmark run, typical memory usage: - Array: 655,416 bytes (contiguous allocation with growth factor) - Singly-linked list: 480,104 bytes (node pointers, no backlinks) - Doubly-linked list: 560,104 bytes (additional back pointers) - HashMap: 786,664 bytes (table + open addressing overhead)
The HashMap uses more memory due to maintaining empty slots for efficiency, while linked lists have per-node pointer overhead. Arrays show the highest footprint due to geometric growth reserving extra capacity.
./build/hashbrowns --size 20000 --runs 8 --memory-tracking --out-format json --output results/csvs/benchmark_results.json./build/hashbrowns --structures hashmap --hash-strategy open --size 20000 --runs 8 --out-format csv --output results/csvs/benchmark_results.csvTip: Pair with --seed 12345 for repeatability and
consider --bootstrap 400 for confidence intervals.
When --memory-tracking is enabled, outputs include:
Common patterns:
For open addressing, average probe counts highlight table efficiency:
Rules of thumb:
Actual benchmark results (size=10000, default settings):
"insert_probes_mean": 2.7669,
"search_probes_mean": 1.7398,
"remove_probes_mean": 1.7398These healthy probe counts (< 3) indicate good hash distribution and appropriate load factor. - Means > ~5 indicate clustering or over‑filled tables. - Large stddev implies unstable performance; address load factor or hashing strategy.
Flags you can adjust:
--hash-load F — target max load factor before growth
(e.g., 0.60–0.75)--hash-capacity N — initial capacity (rounded to pow‑2
for open addressing)--hash-strategy {open,chain} — switch to separate
chaining if distribution is skewedExamples:
# Reduce load to limit clustering
./build/hashbrowns --structures hashmap --hash-strategy open --hash-load 0.6 --size 50000 --runs 6 --memory-tracking
# Pre‑size to avoid early rehash and smooth insert probes
./build/hashbrowns --structures hashmap --hash-strategy open --hash-capacity 65536 --size 50000 --runs 6 --memory-tracking
# Try chaining strategy (probe metrics will be zeros by design)
./build/hashbrowns --structures hashmap --hash-strategy chain --size 50000 --runs 6 --memory-tracking--hash-load or
raise --hash-capacity.--runs, enable
--bootstrap, pin CPU, disable turbo on Linux.You can quickly summarize the JSON with our helper script:
python3 scripts/example_parse.py results/csvs/benchmark_results.json --summaryThis prints a compact table and a one‑line meta summary (seed, size, runs).
Last updated: generated at build time; see --version for
commit.