perf: avoid double Arc allocation in add_source_and_content#288
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merging this PR will degrade performance by 4.64%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | build_single |
6.5 µs | 6.4 µs | +1.73% |
| ⚡ | add_sourcemap_loop |
20.9 µs | 20.1 µs | +4.13% |
| ❌ | serialize[real_small] |
4.2 µs | 4.4 µs | -4.62% |
| ❌ | serialize[real_large] |
20.1 µs | 20.3 µs | -1.01% |
| ⚡ | lookup_table[real_small] |
1.4 µs | 1.4 µs | +2.13% |
| ⚡ | lookup_table[real_medium] |
1.5 µs | 1.5 µs | +1.97% |
| ❌ | serialize[real_medium] |
4.8 µs | 5 µs | -4.64% |
Comparing fix/avoid-double-arc-in-add-source-and-content (6797349) with main (59d8044)2
Footnotes
-
5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
main(1548e7b) during the generation of this report, so 59d8044 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
Summary
add_source_and_contentpreviously created twoArc<str>allocations when a new source was added — one viaentry(source.into())and another viaself.sources.push(source.into()).getfirst to avoid any allocation on the duplicate-hit path, then create a singleArcand clone it for the map — matching the pattern already used inadd_name.🤖 Generated with Claude Code