Create the previous dep graph index on a background thread
This changes SerializedDepGraph.index to be computed on-demand per dep kind. This means we can immediately start using queries without waiting for the entire index to be constructed. Additionally a background thread is started which computes the entire index, effectively off-loading most of the index construction to the background thread.
| Benchmark | Before | After | Before | After | ||
| Time | Time | % | Memory | Memory | % | |
| 🟣 clap:check:unchanged | 0.4259s | 0.4225s | -0.79% | 89.65 MiB | 90.08 MiB | 0.48% |
| 🟣 hyper:check:unchanged | 0.1425s | 0.1417s | -0.53% | 47.85 MiB | 47.91 MiB | 0.13% |
| 🟣 regex:check:unchanged | 0.3188s | 0.3157s | -0.97% | 71.09 MiB | 71.58 MiB | 0.69% |
| 🟣 syn:check:unchanged | 0.5895s | 0.5813s | 💚 -1.38% | 101.68 MiB | 102.15 MiB | 0.47% |
| 🟣 syntex_syntax:check:unchanged | 1.4392s | 1.4361s | -0.22% | 200.62 MiB | 201.68 MiB | 0.53% |
| Total | 2.9158s | 2.8974s | -0.63% | 510.89 MiB | 513.40 MiB | 0.49% |
| Summary | 1.0000s | 0.9922s | -0.78% | 1 byte | 1.00 bytes | 0.46% |
| Benchmark | Before | After | Before | After | ||
| Time | Time | % | Memory | Memory | % | |
| 🟠 clap:debug:unchanged | 1.0753s | 1.0684s | -0.64% | 142.80 MiB | 142.72 MiB | -0.05% |
| 🟠 hyper:debug:unchanged | 0.2857s | 0.2847s | -0.35% | 63.06 MiB | 63.15 MiB | 0.13% |
| 🟠 regex:debug:unchanged | 0.7703s | 0.7633s | -0.90% | 108.76 MiB | 109.03 MiB | 0.25% |
| 🟠 syn:debug:unchanged | 1.0596s | 1.0531s | -0.62% | 142.08 MiB | 142.18 MiB | 0.07% |
| 🟠 syntex_syntax:debug:unchanged | 2.7530s | 2.7274s | -0.93% | 308.92 MiB | 308.63 MiB | -0.09% |
| Total | 5.9438s | 5.8969s | -0.79% | 765.62 MiB | 765.71 MiB | 0.01% |
| Summary | 1.0000s | 0.9931s | -0.69% | 1 byte | 1.00 bytes | 0.06% |
r? @cjgillot
In a typical compilation, when happens the first use of this reciprocal index? I'm tempted to say very early, as the first query to be invoked needs it. In which cases is this beneficial?
In a typical compilation, when happens the first use of this reciprocal index? I'm tempted to say very early, as the first query to be invoked needs it.
It will end up calling setup_index, which constructs the index for only that query kind. It's beneficial if we don't use too many query kinds (around 23) before the background thread sets them all.
:umbrella: The latest upstream changes (presumably #118900) made this pull request unmergeable. Please resolve the merge conflicts.
Hi @cjgillot, I think this is ready for another round of review as all of the discussion threads have replies from @Zoxc. Thanks!
The job x86_64-gnu-llvm-16 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
Built container sha256:9c3c93a371e5aed5c18185b24f130d95d5140dbd72a9b325e7b6b49e521a4faa
Looks like docker image is the same as before, not uploading
https://ci-caches.rust-lang.org/docker/7ebc15c01a233894034d277c8cce4e949f4e7791f66b4727c8fb6e058a0b8171d6152e1441d677cef0653843ceeee469c097b8699b2bb74249e674f6aa1a8813
sha256:9c3c93a371e5aed5c18185b24f130d95d5140dbd72a9b325e7b6b49e521a4faa
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-16]
##[group]Clock drift check
local time: Fri Jan 19 06:14:56 UTC 2024
network time: Fri, 19 Jan 2024 06:14:57 GMT
network time: Fri, 19 Jan 2024 06:14:57 GMT
##[endgroup]
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-16', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'build.optimized-compiler-builtins', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-16/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.thin-lto-import-instr-limit := 10
configure: change-id := 99999999
---
Compiling rustc_parse v0.0.0 (/checkout/compiler/rustc_parse)
error: unused variable: `token`
--> compiler/rustc_query_system/src/dep_graph/serialized.rs:222:27
|
222 | if let Ok(token) = client.acquire() {
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_token`
= note: `-D unused-variables` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_variables)]`
error: method `spawn_prefetch_thread` is never used
error: method `spawn_prefetch_thread` is never used
--> compiler/rustc_query_system/src/dep_graph/serialized.rs:218:8
|
119 | impl SerializedDepGraph {
| ----------------------- method in this implementation
...
218 | fn spawn_prefetch_thread(self: &Arc<Self>) {
|
= note: `-D dead-code` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(dead_code)]`
Probably should do a perf run here as the result in https://github.com/rust-lang/rust/pull/122070 was more mixed than expected.
@bors try @rust-timer queue
Awaiting bors try build completion.
@rustbot label: +S-waiting-on-perf
:hourglass: Trying commit 1b9f6d85a9fe1a08ad2adbd5eb3cfe0af771f2db with merge fa1beb3d6a488d654692efb29b4b14c08b15a554...
:sunny: Try build successful - checks-actions
Build commit: fa1beb3d6a488d654692efb29b4b14c08b15a554 (fa1beb3d6a488d654692efb29b4b14c08b15a554)
:sunny: Try build successful - checks-actions
Build commit: fa1beb3d6a488d654692efb29b4b14c08b15a554 (fa1beb3d6a488d654692efb29b4b14c08b15a554)
Queued fa1beb3d6a488d654692efb29b4b14c08b15a554 with parent 3521a2f2f317cb978063842485c7d1bc86ec82b6, future comparison URL. There is currently 1 preceding artifact in the queue. It will probably take at least ~1.7 hours until the benchmark run finishes.
Finished benchmarking commit (fa1beb3d6a488d654692efb29b4b14c08b15a554): comparison URL.
Overall result: ❌ regressions - 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.
Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.
@bors rollup=never @rustbot label: -S-waiting-on-perf +perf-regression
Instruction count
This is a highly reliable metric that was used to determine the overall result at the top of this comment.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
2.0% | [0.3%, 3.4%] | 103 |
| Regressions ❌ (secondary) |
1.5% | [0.6%, 2.3%] | 27 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
- | - | 0 |
| All ❌✅ (primary) | 2.0% | [0.3%, 3.4%] | 103 |
Max RSS (memory usage)
Results
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) |
2.3% | [1.6%, 3.1%] | 3 |
| Improvements ✅ (primary) |
-1.1% | [-1.1%, -1.1%] | 1 |
| Improvements ✅ (secondary) |
-3.3% | [-6.4%, -1.3%] | 54 |
| All ❌✅ (primary) | -1.1% | [-1.1%, -1.1%] | 1 |
Cycles
Results
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) |
1.7% | [1.0%, 2.4%] | 14 |
| Regressions ❌ (secondary) |
3.0% | [2.2%, 3.6%] | 4 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
- | - | 0 |
| All ❌✅ (primary) | 1.7% | [1.0%, 2.4%] | 14 |
Binary size
This benchmark run did not return any relevant results for this metric.
Bootstrap: 647.634s -> 647.342s (-0.05%) Artifact size: 310.02 MiB -> 309.93 MiB (-0.03%)
That's quite an odd performance result. It seem to have large wall time regressions which don't show up in the self profiling results nor can I reproduce them locally.
:umbrella: The latest upstream changes (presumably #122070) made this pull request unmergeable. Please resolve the merge conflicts.
I think this is waiting on a comment on the perf run? @Zoxc Do you need some directions? Also a rebase when you have a chance. Thanks!
@rustbot author