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

Split the Edges iterator. #137655

Merged
merged 3 commits into from
Mar 9, 2025
Merged

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Feb 26, 2025

Some nice performance wins here, mostly on the wg-grammar benchmark.

r? @lcnr

@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 Feb 26, 2025
@nnethercote
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 Feb 26, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 26, 2025
…<try>

Split the `Edges` iterator.

r? `@ghost`
@bors
Copy link
Contributor

bors commented Feb 26, 2025

⌛ Trying commit b49a734 with merge 449a9f7...

@bors
Copy link
Contributor

bors commented Feb 26, 2025

☀️ Try build successful - checks-actions
Build commit: 449a9f7 (449a9f79d82ced53005ec8aac40306afa5af4cbc)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (449a9f7): 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 the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.8% [-5.3%, -4.5%] 6
All ❌✅ (primary) - - 0

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: 771.663s -> 772.21s (0.07%)
Artifact size: 361.93 MiB -> 361.97 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 26, 2025
@nnethercote
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 Feb 27, 2025
@bors
Copy link
Contributor

bors commented Feb 27, 2025

⌛ Trying commit 48a95d1 with merge 920033b...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 27, 2025
…<try>

Split the `Edges` iterator.

r? `@ghost`
@bors
Copy link
Contributor

bors commented Feb 27, 2025

☀️ Try build successful - checks-actions
Build commit: 920033b (920033be46e1f50b03632d1215206f9e22801e8d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (920033b): 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 the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.1% [-5.6%, -4.8%] 6
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -2.7%, secondary -2.5%)

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)
-2.7% [-3.1%, -1.9%] 3
Improvements ✅
(secondary)
-2.5% [-2.9%, -2.2%] 2
All ❌✅ (primary) -2.7% [-3.1%, -1.9%] 3

Cycles

Results (secondary -4.8%)

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)
- - 0
Improvements ✅
(secondary)
-4.8% [-6.4%, -2.3%] 8
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 770.979s -> 770.86s (-0.02%)
Artifact size: 361.96 MiB -> 361.97 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 27, 2025
@nnethercote nnethercote marked this pull request as ready for review February 27, 2025 04:35
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

not too big a fan of EdgesVanilla as a name 🤔 maybe just Edges and EdgesFromStatic iterator 🤔

r=me after wards

@nnethercote
Copy link
Contributor Author

Ok. I originally had EdgesNormal but that was confusing because Normal is already used for the graphs (as the opposite of Reverse).

This facilitates the next commit.
The `Edges` iterator returns `OutlivesConstraint` elements, which are 72
bytes. This is big enough to affect performance. Return
`&OutlivesConstraint` would be better. However, each `Edges` iterator is
really one of two different iterators. The "from graph" case does a
graph traversal and could return `&OutlivesConstraint`. But the "from
static" case just does a `0..n` iteration and constructs a new
`OutlivesConstraint` from that, so it can't return a reference.

This commit splits `Edges into `EdgesFromGraph` and `EdgesFromStatic`,
which allows them to have different return types. This is a perf win for
the `wg-grammar` benchmark.
`Trace::FromOutlivesConstraint` contains an `OutlivesConstraint`, which
is 72 bytes. Lots of these are created but never used.

This commit splits `Trace::FromOutlivesConstraint` into three new
variants: `FromVanilla`, `FromStatic`, `FromMember`. Each of these
contains just enough data to construct an `OutlivesConstraint`, if
necessary. This reduces the size of `Trace` from 72 bytes to 16 bytes.
All this avoids some memory traffic.
@nnethercote
Copy link
Contributor Author

After discussion on Zulip with @lcnr I went with EdgesFromGraph and EdgesFromStatic.

@bors r+

@bors
Copy link
Contributor

bors commented Feb 27, 2025

📌 Commit 9a0513a has been approved by nnethercote

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Feb 27, 2025

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

@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 Feb 27, 2025
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Mar 6, 2025
…r=nnethercote

Split the `Edges` iterator.

Some nice performance wins here, mostly on the `wg-grammar` benchmark.

r? `@lcnr`
@bors
Copy link
Contributor

bors commented Mar 9, 2025

⌛ Testing commit 9a0513a with merge 385970f...

@bors
Copy link
Contributor

bors commented Mar 9, 2025

☀️ Test successful - checks-actions
Approved by: nnethercote
Pushing 385970f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 9, 2025
@bors bors merged commit 385970f into rust-lang:master Mar 9, 2025
7 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 9, 2025
@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)

gh pr comment ${HEAD_PR} -F output.log
shell: /usr/bin/bash -e {0}
##[endgroup]
fatal: ambiguous argument 'HEAD^1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
##[error]Process completed with exit code 128.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (385970f): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.1% [-5.6%, -4.8%] 6
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -0.8%)

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

Cycles

Results (secondary -5.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)
- - 0
Improvements ✅
(secondary)
-5.2% [-5.9%, -4.7%] 6
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 768.783s -> 769.881s (0.14%)
Artifact size: 361.99 MiB -> 361.99 MiB (0.00%)

@nnethercote nnethercote deleted the split-edges-iterator branch March 9, 2025 21:05
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