Skip to content

clippy: warn for large_stack_arrays lint#11868

Open
xtqqczze wants to merge 2 commits intouutils:mainfrom
xtqqczze:clippy/large_stack_arrays
Open

clippy: warn for large_stack_arrays lint#11868
xtqqczze wants to merge 2 commits intouutils:mainfrom
xtqqczze:clippy/large_stack_arrays

Conversation

@xtqqczze
Copy link
Copy Markdown
Contributor

@xtqqczze xtqqczze commented Apr 16, 2026

Set array-size-threshold to ~64 KiB. This is relatively large, but matches existing usage in some areas.

CodSpeed results are not reliable due to the absence of syscall measurement. In local benchmarks using hyperfine, a ~1% regression was observed: #11868 (comment).

https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#large_stack_arrays

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 16, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/pr/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/symlink (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/rm/isatty (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.
Congrats! The gnu test tests/expand/bounded-memory is now passing!
Congrats! The gnu test tests/seq/seq-epipe is now passing!
Congrats! The gnu test tests/tail/pipe-f is now passing!
Note: The gnu test tests/env/env-signal-handler was skipped on 'main' but is now failing.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 16, 2026

Merging this PR will improve performance by 27.43%

⚡ 4 improved benchmarks
✅ 305 untouched benchmarks
⏩ 46 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation wc_chars_large_line_count[100000] 908.4 µs 712.9 µs +27.43%
Simulation wc_lines_variable_length[(50, 500)] 3.3 ms 3.2 ms +5.66%
Simulation wc_lines_large_line_count[500000] 2.8 ms 2.6 ms +7%
Simulation wc_lines_extreme_line_lengths[(100000, 200)] 1.6 ms 1.4 ms +13.41%

Comparing xtqqczze:clippy/large_stack_arrays (e9cb33d) with main (01b7177)

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.

@xtqqczze xtqqczze mentioned this pull request Apr 16, 2026
@xtqqczze xtqqczze force-pushed the clippy/large_stack_arrays branch from 4edfb02 to 10bb935 Compare April 16, 2026 21:28
@xtqqczze xtqqczze marked this pull request as draft April 16, 2026 21:29
@xtqqczze xtqqczze force-pushed the clippy/large_stack_arrays branch from 10bb935 to 5a39ee5 Compare April 16, 2026 21:31
@xtqqczze
Copy link
Copy Markdown
Contributor Author

xtqqczze commented Apr 16, 2026

⚡ Simulation wc_chars_large_line_count[100000] 913.3 µs 713.7 µs +27.97%
⚡ Simulation wc_bytes_synthetic[500] 86.1 µs 82.4 µs +4.56%
⚡ Simulation wc_lines_extreme_line_lengths[(100000, 200)] 1.6 ms 1.4 ms +13.72%
⚡ Simulation wc_lines_variable_length[(50, 500)] 3.3 ms 3.2 ms +5.79%
⚡ Simulation wc_bytes_synthetic[1] 86.7 µs 82.9 µs +4.6%
⚡ Simulation wc_lines_large_line_count[500000] 2.8 ms 2.6 ms +7.15%

@drinkcat Interesting that we see improvements for wc when decreasing buffer size from 256 KiB to 64 KiB, after it was increased in #7934.

@drinkcat
Copy link
Copy Markdown
Collaborator

⚡ Simulation wc_chars_large_line_count[100000] 913.3 µs 713.7 µs +27.97%
⚡ Simulation wc_bytes_synthetic[500] 86.1 µs 82.4 µs +4.56%
⚡ Simulation wc_lines_extreme_line_lengths[(100000, 200)] 1.6 ms 1.4 ms +13.72%
⚡ Simulation wc_lines_variable_length[(50, 500)] 3.3 ms 3.2 ms +5.79%
⚡ Simulation wc_bytes_synthetic[1] 86.7 µs 82.9 µs +4.6%
⚡ Simulation wc_lines_large_line_count[500000] 2.8 ms 2.6 ms +7.15%

@drinkcat Interesting that we see improvements for wc when decreasing buffer size from 256 KiB to 64 KiB, after it was increased in #7934.

I see this when clicking the links, not sure to understand how the simulation environment works (I haven't contributed to coreutils in a... while):

  • This benchmark shows a significant performance change and was compared across different runtime environments. Results may be affected.
  • AMD EPYC 9V74 80-Core Processor→ AMD EPYC 7763 64-Core Processor

I'd be curious to see numbers on real hardware if this is a simulation, the fact that syscalls are not modeled is a concern too: the main advantage of a larger buffer should be reduced system calls.

@oech3
Copy link
Copy Markdown
Contributor

oech3 commented Apr 17, 2026

Is it easy to change config? Tere is a warning about syscalls:

This benchmark contains * system calls, totalling * of execution time. Since they cannot be consistently instrumented, those calls are not included in the measure. Please switch to the Walltime instrument to accurately measure system calls. Learn more about measurement and system calls.

@xtqqczze xtqqczze force-pushed the clippy/large_stack_arrays branch 2 times, most recently from 5c989de to b55bfc5 Compare April 18, 2026 17:40
@xtqqczze
Copy link
Copy Markdown
Contributor Author

@oech3 I did see small ~1% regression locally (but statistical outliers were detected as I don't have taskset available):

$ seq 10000000000000 1 inf | head -n 100000000 > seq100M
$ cargo build -r -p uu_wc && hyperfine --warmup 10 -L wc ./wc.main,target/release/wc "{wc} -l seq100M"

@xtqqczze xtqqczze force-pushed the clippy/large_stack_arrays branch 2 times, most recently from 0419264 to bd96bbd Compare April 18, 2026 18:03
@xtqqczze xtqqczze force-pushed the clippy/large_stack_arrays branch from bd96bbd to e9cb33d Compare April 18, 2026 20:07
@xtqqczze
Copy link
Copy Markdown
Contributor Author

@drinkcat CodSpeed still reports a significant performance difference even with a consistent runtime environment. However, the size of the improvement doesn’t seem credible, so I think you’re right that CodSpeed is likely flawed due to not modeling syscalls.

@xtqqczze
Copy link
Copy Markdown
Contributor Author

xtqqczze commented Apr 18, 2026

⚡ Simulation wc_chars_large_line_count[100000] 908.4 µs 712.9 µs +27.43%

@oech3 This benchmark had 139 system calls with e9cb33d but only 41 before, so the reported 27.43% improvement is not meaningful due to missing instrumentation.

@xtqqczze xtqqczze marked this pull request as ready for review April 18, 2026 20:53
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