Skip to content

unexpand: save stack size - perf +6.98%#11787

Open
oech3 wants to merge 1 commit intouutils:mainfrom
oech3:unexpand-stack
Open

unexpand: save stack size - perf +6.98%#11787
oech3 wants to merge 1 commit intouutils:mainfrom
oech3:unexpand-stack

Conversation

@oech3
Copy link
Copy Markdown
Contributor

@oech3 oech3 commented Apr 13, 2026

Replace a stack array with vec to avoid stack spill seen at rust-lang/rust#148670 .

Probally fixes #10654

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 13, 2026

Merging this PR will improve performance by 6.98%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
✅ 307 untouched benchmarks
⏩ 46 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation unexpand_many_lines[100000] 145.8 ms 136.3 ms +6.97%
Simulation unexpand_large_file[10] 305.6 ms 285.6 ms +6.98%

Comparing oech3:unexpand-stack (eda5aed) with main (44aff6b)

Open in CodSpeed

Footnotes

  1. 46 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.

@oech3

This comment was marked as outdated.

@oech3 oech3 force-pushed the unexpand-stack branch 2 times, most recently from 628fe47 to e6c1c8f Compare April 13, 2026 06:11
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/misc/io-errors. tests/misc/io-errors is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/seq/seq-epipe is now being skipped but was previously passing.
Congrats! The gnu test tests/tail/tail-n0f is now passing!

@oech3 oech3 changed the title unexpand: save stack size unexpand: save stack size - perf +6.98% Apr 13, 2026
@oech3 oech3 marked this pull request as ready for review April 13, 2026 06:36
@sylvestre
Copy link
Copy Markdown
Contributor

i wasn't expecting such wins for this kind of changes

@xtqqczze
Copy link
Copy Markdown
Contributor

I don't understand why changing stack allocation to heap allocation is a performance improvement. Additionally, it may be possible that this isn't an improvement on targets other than x86_64-unknown-linux-gnu.

@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Apr 13, 2026

I'm OK to have cfg block.

@xtqqczze
Copy link
Copy Markdown
Contributor

It would be good to understand why there is a performance difference; if necessary this could be reported upstream.

@oech3
Copy link
Copy Markdown
Contributor Author

oech3 commented Apr 13, 2026

done at rust-lang/rust#148670

@xtqqczze
Copy link
Copy Markdown
Contributor

done at rust-lang/rust#148670

Please add a comment linking to this issue; it would also have been helpful to include it in the PR description.

@xtqqczze
Copy link
Copy Markdown
Contributor

I guess it would be good to explain in the comment that the regression is specifically with codegen-units=1 + LTO.

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/timeout/timeout-group. tests/timeout/timeout-group is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/expand/bounded-memory is now passing!

@xtqqczze
Copy link
Copy Markdown
Contributor

I'm OK to have cfg block.

Like efd0f0c, or just x86_64-unknown-linux-gnu?

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.

unexpand: Performance regression with codegen-units=1

3 participants