Skip to content

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Oct 9, 2025

Some cleanups and minor perf improvements relating to TaskDeps.

r? @saethlin

There are only two places that create a `TaskDeps`. One constructs it
manually, the other uses `default`. It's weird that `default()` uses a
capacity of 128.

This commit just gets rid of `default` and introduces `new` so that
both construction sites can be equivalent.
`INLINE_CAPACITY` has two different uses:
- It dictates the inline capacity of `EdgesVec::edges`, which is a
  `SmallVec`.
- It dictates when `TaskDeps` switches from a linear scan lookup to a
  hashset lookup to determine if an edge has been seen before.

These two uses are in the same part of the code, but they're
fundamentally separate and don't need to use the same constant.

This commit separates the two uses, and adds some helpful comments,
making the code clearer. It also changes the value used for the
linear/hashset threshold from 8 to 16, which gives slightly better perf.
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 9, 2025
@nnethercote nnethercote closed this Oct 9, 2025
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 9, 2025
@nnethercote nnethercote reopened this Oct 9, 2025
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 9, 2025
@nnethercote
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 9, 2025
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 9, 2025
@rust-bors
Copy link

rust-bors bot commented Oct 9, 2025

💥 Test timed out after 21600s

@nnethercote
Copy link
Contributor Author

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 9, 2025
@nnethercote nnethercote closed this Oct 9, 2025
@nnethercote nnethercote reopened this Oct 9, 2025
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 9, 2025
@nnethercote
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 9, 2025
@rust-bors
Copy link

rust-bors bot commented Oct 10, 2025

☀️ Try build successful (CI)
Build commit: e4658cf (e4658cffaf309c44def5c182c71fc3b1e4f810d8, parent: b925a865e2c9a0aefe5a2877863cb4df796f2eaf)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e4658cf): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@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.7% [0.6%, 0.8%] 3
Regressions ❌
(secondary)
0.8% [0.2%, 1.0%] 22
Improvements ✅
(primary)
-0.4% [-1.2%, -0.1%] 29
Improvements ✅
(secondary)
-0.5% [-1.1%, -0.1%] 23
All ❌✅ (primary) -0.3% [-1.2%, 0.8%] 32

Max RSS (memory usage)

Results (primary -0.8%, secondary 0.4%)

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

mean range count
Regressions ❌
(primary)
1.9% [0.8%, 2.5%] 3
Regressions ❌
(secondary)
1.8% [1.2%, 2.3%] 2
Improvements ✅
(primary)
-4.8% [-8.8%, -0.9%] 2
Improvements ✅
(secondary)
-1.1% [-1.1%, -1.0%] 2
All ❌✅ (primary) -0.8% [-8.8%, 2.5%] 5

Cycles

Results (secondary -1.8%)

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)
3.2% [2.0%, 4.3%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.3% [-4.0%, -2.2%] 7
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 472.277s -> 472.516s (0.05%)
Artifact size: 388.06 MiB -> 388.09 MiB (0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 10, 2025
@nnethercote
Copy link
Contributor Author

I'm a bit surprised by the mix of perf improvements and regressions. Locally I saw almost universal improvements with a small number of miniscule regressions, e.g. some icount numbers:

BEFORE (Check-IncrFull)
bitmaps-3.2.1                3,999,278,379 (100.0%)  PROGRAM TOTALS
typenum-1.18.0               5,364,985,952 (100.0%)  PROGRAM TOTALS
externs                      1,184,979,961 (100.0%)  PROGRAM TOTALS
many-assoc-items             5,117,422,096 (100.0%)  PROGRAM TOTALS
wg-grammar                   6,753,582,514 (100.0%)  PROGRAM TOTALS
tuple-stress                12,562,234,370 (100.0%)  PROGRAM TOTALS
unicode-normalization-0.1.24 2,729,862,515 (100.0%)  PROGRAM TOTALS
ucd                         24,642,112,477 (100.0%)  PROGRAM TOTALS
coercions                    2,098,125,489 (100.0%)  PROGRAM TOTALS

AFTER (Check-IncrFull)
bitmaps-3.2.1                3,976,850,944 (100.0%)  PROGRAM TOTALS
typenum-1.18.0               5,339,821,854 (100.0%)  PROGRAM TOTALS
externs                      1,176,914,821 (100.0%)  PROGRAM TOTALS
many-assoc-items             5,098,681,486 (100.0%)  PROGRAM TOTALS
wg-grammar                   6,546,434,699 (100.0%)  PROGRAM TOTALS
tuple-stress                12,431,543,435 (100.0%)  PROGRAM TOTALS
unicode-normalization-0.1.24 2,725,721,823 (100.0%)  PROGRAM TOTALS
ucd                         24,665,476,690 (100.0%)  PROGRAM TOTALS
coercions                    2,096,889,857 (100.0%)  PROGRAM TOTALS

Anyway, overall it's still a perf win (esp. if you focus on primary benchmarks) and it's also as much a cleanup PR as a perf PR, so I think it's good enough.

@nnethercote nnethercote marked this pull request as ready for review October 13, 2025 10:58
@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 Oct 13, 2025
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) perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants