Date: 2025-10-24 Goal: Verify that StatePool eliminated State::clone overhead
Top hotspots with State cloning:
| Function | Percentage | Notes |
|---|---|---|
| PathMap edges() | 13.75% | Dictionary edge iteration |
| State::clone | 21.73% | TARGET: State cloning overhead |
| PathMapNode::clone | 6.70% | Dictionary node cloning |
| Position cloning | 7.44% | Position copies |
| Vec allocation | 6.00% | State Vec allocations |
Total State-related overhead: ~21.73% + 7.44% + 6.00% = ~35%
Top hotspots - State::clone GONE:
| Function | Percentage | Notes |
|---|---|---|
| query_children | 26.69% | Query traversal (includes all below) |
| Intersection::clone | 21.23% | PathMapNode cloning in parent box |
| Dictionary edges | ~11.38% | Edge iteration (child_mask checks) |
| transition_state_pooled | 1.49% | Pooled state transitions |
| epsilon_closure_into | 1.26% | In-place epsilon closure |
State::clone is NO LONGER VISIBLE in the profile!
State::clone (21.73%) → Gone ✅
Position cloning (7.44%) → Minimal ✅
Copy (17 bytes)Vec allocation (6.00%) → Gone ✅
Total eliminated: ~35% of runtime overhead!
Intersection::clone (21.23%) - PathMapNode cloning
queue_children (query.rs:99-106)Dictionary edge iteration (~11.38%)
Pooled transitions (~2.75% combined)
transition_state_pooled: 1.49%epsilon_closure_into: 1.26%The profiling verification confirms the benchmark results:
Benchmark Improvements:
Profiling Evidence:
The remaining significant overhead is Intersection::clone (21.23%), which includes:
Potential optimization:
Arc<Vec<u8>> for paths instead of Vec<u8>Trade-off:
StatePool optimization completely eliminated the State cloning bottleneck:
Total reduction: ~35% of runtime overhead eliminated!
The profiling data confirms the benchmark results and validates the StatePool approach. The optimization has been exceptionally successful.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |