-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add unicode fast path to is_printable
#97526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unicode fast path to is_printable
#97526
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
(rust-highfive has picked a reviewer for you, use r? to override) |
4d16044
to
4b97628
Compare
I've added a new benchmark and ran it and an existing one locally, the results are promising. ( It appears to be slightly slower for non-ascii, and a lot faster for ascii.
|
d638586
to
1edac2d
Compare
Since the conditional is needed anyway, would it be worth returning false in the < 32 case, to include that in the fast path? |
Before, it would enter the full expensive check even for normal ascii characters. Now, it skips the check for the ascii characters in `32..127`. This range was checked manually from the current behavior.
1edac2d
to
3358a41
Compare
Huh, I changed this locally but forgot to commit it. |
@bors r+ rollup=never |
📌 Commit 3358a41 has been approved by |
@bors rollup=never |
☀️ Test successful - checks-actions |
Finished benchmarking commit (dcbd5f5): comparison url. Instruction count
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
Before, it would enter the full expensive check even for normal ascii characters. Now, it skips the check for the ascii characters in
32..127
. This range was checked manually from the current behavior.I ran the
tracing
test suite in miri, and it was really slow. I looked at a profile, and miri spent most of the time incore::char::methods::escape_debug_ext
, where half of that was dominated bycore::unicode::printable::is_printable
. So I optimized it here.The tracing profile:
