locale, factor, shuf: Example of deferred locale loading for clap#10911
locale, factor, shuf: Example of deferred locale loading for clap#10911ChrisDryden wants to merge 3 commits intouutils:mainfrom
Conversation
|
Whoops didn't realize, uudoc calls uuapp directly, should be a simple fix to swap the names of the two uuapp functions and it should work backwards compatible. Just waiting to see the perf numbers and the gnu test results |
|
GNU testsuite comparison: |
Merging this PR will degrade performance by 4.94%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | wc_bytes_synthetic[500] |
194.7 µs | 86.9 µs | ×2.2 |
| ⚡ | Simulation | wc_chars_large_line_count[100000] |
1,023 µs | 912.4 µs | +12.12% |
| ⚡ | Simulation | wc_lines_variable_length[(50, 500)] |
3.5 ms | 3.3 ms | +3.19% |
| ⚡ | Simulation | wc_lines_extreme_line_lengths[(100000, 200)] |
1.6 ms | 1.5 ms | +6.32% |
| ⚡ | Simulation | wc_lines_large_line_count[500000] |
2.9 ms | 2.8 ms | +3.94% |
| ⚡ | Simulation | b64_decode_synthetic |
171.7 µs | 60.1 µs | ×2.9 |
| ⚡ | Simulation | b64_decode_ignore_garbage_synthetic |
168.7 µs | 62 µs | ×2.7 |
| ⚡ | Simulation | b64_encode_synthetic |
167.7 µs | 58.6 µs | ×2.9 |
| ⚡ | Simulation | cksum_blake3 |
216.9 µs | 113.3 µs | +91.43% |
| ❌ | Simulation | sort_ascii_c_locale |
18.2 ms | 18.8 ms | -3.16% |
| ⚡ | Simulation | sort_ascii_utf8_locale |
18 ms | 17.2 ms | +4.47% |
| ⚡ | Simulation | sort_long_line[160000] |
1.4 ms | 1.3 ms | +6.8% |
| ⚡ | Memory | b64_decode_synthetic |
46.2 KB | 12.1 KB | ×3.8 |
| ⚡ | Memory | b64_encode_synthetic |
46.2 KB | 8.6 KB | ×5.4 |
| ⚡ | Memory | b64_decode_ignore_garbage_synthetic |
46.2 KB | 12.1 KB | ×3.8 |
| ⚡ | Memory | file_tz_abbreviations |
333.4 KB | 288.4 KB | +15.59% |
| ⚡ | Memory | complex_relative_date |
46.1 KB | 16.9 KB | ×2.7 |
| ⚡ | Memory | single_date_now |
46.1 KB | 15.6 KB | ×3 |
| ⚡ | Memory | file_custom_format |
46.2 KB | 20.1 KB | ×2.3 |
| ⚡ | Memory | file_iso_dates |
46.2 KB | 19.5 KB | ×2.4 |
| ... | ... | ... | ... | ... | ... |
ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.
Comparing ChrisDryden:deferred-locale-loading (7e70533) with main (dec633c)
Footnotes
-
38 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. ↩
|
This should also unblock us from doing translations in all of the shared libraries because there will no longer be the performance penalty hit from adding a bunch of translations into the shared locale file |
|
GNU testsuite comparison: |
| /// .help_template(localized_help_template("myutil")); | ||
| /// ``` | ||
| pub fn localized_help_template(util_name: &str) -> clap::builder::StyledStr { | ||
| pub fn localized_help_template(_util_name: &str) -> clap::builder::StyledStr { |
There was a problem hiding this comment.
maybe remove _util_name if we don't use it anymore?
| let name = cmd.get_name().to_string(); | ||
|
|
||
| cmd = cmd | ||
| .about(crate::locale::get_message(&format!("{name}-about"))) |
There was a problem hiding this comment.
i wonder if we follow the same standard everywhere ?
|
Hi ! I've also tried to work a bit on the localization system and your defer implementation is really game changer. I just have a few remarks :
|
|
Would you add |
|
@ChrisDryden I'm really sorry if that's impolite, but it seems that you're not working on this and the defer feature would help me a lot and, if you're okay, I would gladly do the implementation and submit a PR. |
|
No worries please go ahead |
|
ANy chance to do this with ~20 lines diff? |
|
@oech3 For each commit or the whole PR ? If it's for the whole PR, that seems impossible with the whole refactor of the locale init system... |
I see. |
|
@oech3 @ChrisDryden Hi, I said I would work on this feature but I was not able to work on it and would be able to work untile the 12th-15th of march. I'm letting you know just in case someone else want to work on it. Really sorry about it, have a nice day ! NB : @oech3 I've looked around a bit and I think that we can divide the PR in 2. The first one should defer the setup of the Localizer to the first one to call |
|
@oech3 @ChrisDryden I'm really sorry but my health is getting worse. I will not be able to program for an (probably very long) indefinite amount of time. Wishing you all the best. |
|
If I am undrstanding correctly, separating |
A few month ago I attempted the same thing but now I've got a much better understanding of the project to attempt it again. The change here is that there is a parse_deferred handler now that attempts to parse the clap arguments and it it fails it will reattempt it with the locale files loaded. This combined with changes in the default locale initialization to take the util_name at the beginning from the arguments allows us to not have to load the locale file until the translation is actually required.
This requires migrating each utility to this new format, but I already started the process for factor and shuf to start.
This change is also required for the
ls/stat-free-symlinkgnu test and it should make the valgrind tests much more stable since it runs twice as fast in local testing and less likely to timeout.