Repository navigation
perf(db): share collectors within predicate indexes - #424
Merged
Merged
Conversation
Signed-off-by: Jim Ezesinachi <ezesinachijim@gmail.com>
Test Results402 tests 402 ✅ 11m 41s ⏱️ Results for commit b31f915. ♻️ This comment has been updated with latest results. |
Signed-off-by: Jim Ezesinachi <ezesinachijim@gmail.com>
Benchmark Results |
Signed-off-by: Jim Ezesinachi <ezesinachijim@gmail.com>
Opt-in Benchmark ResultsCriterion results from the benchmark targets changed by this PR. db/papaya_collector_sharingfirst-time benchmark: candidate vs control db/papaya_collector_memoryMedian of 3 isolated processes per case. Values are control / candidate.
|
deven96
self-requested a review
September 18, 2026 11:52
deven96
approved these changes
Sep 18, 2026
deven96
left a comment
Owner
There was a problem hiding this comment.
LGTM
Approved but pending removal of the bootstrap code in the core engine
Signed-off-by: Jim Ezesinachi <ezesinachijim@gmail.com>
Signed-off-by: Jim Ezesinachi <ezesinachijim@gmail.com>
Signed-off-by: Jim Ezesinachi <ezesinachijim@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reduce predicate-index memory usage by sharing one Papaya collector between the outer map and all value buckets belonging to the same predicate index.
Previously, every predicate-value bucket owned an independent collector. High-cardinality indexes could therefore create tens or hundreds of thousands of collectors, with the collector overhead dominating the memory used by the indexed values themselves.
The new per-index boundary keeps separate predicate indexes isolated while removing the collector-per-bucket cost.
Implementation
SharedPredicateIndex, which owns:MetadataValue -> HashSet<StoreKeyId>map;bench-experimentsas the benchmark control.Persistence Compatibility
The collector is runtime state and must not become part of persisted snapshots.
SharedPredicateIndextherefore serializes exactly its inner map, preserving the previous serialized shape. During deserialization it:Coverage verifies this behavior through:
utils::Persistencerecovery;Papaya Safety Fix
Benchmarking shared collectors exposed an unsafe Papaya drop path: dropping one map called
Collector::reclaim_all()even when another map sharing that collector still had an active guard.The issue and reproducer are documented in:
The proposed upstream fix is:
Until that fix is merged and released, this PR pins Papaya to the exact reviewed commit:
Performance
Criterion compares the old independent-collector representation against the new per-index representation using the production insertion implementations.
Representative sequential results:
The fixed construction cost increases by approximately 364 ns per predicate index. High-cardinality sequential ingestion improves substantially because it no longer creates an independent collector for every bucket.
Forced parallel high-cardinality insertion remains worse for the candidate:
The benchmark forces these paths for analysis. Production’s current 150k parallel threshold processes the measured 10k and 100k workloads sequentially.
Memory
Memory measurements run each control/candidate case in fresh processes and report the median of three runs.
Populated stores
After deleting store keys
The report also exposes immediate post-drop retention in the candidate’s deferred Papaya table retirement. For example, the unique 100k case retains approximately 225.6 MiB immediately after dropping the store. This is visible in the report for follow-up alongside the upstream reclamation fix.
Benchmark Reporting
Extend the opt-in
benchmark-experimentsworkflow to support two report types:Changed memory targets under
benches/memory/generate Markdown that is appended to the existing update-in-place PR benchmark comment.Validation
-D warnings