Skip to content

Conversation

@yannham
Copy link
Member

@yannham yannham commented Nov 28, 2025

This slightly optimizes the label representation, by using (smaller) PosIdx instead of TermPos, and a combination of Vec, SmallVec, and Vector, that was found by experimentation, trying to optimize first for runtime but also for memory consumption. On the OPL benchmark the change seems to have a very small time improvement, but does at least win a few noticeable % of leaked memory.

It was tempting to use only copy-on-write structures, such as a thin Rc<[T]> or Vector everywhere (but the latter is bigger). It turns that after measuring many label operations do succeed in taking their content mutably with content_make_mut (the operators pushing an element to the path, or a diagnostic for example), around a surprising 50%. On the other hand, some other mutable label operations do not currently try to take a mutable reference to the label, typically path operations. There, trying to take the label mutably shows that 0% of them succeeds... So for some reason, although I believe it's by accident, the current choices of when should we try to take unique access to a label in eval::operation sounds rather adapted. The data structure were chosen in consequence.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

🐰 Bencher Report

Branchperf/label-repr
Testbedubuntu-latest
Click to view all benchmark results
BenchmarkLatencymicroseconds (µs)
diagnostics-benches/inputs/goto-perf.ncl📈 view plot
🚷 view threshold
10,091.00 µs
diagnostics-benches/inputs/large-record-tree.ncl📈 view plot
🚷 view threshold
187,100.00 µs
diagnostics-benches/inputs/redis-replication-controller.ncl📈 view plot
🚷 view threshold
302.24 µs
diagnostics-benches/inputs/small-record-tree.ncl📈 view plot
🚷 view threshold
430.79 µs
fibonacci 10📈 view plot
🚷 view threshold
219.88 µs
foldl arrays 50📈 view plot
🚷 view threshold
457.01 µs
foldl arrays 500📈 view plot
🚷 view threshold
2,749.80 µs
foldr strings 50📈 view plot
🚷 view threshold
3,164.60 µs
foldr strings 500📈 view plot
🚷 view threshold
28,938.00 µs
generate normal 250📈 view plot
🚷 view threshold
15,600.00 µs
generate normal 50📈 view plot
🚷 view threshold
1,058.90 µs
generate normal unchecked 1000📈 view plot
🚷 view threshold
2,007.50 µs
generate normal unchecked 200📈 view plot
🚷 view threshold
387.37 µs
init-diagnostics-benches/inputs/goto-perf.ncl📈 view plot
🚷 view threshold
52,036.00 µs
init-diagnostics-benches/inputs/large-record-tree.ncl📈 view plot
🚷 view threshold
206,600.00 µs
init-diagnostics-benches/inputs/redis-replication-controller.ncl📈 view plot
🚷 view threshold
46,988.00 µs
init-diagnostics-benches/inputs/small-record-tree.ncl📈 view plot
🚷 view threshold
47,016.00 µs
pidigits 100📈 view plot
🚷 view threshold
1,897.00 µs
pipe normal 20📈 view plot
🚷 view threshold
674.85 µs
pipe normal 200📈 view plot
🚷 view threshold
4,531.70 µs
product 30📈 view plot
🚷 view threshold
341.06 µs
requests-benches/inputs/goto-perf.ncl-000📈 view plot
🚷 view threshold
3,002.60 µs
requests-benches/inputs/large-record-tree.ncl-000📈 view plot
🚷 view threshold
581,170.00 µs
requests-benches/inputs/large-record-tree.ncl-001📈 view plot
🚷 view threshold
88.00 µs
scalar 10📈 view plot
🚷 view threshold
597.40 µs
sum 30📈 view plot
🚷 view threshold
343.22 µs
🐰 View full continuous benchmarking report in Bencher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants