Date: 2025-10-24 Goal: Verify that Arc<Vec> path sharing eliminated PathMapNode path cloning overhead
Top hotspots with PathMapNode path cloning:
| Function | Percentage | Notes |
|---|---|---|
| query_children | 26.69% | Query traversal (includes all below) |
| Intersection::clone | 21.23% | TARGET: 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 |
Total PathMapNode-related overhead: ~21.23% in Intersection::clone
Top hotspots - PathMapNode path cloning MASSIVELY REDUCED:
| Function | Percentage | Notes |
|---|---|---|
| query_children | 23.21% | Query traversal (reduced from 26.69%) |
| PathMap read_zipper_at_path | 9.62% | Zipper creation (includes path navigation) |
| Intersection::clone | 5.90% | DOWN FROM 21.23% - 72% REDUCTION! |
| Dictionary edges | ~10.48% | Edge iteration (inlined) |
| transition_state_pooled | ~3.05% | Pooled state transitions |
PathMapNode path cloning is NO LONGER SIGNIFICANT in the profile!
PathMapNode path cloning (within Intersection::clone: 21.23%) → 5.90% ✅
Vec allocations for paths → Minimal ✅
Path manipulation overhead → Cheap atomic ops ✅
Total eliminated: ~15 percentage points of Intersection::clone overhead!
Intersection::clone (5.90%) - Remaining overhead
PathMap read_zipper_at_path (9.62%)
Dictionary edge iteration (~10.48%)
The profiling verification confirms the benchmark results:
Benchmark Improvements:
Profiling Evidence:
23.21% query_children
├─ 11.83% dictionary operations
│ ├─ 10.48% edges() (bit mask iteration)
│ └─ 9.93% with_zipper (read lock + zipper creation)
├─ 9.21% transition operations
│ ├─ 3.05% transition_state_pooled
│ ├─ 2.66% epsilon_closure_into
│ └─ 1.89% Box allocations
└─ 5.50% next() iterator
9.62% PathMap::read_zipper_at_path
├─ 6.29% ReadZipperUntracked::new (path navigation)
└─ 3.04% node_along_path (trie traversal)
5.90% Intersection::clone ✅ **DOWN FROM 21.23%!**
├─ 2.87% clone operations
├─ 1.74% term() / collect_path()
├─ 1.08% State::clone (minimal)
└─ 0.56% Option clone
| Component | Phase 5 | Phase 6 | Reduction |
|---|---|---|---|
| Intersection::clone | 21.23% | 5.90% | -72% ✅ |
| query_children (total) | 26.69% | 23.21% | -13% |
| Dictionary edges | ~11.38% | ~10.48% | -8% |
| State operations (pooled) | ~2.75% | ~3.05% | +11% (noise) |
Cheap Clones
Vec::clone: O(n) allocation + memcpyArc::clone: O(1) atomic incrementMemory Sharing
Cache Locality
Small dictionary (+5.5%), exact match (+2.8%) are the only regressions
Root cause:
Trade-off analysis:
Arc<Vec> path optimization exceeded expectations, delivering:
Total cumulative optimization results (Phases 1-6):
Final result: 40-52% faster than baseline across all major workloads!
The profiling data confirms the benchmark results and validates the Arc path sharing 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 |