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

Rewrite MemDecoder around pointers not a slice #110634

Merged
merged 1 commit into from
Apr 26, 2023

Conversation

saethlin
Copy link
Member

@saethlin saethlin commented Apr 21, 2023

This is basically #109910 but I'm being a lot more aggressive. The pointer-based structure means that it makes a lot more sense to absorb more complexity into MemDecoder, most of the diff is just complexity moving from one place to another.

The primary argument for this structure is that we only incur a single bounds check when doing multi-byte reads from a MemDecoder. With the slice-based implementation we need to do those with data[position..position + len] , which needs to account for position + len wrapping. It would be possible to dodge the first bounds check if we stored a slice that starts at position, but that would require updating the pointer and length on every read.

This PR also embeds the failure path in a separate function, which means that this PR should subsume all the perf wins observed in #109867.

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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. labels Apr 21, 2023
@saethlin
Copy link
Member Author

@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 21, 2023
@bors
Copy link
Contributor

bors commented Apr 21, 2023

⌛ Trying commit 708c71bc9fed44627872cff4d24018b17905f0fa with merge ea67749271a3bfca6996cc4b8becfa7a0591f9ab...

@bors
Copy link
Contributor

bors commented Apr 21, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ea67749271a3bfca6996cc4b8becfa7a0591f9ab): 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 a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-0.7%, -0.3%] 41
Improvements ✅
(secondary)
-0.5% [-0.6%, -0.2%] 10
All ❌✅ (primary) -0.5% [-0.7%, -0.3%] 41

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)
- - 0
Regressions ❌
(secondary)
2.2% [2.2%, 2.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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)
- - 0
Regressions ❌
(secondary)
2.7% [2.6%, 2.8%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 21, 2023
@saethlin saethlin force-pushed the pointy-decoder branch 2 times, most recently from 3d25012 to 2995eb3 Compare April 22, 2023 02:45
@saethlin
Copy link
Member Author

@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 22, 2023
@bors
Copy link
Contributor

bors commented Apr 22, 2023

⌛ Trying commit 2995eb38309270f12efb8a8d43ba82cf6fdb4000 with merge 441c638841629089f54e4aa6da3960f27bbfac6d...

@bors
Copy link
Contributor

bors commented Apr 22, 2023

☀️ Try build successful - checks-actions
Build commit: 441c638841629089f54e4aa6da3960f27bbfac6d (441c638841629089f54e4aa6da3960f27bbfac6d)

1 similar comment
@bors
Copy link
Contributor

bors commented Apr 22, 2023

☀️ Try build successful - checks-actions
Build commit: 441c638841629089f54e4aa6da3960f27bbfac6d (441c638841629089f54e4aa6da3960f27bbfac6d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (441c638841629089f54e4aa6da3960f27bbfac6d): 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 a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.6%, -0.3%] 33
Improvements ✅
(secondary)
-0.4% [-0.5%, -0.3%] 7
All ❌✅ (primary) -0.4% [-0.6%, -0.3%] 33

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)
- - 0
Regressions ❌
(secondary)
2.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) - - 0

Cycles

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

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 22, 2023
@saethlin saethlin assigned scottmcm and unassigned scottmcm Apr 23, 2023
@saethlin
Copy link
Member Author

r? compiler

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

bors commented Apr 24, 2023

⌛ Testing commit 1f67ba6 with merge f5d087af3c1f1f1cd92ce34419bd874002eca742...

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Apr 24, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 24, 2023
@cjgillot
Copy link
Contributor

@bors retry

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

bors commented Apr 24, 2023

⌛ Testing commit 1f67ba6 with merge 9abd3bce4eec20d550601dbfd2f024f5e896f635...

@bors
Copy link
Contributor

bors commented Apr 24, 2023

💔 Test failed - checks-actions

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

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:8e5e7e5ab8b370d6c329ec480221332ada57f0ab)
##[warning]Failed to download action 'https://api.github.com/repos/actions/checkout/tarball/8e5e7e5ab8b370d6c329ec480221332ada57f0ab'. Error: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.
##[warning]Back off 18.465 seconds before retry.
##[warning]Failed to download action 'https://api.github.com/repos/actions/checkout/tarball/8e5e7e5ab8b370d6c329ec480221332ada57f0ab'. Error: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.
##[warning]Back off 26.406 seconds before retry.
##[error]The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.

@compiler-errors
Copy link
Member

@bors retry

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

bors commented Apr 26, 2023

⌛ Testing commit 1f67ba6 with merge adaac6b...

@bors
Copy link
Contributor

bors commented Apr 26, 2023

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing adaac6b to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 26, 2023
@bors bors merged commit adaac6b into rust-lang:master Apr 26, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 26, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (adaac6b): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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.4% [0.4%, 0.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-0.7%, -0.3%] 52
Improvements ✅
(secondary)
-0.5% [-0.8%, -0.3%] 16
All ❌✅ (primary) -0.4% [-0.7%, 0.4%] 53

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)
- - 0
Regressions ❌
(secondary)
1.9% [0.7%, 3.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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)
0.6% [0.6%, 0.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-10.2% [-11.7%, -4.6%] 7
All ❌✅ (primary) 0.6% [0.6%, 0.6%] 1

@saethlin saethlin deleted the pointy-decoder branch April 28, 2023 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants