perf: benchmark metadata string interning strategies - #393
Conversation
Metadata representation experiment resultsI tested three benchmark-local representations:
MethodThe deterministic fixture contains 1,000, 10,000, or 100,000 rows, with four metadata keys per row and eight repeated raw-string values per key. It uses Ahnlich's generated Build measures the additional storage-representation work after request decoding. Criterion excludes fixture cloning from the timed section, so the owned control is nearly free because it only moves the decoded collection. Environment: commit Live metadata allocation
Representation build
Key interning is therefore 475,605-7,409,886% slower than owned representation build in this benchmark, corresponding to approximately 0.38 us of additional conversion work per row. The percentages are unusually large and grow with the fixture because the owned representation performs an O(1) move of already-decoded metadata, while interning performs O(rows x keys) hashing and reconstruction. They describe the isolated representation-conversion regression, not the percentage impact on Ahnlich's complete Equality filtering
Key interning is approximately 28-66% faster for this equality-filter workload. Full interning is approximately 39-74% faster. Materialization back to public metadata
Key interning is approximately 6-9% slower when reconstructing public metadata. InterpretationFull string interning does not look suitable for production: its large memory and filter gains come with broader value conversion, storage-format complexity, and a higher ingestion cost. Integer-ID key interning is more credible. It keeps every The main limitation is that this is an isolated, highly repetitive metadata workload. It does not include protobuf decoding, Raft, vector/index updates, snapshots, or the complete Reproduce with: cargo install critcmp
./benchmarks/run_metadata_representation_ab.sh |
Test Results379 tests 379 ✅ 11m 18s ⏱️ Results for commit a515297. ♻️ This comment has been updated with latest results. |
Benchmark Results |
Summary
This PR contains benchmark code only and does not change Ahnlich production storage or behavior.
Verification
cargo fmt --all -- --checkcargo clippy -p db --bench metadata_representation -- -D warningscargo check -p db --benchesmake test(342 passed, 5 skipped)./benchmarks/run_metadata_representation_ab.sh