Skip to content
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 some targeted assume(bytes <= isize::MAX) around slices #123575

Closed
wants to merge 1 commit into from

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Apr 6, 2024

Putting it on every single slice length was pretty expensive, but let's see if doing it just in slice::from_raw_parts(_mut) and slice::Iter(Mut)::len works better.

@rustbot
Copy link
Collaborator

rustbot commented Apr 6, 2024

r? @joboet

rustbot has assigned @joboet.
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 6, 2024
);
intrinsics::assume(len <= T::MAX_SLICE_LEN);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this was already assert_unsafe_preconditioned, might as well assume it too.

(Not using assert_unchecked because it doesn't need a second UbCheck.)

@scottmcm
Copy link
Member Author

scottmcm commented Apr 6, 2024

@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 Apr 6, 2024
@bors
Copy link
Contributor

bors commented Apr 6, 2024

⌛ Trying commit 2be8c36 with merge a4009ef...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2024
Add some targeted `assume(bytes <= isize::MAX)` around slices

Putting it on every single slice length was pretty expensive, but let's see if doing it just in `slice::from_raw_parts(_mut)` and `slice::Iter(Mut)::len` works better.
@bors
Copy link
Contributor

bors commented Apr 7, 2024

☀️ Try build successful - checks-actions
Build commit: a4009ef (a4009ef679b4340bef4d86f8c96d4135102cca59)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a4009ef): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.7% [0.1%, 3.4%] 130
Regressions ❌
(secondary)
0.4% [0.2%, 1.2%] 53
Improvements ✅
(primary)
-1.5% [-4.1%, -0.2%] 3
Improvements ✅
(secondary)
-0.8% [-1.7%, -0.2%] 11
All ❌✅ (primary) 0.6% [-4.1%, 3.4%] 133

Max RSS (memory usage)

Results

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)
3.7% [2.1%, 5.3%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.4% [-3.2%, -1.6%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.3% [-3.2%, 5.3%] 5

Cycles

Results

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)
1.9% [0.8%, 2.9%] 21
Regressions ❌
(secondary)
1.0% [1.0%, 1.0%] 1
Improvements ✅
(primary)
-4.3% [-4.3%, -4.3%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.6% [-4.3%, 2.9%] 22

Binary size

Results

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.0%, 0.8%] 11
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.3%, -0.0%] 46
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.0%] 5
All ❌✅ (primary) -0.0% [-0.3%, 0.8%] 57

Bootstrap: 670.181s -> 676.772s (0.98%)
Artifact size: 318.20 MiB -> 318.14 MiB (-0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 7, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 7, 2024
…ed, r=<try>

Have `offset_from_unsigned` assume the `isize::MAX` restriction

Split off from rust-lang#123575; hopefully this won't be as perf-painful.

(Notably it doesn't change MIR, so hopefully can't affect check/debug.)
Putting it on every single slice length was pretty expensive, but let's see if doing it just in `slice::from_raw_parts(_mut)` and `slice::Iter(Mut)::len` works better.
@scottmcm
Copy link
Member Author

scottmcm commented Apr 7, 2024

Split off half of it over to #123598; let's see just this bit.

@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 Apr 7, 2024
@bors
Copy link
Contributor

bors commented Apr 7, 2024

⌛ Trying commit 5c95280 with merge ada8fc8...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 7, 2024
Add some targeted `assume(bytes <= isize::MAX)` around slices

Putting it on every single slice length was pretty expensive, but let's see if doing it just in `slice::from_raw_parts(_mut)` ~~and `slice::Iter(Mut)::len`~~ works better.
@bors
Copy link
Contributor

bors commented Apr 7, 2024

☀️ Try build successful - checks-actions
Build commit: ada8fc8 (ada8fc8c65b4d8b6834976d9cff03e93d277a713)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ada8fc8): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.6% [0.2%, 3.3%] 141
Regressions ❌
(secondary)
0.4% [0.2%, 1.1%] 45
Improvements ✅
(primary)
-4.2% [-4.2%, -4.2%] 1
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.2%] 2
All ❌✅ (primary) 0.6% [-4.2%, 3.3%] 142

Max RSS (memory usage)

Results

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)
2.7% [2.2%, 3.0%] 4
Regressions ❌
(secondary)
2.6% [2.1%, 3.2%] 10
Improvements ✅
(primary)
-6.9% [-6.9%, -6.9%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.8% [-6.9%, 3.0%] 5

Cycles

Results

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)
2.1% [1.1%, 3.1%] 16
Regressions ❌
(secondary)
5.9% [1.1%, 10.7%] 2
Improvements ✅
(primary)
-4.1% [-4.1%, -4.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.7% [-4.1%, 3.1%] 17

Binary size

Results

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.1% [0.0%, 0.3%] 15
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.3%, -0.0%] 41
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.0%] 5
All ❌✅ (primary) -0.0% [-0.3%, 0.3%] 56

Bootstrap: 667.449s -> 673.747s (0.94%)
Artifact size: 318.47 MiB -> 318.41 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 7, 2024
@scottmcm
Copy link
Member Author

scottmcm commented Apr 7, 2024

Wow, even worse. Clearly we can't do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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.

5 participants