Add str::is_char_boundary ASCII successor optimization hint - #161570
briantkelley wants to merge 1 commit into
Conversation
Indexing and splitting `&str` after an ASCII character is a common pattern in parsing or tokenizing a string. Today, if the index or split occurs *after* the ASCII character (e.g., a line feed or a double quote), the operation incurs a runtime character boundary check, which adversely affects runtime performance and increases binary size. This commit enables the optimizer to eliminate that runtime check by adding a hint about a continuation byte's predecessor.
|
Thanks for the pull request, and welcome! The Rust Project has assigned @dingxiangfei2009 (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
r? libs |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…try> Add `str::is_char_boundary` ASCII successor optimization hint
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (95df97f): comparison URL. Overall result: ❌ regressions - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -4.2%, secondary 2.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 4.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.2%, secondary 0.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 468.884s -> 469.334s (0.10%) |
|
these are strong enough results to register as meaningful I think. usually we avoid @rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
Alright, thanks for the feedback. Looks like there are two main follow ups:
|
Indexing and splitting
&strafter an ASCII character is a common pattern in parsing or tokenizing a string.Today, if the index or split occurs after the ASCII character (e.g., a line feed or a double quote), the operation incurs a runtime character boundary check, which adversely affects runtime performance and increases binary size.
This commit enables the optimizer to eliminate that runtime check by adding a hint about a continuation byte's predecessor.