memory_and_probes

Memory and Probe Metrics

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.

Memory Footprints (size=10000)

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.

Enable metrics

./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.csv

Tip: Pair with --seed 12345 for repeatability and consider --bootstrap 400 for confidence intervals.

Interpreting memory_* fields

When --memory-tracking is enabled, outputs include:

Common patterns:

Interpreting probes (HashMap)

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.7398

These 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.

Tuning the HashMap

Flags you can adjust:

Examples:

# 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

Quick checklist

Example: reading JSON

You can quickly summarize the JSON with our helper script:

python3 scripts/example_parse.py results/csvs/benchmark_results.json --summary

This prints a compact table and a one‑line meta summary (seed, size, runs).


Last updated: generated at build time; see --version for commit.