Skip to content

Restore simpler Encode/Decode impls for u32 and (on 64bit systems) usize#157182

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
bjorn3:fix_perf_regression
Jun 2, 2026
Merged

Restore simpler Encode/Decode impls for u32 and (on 64bit systems) usize#157182
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
bjorn3:fix_perf_regression

Conversation

@bjorn3
Copy link
Copy Markdown
Member

@bjorn3 bjorn3 commented May 31, 2026

View all comments

This fixes the perf regression in #157076.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 31, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 31, 2026

r? @petrochenkov

rustbot has assigned @petrochenkov.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @petrochenkov

@bjorn3
Copy link
Copy Markdown
Member Author

bjorn3 commented May 31, 2026

@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 May 31, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 31, 2026
Revert "Implement Encode and Decode for proc_macro::TokenStream wrapper type"
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 31, 2026

☀️ Try build successful (CI)
Build commit: a7931ec (a7931ecedd0a736e4d0bb8bf01d3cdc41cc9c59a, parent: c315891193c35827c2d789adce686f8a5481778f)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (a7931ec): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

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

Max RSS (memory usage)

Results (primary 6.6%, secondary -6.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
6.6% [3.4%, 8.5%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.2% [-6.2%, -6.2%] 1
All ❌✅ (primary) 6.6% [3.4%, 8.5%] 4

Cycles

This perf run didn't have relevant results for this metric.

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 509.639s -> 511.772s (0.42%)
Artifact size: 400.69 MiB -> 400.75 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 31, 2026
@bjorn3 bjorn3 force-pushed the fix_perf_regression branch from 6d53fa0 to 69968b9 Compare May 31, 2026 15:11
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 31, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@bjorn3 bjorn3 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 31, 2026
@bjorn3
Copy link
Copy Markdown
Member Author

bjorn3 commented May 31, 2026

@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 May 31, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 31, 2026
Revert "Implement Encode and Decode for proc_macro::TokenStream wrapper type"
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 31, 2026

☀️ Try build successful (CI)
Build commit: 23e5f23 (23e5f230eeb49af7959b165167c00a7d3f38ac9b, parent: 9e293ae9f8abecb0be5105787d181518c9012a19)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (23e5f23): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.6% [-0.9%, -0.3%] 6
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -1.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.2% [2.2%, 2.2%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.3% [-4.3%, -4.3%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.1% [-4.3%, 2.2%] 2

Cycles

Results (primary 2.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

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

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 508.947s -> 512.149s (0.63%)
Artifact size: 400.66 MiB -> 400.68 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 31, 2026
@bjorn3 bjorn3 changed the title Revert "Implement Encode and Decode for proc_macro::TokenStream wrapper type" Revert "Use platform independent encoding for integers in proc-macro RPC" May 31, 2026
@bjorn3
Copy link
Copy Markdown
Member Author

bjorn3 commented May 31, 2026

I'm surprised this didn't get optimized away on 64bit. This commit is required for ensuring 32bit wasm proc-macros encode/decode usize the same way as a 64bit rustc host. Maybe codegening the original code on 64bit and using the new code on 32bit would work? Should also be fine to revert back to the old code for u32.

@bjorn3 bjorn3 force-pushed the fix_perf_regression branch from 69968b9 to 936f0ce Compare June 2, 2026 12:34
@bjorn3
Copy link
Copy Markdown
Member Author

bjorn3 commented Jun 2, 2026

@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 Jun 2, 2026
rust-bors Bot pushed a commit that referenced this pull request Jun 2, 2026
 Revert "Use platform independent encoding for integers in proc-macro RPC"
@rust-bors

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 2, 2026

☀️ Try build successful (CI)
Build commit: f248d0e (f248d0e17bc99781e30fce8a93824a3023e320bc, parent: 4f84d9fac456d973d592cf3fb48db958ecf22506)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (f248d0e): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.6% [-0.9%, -0.3%] 6
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 1.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.9% [2.0%, 6.2%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-5.6% [-5.6%, -5.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.5% [-5.6%, 6.2%] 4

Cycles

Results (primary 2.5%, secondary 12.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.5% [2.5%, 2.5%] 1
Regressions ❌
(secondary)
20.5% [18.9%, 22.0%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.3% [-2.8%, -1.7%] 2
All ❌✅ (primary) 2.5% [2.5%, 2.5%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 510.625s -> 512.605s (0.39%)
Artifact size: 400.75 MiB -> 400.70 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 2, 2026
@bjorn3 bjorn3 changed the title Revert "Use platform independent encoding for integers in proc-macro RPC" Restore simpler Encode/Decode impls for u32 and (on 64bit systems) usize Jun 2, 2026
@bjorn3
Copy link
Copy Markdown
Member Author

bjorn3 commented Jun 2, 2026

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 2, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 2, 2026

📌 Commit 936f0ce has been approved by petrochenkov

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot 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 Jun 2, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 2, 2026
…ochenkov

Restore simpler Encode/Decode impls for u32 and (on 64bit systems) usize

This fixes the perf regression in rust-lang#157076.
rust-bors Bot pushed a commit that referenced this pull request Jun 2, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #157035 (`LivenessValues`: use dedicated enum rather than mutually exclusive `Option`s)
 - #157182 (Restore simpler Encode/Decode impls for u32 and (on 64bit systems) usize)
 - #157310 (rustdoc: Render `impl` restriction)
 - #157070 (Remove `skip_arg` attribute from `Diagnostic` and `Subdiagnostic` proc-macros)
 - #157137 (rustc_target: Use +spe for powerpcspe targets)
 - #157215 (Implement argument-dependent target checking for the `#[repr]` parser)
 - #157235 (additional changes for issue-144595)
 - #157321 (Remove unnecessary arm in `handle_res`)
 - #157324 (Add test for undefined EII static error)
rust-bors Bot pushed a commit that referenced this pull request Jun 2, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #157035 (`LivenessValues`: use dedicated enum rather than mutually exclusive `Option`s)
 - #157182 (Restore simpler Encode/Decode impls for u32 and (on 64bit systems) usize)
 - #157310 (rustdoc: Render `impl` restriction)
 - #157070 (Remove `skip_arg` attribute from `Diagnostic` and `Subdiagnostic` proc-macros)
 - #157137 (rustc_target: Use +spe for powerpcspe targets)
 - #157215 (Implement argument-dependent target checking for the `#[repr]` parser)
 - #157235 (additional changes for issue-144595)
 - #157321 (Remove unnecessary arm in `handle_res`)
 - #157324 (Add test for undefined EII static error)
rust-bors Bot pushed a commit that referenced this pull request Jun 2, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #157035 (`LivenessValues`: use dedicated enum rather than mutually exclusive `Option`s)
 - #157182 (Restore simpler Encode/Decode impls for u32 and (on 64bit systems) usize)
 - #157310 (rustdoc: Render `impl` restriction)
 - #157070 (Remove `skip_arg` attribute from `Diagnostic` and `Subdiagnostic` proc-macros)
 - #157137 (rustc_target: Use +spe for powerpcspe targets)
 - #157215 (Implement argument-dependent target checking for the `#[repr]` parser)
 - #157235 (additional changes for issue-144595)
 - #157321 (Remove unnecessary arm in `handle_res`)
 - #157324 (Add test for undefined EII static error)
@rust-bors rust-bors Bot merged commit 9ca6103 into rust-lang:main Jun 2, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 2, 2026
rust-timer added a commit that referenced this pull request Jun 2, 2026
Rollup merge of #157182 - bjorn3:fix_perf_regression, r=petrochenkov

Restore simpler Encode/Decode impls for u32 and (on 64bit systems) usize

This fixes the perf regression in #157076.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants