Skip to content

Optimize multi-char string patterns #138537

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

Merged
merged 1 commit into from
Mar 16, 2025

Conversation

yotamofek
Copy link
Contributor

Uses specialization for [T]::contains from #130991 to optimize multi-char patterns in string searches.
Requesting a perf run to see if this actually has an effect 🙏
(I think that adding char to the list of types for which the SliceContains is specialized is a good idea, even if it doesn't show up on perf - might be helpful for downstream users)

@rustbot
Copy link
Collaborator

rustbot commented Mar 15, 2025

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 15, 2025
@the8472
Copy link
Member

the8472 commented Mar 15, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 15, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 15, 2025
… r=<try>

Optimize multi-char string patterns

Uses specialization for `[T]::contains` from rust-lang#130991 to optimize multi-char patterns in string searches.
Requesting a perf run to see if this actually has an effect 🙏
(I think that adding `char` to the list of types for which the `SliceContains` is specialized is a good idea, even if it doesn't show up on perf - might be helpful for downstream users)
@bors
Copy link
Collaborator

bors commented Mar 15, 2025

⌛ Trying commit bfe5363 with merge d3e8dbc...

@bors
Copy link
Collaborator

bors commented Mar 15, 2025

☀️ Try build successful - checks-actions
Build commit: d3e8dbc (d3e8dbc76ef84b7c134ebcb6e73fdd3b473a6b7d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d3e8dbc): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.0% [-2.0%, -2.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.0% [-2.0%, -2.0%] 1

Max RSS (memory usage)

Results (primary -4.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.1% [-7.8%, -1.5%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.1% [-7.8%, -1.5%] 3

Cycles

Results (secondary -2.9%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-3.9%, -2.2%] 8
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.0%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.2% [0.1%, 0.2%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-0.6%, 0.2%] 5

Bootstrap: 773.519s -> 774.394s (0.11%)
Artifact size: 365.06 MiB -> 365.07 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 15, 2025
@yotamofek
Copy link
Contributor Author

Huh, nice. Thought it would be neutral at best

@jhpratt
Copy link
Member

jhpratt commented Mar 15, 2025

Looks straightforward to me!

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 15, 2025

📌 Commit bfe5363 has been approved by jhpratt

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 15, 2025
@bors
Copy link
Collaborator

bors commented Mar 16, 2025

⌛ Testing commit bfe5363 with merge 8b87fef...

@bors
Copy link
Collaborator

bors commented Mar 16, 2025

☀️ Test successful - checks-actions
Approved by: jhpratt
Pushing 8b87fef to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 16, 2025
@bors bors merged commit 8b87fef into rust-lang:master Mar 16, 2025
7 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 16, 2025
Copy link

This is an experimental post-merge analysis report. You can ignore it.

Post-merge report

Comparing d497e43 (base) -> 8b87fef (this PR)

Test differences

No test diffs found

@yotamofek yotamofek deleted the pr/lib/multi-char-pattern branch March 16, 2025 18:16
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8b87fef): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (secondary 2.4%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.4%, 2.5%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.0%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.3%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-0.7%, -0.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-0.7%, 0.3%] 5

Bootstrap: 775.874s -> 775.103s (-0.10%)
Artifact size: 365.13 MiB -> 365.12 MiB (-0.00%)

github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Mar 19, 2025
… r=jhpratt

Optimize multi-char string patterns

Uses specialization for `[T]::contains` from rust-lang#130991 to optimize multi-char patterns in string searches.
Requesting a perf run to see if this actually has an effect 🙏
(I think that adding `char` to the list of types for which the `SliceContains` is specialized is a good idea, even if it doesn't show up on perf - might be helpful for downstream users)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants