Skip to content

Try to make FieldDef smaller#157986

Open
panstromek wants to merge 1 commit into
rust-lang:mainfrom
panstromek:make-field-def-smaller
Open

Try to make FieldDef smaller#157986
panstromek wants to merge 1 commit into
rust-lang:mainfrom
panstromek:make-field-def-smaller

Conversation

@panstromek

@panstromek panstromek commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

View all comments

Tries to mitigate the regression from #156824. We do this by Option Boxing together all the properties that are only used for unstable features.

fixes #157003

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. labels Jun 16, 2026
@panstromek

Copy link
Copy Markdown
Contributor 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 Jun 16, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 16, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 289b567 (289b567a59d12dd1f7712d6ff110fbd73a56766d, parent: 89a99936d9e76a50e8df622e7242190841fd871b)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (289b567): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@bors rollup=never
@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.2% [-0.4%, -0.2%] 10
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.1%] 7
All ❌✅ (primary) -0.2% [-0.4%, -0.2%] 10

Max RSS (memory usage)

Results (primary 6.4%, secondary 2.0%)

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

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

Cycles

Results (primary 1.4%, secondary 4.9%)

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

mean range count
Regressions ❌
(primary)
1.4% [1.4%, 1.4%] 1
Regressions ❌
(secondary)
4.9% [2.8%, 7.6%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.4% [1.4%, 1.4%] 1

Binary size

Results (primary -0.0%)

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

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

Bootstrap: 522.035s -> 522.066s (0.01%)
Artifact size: 401.81 MiB -> 401.82 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 16, 2026
@rust-bors

This comment has been minimized.

Comment thread compiler/rustc_ast/src/ast.rs Outdated
Comment thread compiler/rustc_ast/src/ast.rs Outdated
@panstromek

panstromek commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

I'll undraft this for preliminary review, because I want to get some second opinion. This helps to mitigate the perf regression, but feels somewhat arbitrary/ad-hoc to me? I'm not sure if this is the right approach.

Also, this exploits the fact that these features are unstable, and used rarely - as soon as the majority of fields in the ecosystem use at least one of those features (presumably the default value in most cases), this will no longer be an optimization.

@panstromek
panstromek marked this pull request as ready for review July 12, 2026 11:55
@rustbot

rustbot commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

rustfmt is developed in its own repository. If possible, consider making this change to rust-lang/rustfmt instead.

cc @rust-lang/rustfmt

@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 Jul 12, 2026
@rustbot

rustbot commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

r? @khyperia

rustbot has assigned @khyperia.
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: compiler
  • compiler expanded to 75 candidates
  • Random selection from 18 candidates

@khyperia

Copy link
Copy Markdown
Contributor

apologies, I've fallen ill and probably won't get around to reviewing this for a while, so I'm rerolling

r? compiler

@rustbot rustbot assigned petrochenkov and unassigned khyperia Jul 13, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

We need to re-benchmark this after #158942, tokens in MutRestriction were clearly unnecessary.
@rustbot author

@rustbot rustbot 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 Jul 13, 2026
@rustbot

rustbot commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rust-bors

rust-bors Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: aee29e1 (aee29e16223a403e2e07ed5fef9f3772c1c4544a)
Base parent: eff8269 (eff8269f797067c30555e77f160ec84c0ed15cd9)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (aee29e1): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@bors rollup=never rustc-perf
@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.3% [-0.3%, -0.2%] 14
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.3% [-0.3%, -0.2%] 14

Max RSS (memory usage)

Results (secondary -1.5%)

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

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

Cycles

Results (primary 1.9%, secondary 2.7%)

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

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

Binary size

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

Bootstrap: 489.126s -> 485.679s (-0.70%)
Artifact size: 389.52 MiB -> 389.46 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 19, 2026
@panstromek

Copy link
Copy Markdown
Contributor Author

@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 Jul 19, 2026
@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_ast/src/ast.rs Outdated
Comment thread compiler/rustc_ast_lowering/src/item.rs Outdated
Comment thread compiler/rustc_parse/src/parser/item.rs Outdated
Comment thread compiler/rustc_resolve/src/build_reduced_graph.rs Outdated
@petrochenkov

Copy link
Copy Markdown
Contributor

Some tests are also failing.
@rustbot author

@rustbot rustbot 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 Jul 20, 2026
@rustbot

rustbot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Changes to the size of AST and/or HIR nodes.

cc @nnethercote

@panstromek
panstromek force-pushed the make-field-def-smaller branch from f94ea58 to ce94ff5 Compare July 22, 2026 19:43
@rustbot

rustbot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

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.

@panstromek

Copy link
Copy Markdown
Contributor Author

@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 Jul 23, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

r=me after squashing commits.
@rustbot author

@rustbot rustbot 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 Jul 23, 2026
@panstromek
panstromek force-pushed the make-field-def-smaller branch from ce94ff5 to 283ec3a Compare July 23, 2026 12:44
@panstromek

Copy link
Copy Markdown
Contributor Author

Thanks! I squashed the commits but I don't have rights to r= you. Sorry for the churn.

@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 Jul 23, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 283ec3a has been approved by petrochenkov

It is now in the queue for this repository.

@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 Jul 23, 2026
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. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Try to make FieldDef smaller

6 participants