perf(uucore): call rt_sigaction once not 62 times#11350
Open
danielzgtg wants to merge 1 commit intouutils:mainfrom
Open
perf(uucore): call rt_sigaction once not 62 times#11350danielzgtg wants to merge 1 commit intouutils:mainfrom
danielzgtg wants to merge 1 commit intouutils:mainfrom
Conversation
Contributor
|
please run hyperfine this way: in release mode |
Contributor
|
(nice finding btw) |
Contributor
Author
home@daniel-desktop3:~/CLionProjects$ git -C with_the_change rev-parse HEAD
53b5d127c811027dff3f107950046d5b186dd9f1
home@daniel-desktop3:~/CLionProjects$ git -C without_the_change rev-parse HEAD
0f891cc66f5bee12ed3217000afd6ac4c07247aa
home@daniel-desktop3:~/CLionProjects$ hyperfine without_the_change/target/release/coreutils with_the_change/target/release/coreutils
Benchmark 1: without_the_change/target/release/coreutils
Time (mean ± σ): 1.5 ms ± 0.2 ms [User: 0.5 ms, System: 1.1 ms]
Range (min … max): 1.2 ms … 2.7 ms 1238 runs
Warning: Command took less than 5 ms to complete. Note that the results might be inaccurate because hyperfine can not calibrate the shell startup time much more precise than this limit. You can try to use the `-N`/`--shell=none` option to disable the shell completely.
Benchmark 2: with_the_change/target/release/coreutils
Time (mean ± σ): 1.4 ms ± 0.2 ms [User: 0.4 ms, System: 1.1 ms]
Range (min … max): 1.1 ms … 2.2 ms 1407 runs
Warning: Command took less than 5 ms to complete. Note that the results might be inaccurate because hyperfine can not calibrate the shell startup time much more precise than this limit. You can try to use the `-N`/`--shell=none` option to disable the shell completely.
Summary
with_the_change/target/release/coreutils ran
1.11 ± 0.17 times faster than without_the_change/target/release/coreutils |
|
GNU testsuite comparison: |
Contributor
|
Interesting. btw, we have fluent parse in the thread too. |
oech3
reviewed
Mar 16, 2026
`./coreutils true` becomes 6% faster. For some unknown reason, `capture_startup_state` runs 62 times, so I'll just hotfix it to immediately return from the second time onwards. When 2d7a3bf introduced the fcntl calls, each group of 3 calls was repeated 4 times. Some time later, it became 62 times. Now it runs only 1 time.
53b5d12 to
30871aa
Compare
|
GNU testsuite comparison: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
./coreutils truebecomes 6% faster. For some unknown reason,capture_startup_stateruns 62 times, so I'll just hotfix it to immediately return from the second time onwards.When 2d7a3bf introduced the fcntl calls, each group of 3 calls was repeated 4 times. Some time later, it became 62 times. Now it runs only 1 time.
Before
After
Alternative
For comparison, omitting the new AtomicBool and instead moving the block containing the fcntl into the conditional below wouldn't improve things that much:
Someone can also attempt to optimize by replacing
fctnlwithpolllike Rust's stdlib, but I don't think the bottleneck remains here after fixing the repetition.