First partial results
Benchmark results (single host, 5 iterations, best-of)
=== LONG SET: 100k vertex keys (GraphBatch.allKeys shape) ===
HashSet build= 3.86 ms contains= 0.60 ms mem= 5.9 MB
ConcurrentHashMap.keySet build= 5.67 ms contains= 0.78 ms mem= 6.0 MB
LongHashSet build= 1.43 ms contains= 0.40 ms mem= 2.0 MB
=== INT SET: 200 file-ids x 100k builds (TransactionContext shape) ===
HashSet contains=22.71 ms ~11,742 bytes/instance
IntHashSet contains=11.49 ms ~ 2,153 bytes/instance
=== INT SET: 64 bucket-ids x 100k builds (OpenCypher validBuckets shape) ===
HashSet contains= 8.76 ms ~3,714 bytes/instance
IntHashSet contains= 3.66 ms ~ 566 bytes/instance
┌────────────────────────┬─────────────────────────────────────────┬───────────────────────────────────────┐
│ Workload │ Speed │ Memory │
├────────────────────────┼─────────────────────────────────────────┼───────────────────────────────────────┤
│ 100k Long (GraphBatch) │ 2.7x faster build, 1.5x faster contains │ 3x less (5.9 MB → 2.0 MB) │
├────────────────────────┼─────────────────────────────────────────┼───────────────────────────────────────┤
│ 200 Int (commit shape) │ 2x faster contains │ 5.4x less (11.7 KB → 2.1 KB/instance) │
├────────────────────────┼─────────────────────────────────────────┼───────────────────────────────────────┤
│ 64 Int (OLAP shape) │ 2.4x faster contains │ 6.6x less (3.7 KB → 566 B/instance) │
└────────────────────────┴─────────────────────────────────────────┴───────────────────────────────────────┘
The per-instance memory ratios match the analytical estimate (~10x for int, ~7x for long, partly diluted by the load-factor headroom + table sentinel-fill cost). The speed wins on contains() come from skipping autobox + equals() cast.
For a workload that does 1 commit/sec creating a 200-fileId set, the GC delta alone is ~10 KB/sec saved + ~200 short-lived Integer allocations avoided per commit - meaningful at thousands of TPS.