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

hygiene: Rewrite apply_mark_internal to be more understandable #139083

Merged
merged 1 commit into from
Mar 31, 2025

Conversation

petrochenkov
Copy link
Contributor

The previous implementation allocated new SyntaxContexts in the inverted order, and it was generally very hard to understand why its result matches what the opaque and opaque_and_semitransparent field docs promise.

/// This context, but with all transparent and semi-transparent expansions filtered away.
opaque: SyntaxContext,
/// This context, but with all transparent expansions filtered away.
opaque_and_semitransparent: SyntaxContext,

It also couldn't be easily reused for the case where the context id is pre-reserved like in #129827.

The new implementation tries to follow the docs in a more straightforward way.
I did the transformation in small steps, so it indeed matches the old implementation, not just the docs.
So I suggest reading only the new version.

@rustbot
Copy link
Collaborator

rustbot commented Mar 28, 2025

r? @cjgillot

rustbot has assigned @cjgillot.
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. labels Mar 28, 2025
@petrochenkov
Copy link
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 Mar 28, 2025
@petrochenkov
Copy link
Contributor Author

r? compiler (cjgillot is inactive)

@rustbot rustbot assigned nnethercote and unassigned cjgillot Mar 28, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 28, 2025
hygiene: Rewrite `apply_mark_internal` to be more understandable

The previous implementation allocated new `SyntaxContext`s in the inverted order, and it was generally very hard to understand why its result matches what the `opaque` and `opaque_and_semitransparent` field docs promise.
```rust
/// This context, but with all transparent and semi-transparent expansions filtered away.
opaque: SyntaxContext,
/// This context, but with all transparent expansions filtered away.
opaque_and_semitransparent: SyntaxContext,
```
It also couldn't be easily reused for the case where the context id is pre-reserved like in rust-lang#129827.

The new implementation tries to follow the docs in a more straightforward way.
I did the transformation in small steps, so it indeed matches the old implementation, not just the docs.
So I suggest reading only the new version.
@bors
Copy link
Collaborator

bors commented Mar 28, 2025

⌛ Trying commit 7c74474 with merge 037210a...

@petrochenkov
Copy link
Contributor Author

petrochenkov commented Mar 28, 2025

I think we could also try evaluating opaque and opaque_and_semitransparent lazily on demand, but for that #129827 needs to land first.

Upd: this was tried in #139146, turned out to not be an improvement.

@bors
Copy link
Collaborator

bors commented Mar 28, 2025

☀️ Try build successful - checks-actions
Build commit: 037210a (037210a42e18d142c45ef34265694b981f4685b4)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (037210a): comparison URL.

Overall result: no relevant changes - 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 benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary -1.2%)

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

Cycles

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

Binary size

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

Bootstrap: 777.292s -> 777.64s (0.04%)
Artifact size: 365.95 MiB -> 365.87 MiB (-0.02%)

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

@bors rollup=maybe

@petrochenkov
Copy link
Contributor Author

This was included into #129827.

@petrochenkov
Copy link
Contributor Author

#129827 was reverted, so reopening.
Blocked on #139130.
@rustbot blocked

@petrochenkov petrochenkov reopened this Mar 30, 2025
@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 30, 2025
@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Mar 30, 2025
@nnethercote
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 31, 2025

📌 Commit 7c74474 has been approved by nnethercote

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 31, 2025
@bors
Copy link
Collaborator

bors commented Mar 31, 2025

⌛ Testing commit 7c74474 with merge 10a76d6...

@bors
Copy link
Collaborator

bors commented Mar 31, 2025

☀️ Test successful - checks-actions
Approved by: nnethercote
Pushing 10a76d6 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 31, 2025
@bors bors merged commit 10a76d6 into rust-lang:master Mar 31, 2025
7 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Mar 31, 2025
Copy link

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 7bfd952 (parent) -> 10a76d6 (this PR)

Test differences

Show 8 test diffs

Additionally, 8 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Job duration changes

  1. aarch64-gnu: 6676.8s -> 9436.6s (41.3%)
  2. x86_64-apple-1: 8381.5s -> 9897.4s (18.1%)
  3. dist-x86_64-apple: 8889.5s -> 9757.8s (9.8%)
  4. aarch64-apple: 3816.3s -> 4091.3s (7.2%)
  5. i686-mingw-1: 7342.0s -> 7802.5s (6.3%)
  6. x86_64-msvc-ext1: 7280.2s -> 7651.1s (5.1%)
  7. dist-aarch64-apple: 5291.2s -> 5499.4s (3.9%)
  8. dist-loongarch64-linux: 6332.1s -> 6578.1s (3.9%)
  9. i686-mingw-3: 7986.3s -> 8290.9s (3.8%)
  10. dist-x86_64-msvc-alt: 7188.3s -> 7460.7s (3.8%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (10a76d6): 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

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

Binary size

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

Bootstrap: 776.473s -> 776.145s (-0.04%)
Artifact size: 365.91 MiB -> 365.92 MiB (0.00%)

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-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.

6 participants