prefix set | size: 10 | `BTreeSet` with `Iterator:any` lookup
crates/trie/common/benches/prefix_set.rs::prefix_set::prefix_set_lookups::Prefix Set Lookups
-2%
3.8 µs3.9 µs
Commits
Click on a commit to change the comparison range
Base
main
2ade18d
+0.13%
perf(trie): add adaptive batching for storage proof results
Problem:
Storage proof workers send one ProofResultMessage per proof through
crossbeam channels. For blocks with many small storage changes (100+
accounts), this creates 100+ individual send/recv syscalls, adding
significant overhead.
Solution:
Implement adaptive batching at the worker level that collects multiple
storage proof jobs based on queue pressure and processes them together.
Changes:
- Add batching constants (MAX_BATCH_SIZE: 32, MIN_QUEUE_FOR_BATCHING: 2)
- Add BatchedProofResults type for batched proof containers
- Implement try_collect_batch_static() for adaptive batch collection
- Modify StorageProofWorker::run() to use batching when beneficial
- Add process_storage_proof_batch() for batch processing
- Preserve individual channels to maintain existing architecture
Batching Strategy:
- Queue depth < 2: Process individually (minimize latency)
- Queue depth 2-32: Batch = queue depth (balanced)
- Queue depth > 32: Batch = 32 (maximize throughput)
- Blinded node requests: Never batch (latency-sensitive)
Expected Impact:
- 70%+ reduction in channel syscalls under high load
- No latency regression for low-load scenarios
- Better CPU cache utilization through sequential processing
Baseline: 100 storage proofs = 200 syscalls (100 sends + 100 recvs)
With batching (avg batch size 4-8): ~30-50 syscalls = 75-85% reduction
f6f41c9
23 hours ago
by yongkangc
+0.12%
fix(trie): address code review issues in proof batching
Fixed critical bugs and issues identified in code review:
1. **Critical: Fix job loss bug for BlindedStorageNode requests**
- Previously, blinded node jobs were silently dropped during batch
collection, causing indefinite hangs
- Now properly includes all job types in batch and separates them
for appropriate processing
2. **Remove unused BatchedProofResults struct**
- Struct was defined but never instantiated or used
- Removed to eliminate dead code and confusion
3. **Fix misleading documentation**
- Clarified that batching optimizes job *processing*, not result sending
- Updated docs to accurately reflect performance benefits:
* Reduced recv() syscalls on work queue
* Better CPU cache locality
* Reduced context switching overhead
- Removed unsubstantiated claims about channel syscall reduction
4. **Improve job handling**
- Worker loop now properly separates storage proofs from blinded nodes
- Storage proofs batched for cache benefits when multiple available
- Blinded node requests always processed individually (latency-sensitive)
5. **Code quality improvements**
- Added accurate inline documentation
- Fixed move-after-use error with job type checking
- Ensured all jobs are processed, never lost
Changes address all issues raised in PR review including:
- Job loss bug (P0)
- Dead code (P1)
- Misleading performance claims (P1)
- Proper mixed job type handling (P1)
All clippy checks pass with -D warnings.
882bea7
16 hours ago
by yongkangc
-0.05%
refactor: simplify proof result batching implementation
Simplifies the batching implementation based on code review feedback:
- Remove unnecessary performance comments from documentation
- Streamline function documentation to focus on behavior
- Fix unused worker_id parameter warning
- Keep code clear and concise
All fmt and clippy checks pass.
46c4bc2
15 hours ago
by yongkangc
-0.24%
fix(trie): address code review issues in proof batching
**Problem:**
Code review identified several issues with the batching implementation:
- Redundant pattern matching (jobs classified by type twice)
- Unnecessary process_storage_proof_batch wrapper function
- Unused worker_id parameter in try_collect_batch_static
**Solution:**
Simplify the implementation by removing redundancy:
- Destructure jobs immediately when separating by type
- Remove process_storage_proof_batch function (just inline the loop)
- Remove unused worker_id parameter
**Changes:**
- Worker loop now destructures jobs in first match, eliminating redundant pattern checks
- Removed 23 lines of dead/redundant code
- Cleaner, more direct implementation
**Expected Impact:**
No functional changes, just cleaner code that's easier to understand and maintain.