Uh oh!
There was an error while loading. Please reload this page.
Refactor execute_job_incr - #154279
Conversation
Zalathar
commented
Mar 24, 2026
I feel very uneasy about the |
nnethercote
commented
Mar 24, 2026
Ok, so what does
Let's think about the things that were within
|
This comment has been minimized.
This comment has been minimized.
745e144 to
f7fed56Comparennethercote
commented
Mar 24, 2026
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Refactor `execute_job_incr`
| pub fn with_feed_task<'tcx, C: QueryCache>( | ||
| &self, | ||
| node: DepNode, | ||
| tcx: TyCtxt<'tcx>, | ||
| result: &R, | ||
| hash_result: Option<fn(&mut StableHashingContext<'_>, &R) -> Fingerprint>, | ||
| format_value_fn: fn(&R) -> String, | ||
| query: &'tcx QueryVTable<'tcx, C>, | ||
| node: DepNode, | ||
| value: &C::Value, |
There was a problem hiding this comment.
I had considered doing this in the past, and ultimately backed down because I wasn't sure if I wanted to introduce this C: QueryCache bound here or not.
But it's probably fine, and being able to simplify the signature of incremental_verify_ich is certainly a nice payoff, so +1 on this change.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rust-timer
commented
Mar 24, 2026
Finished benchmarking commit (237f82c): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.5%, secondary 0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 0.3%, secondary -1.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 495.299s -> 485.474s (-1.98%) |
f7fed56 to
68a138dCompareThere are three `start_query` calls. Two of them have very small scopes, just an `invoke_provider_fn` call and very little else. But the one in `execute_job_incr` has a huge scope that covers a `try_mark_green` call and everything done by `load_from_disk_or_invoke_provider_green`: a disk load attempt, `prof_timer` start/stop; an `invoke_provider_fn` call, and hash verification. This commit moves the `start_query` call into `load_from_disk_or_invoke_provider_green` to make the scope match the other two cases. Most of the code that is moved out of the `start_query` scope is unaffected. `try_mark_green` is affected, but in a good way. With the old scope, when going through `try_mark_green` two calls to `start_query` would occur on the way to an actual `invoke_provider_fn`. This is why `false` was passed for `depth_limit`; this `false` is no longer necessary.
It doesn't need to be in there. Removing it makes `define_queries` smaller, which is always good, and also enables the next commit which tidies up profiling. Also change how `value` and `verify` are initialized, because I just don't like the current way of doing it after the declaration.
From `plumbing.rs` to `execution.rs`, which is where most of the other query profiling occurs. It also avoids eliminates some fn parameters. This means the `provided_to_erased` call in `try_from_load_disk_fn` is now included in the profiling when previously it wasn't. This is good because `provided_to_erased` is included in other profiling calls (e.g. calls to `invoke_provider_fn`).
It has a single call site. After inlining we can refactor `execute_job_incr` quite a bit and the overall result is simpler and clearer, especially the control flow -- no `try` block in an `if` condition(!), no early returns, just vanilla `if`s and `match`es and about -40 lines of code.
Remove a low-value comment, and add a comment about hashing explaining something that I found non-obvious.
Specifically, `DepGraph::with_feed_task` and `incremental_verify_ich` This makes some things shorter, at the cost of making module `dep_graph` depend directly on module `query`. (It already depends indirectly via module `verify_ich`.)
I was looking at the version of There are now several multi-level nested conditions, The current version, while far from perfect, at least has a mostly-linear structure with a distinct green path followed by fallback to a red path. The new version makes me immediately want to look for ways to make things more manageable. EDIT: Specifically, the commit that removes the green-path early return and inlines |
68a138d to
d595192Comparennethercote
commented
Mar 24, 2026
Arguing over matters of taste is probably pointless but I'll defend my work in case it stops you from blocking what I think is a good change. This code is complex because the underlying algorithm is complex. Breaking it in to smaller pieces doesn't change the complexity, it just obscures it. Splitting Just look at |
Zalathar
commented
Mar 25, 2026
That function is the green case path. It used to have a straightforward top-to-bottom special-case/fallback structure (much like Inlining it turns Inlining the green path feels like the result of following a rigid style guide that says all early returns are bad, and all single-call-site functions are bad, and all long parameter lists are bad. It's not simpler, and it's not clearer, and that was supposed to be the whole point. |
☔ The latest upstream changes (presumably #154576) made this pull request unmergeable. Please resolve the merge conflicts. |
Zoxc
commented
Apr 2, 2026
The |
This PR improves some clumsy control flow in
execute_job_incr, and also fixes some inconsistencies the the scopes ofstart_queryand query profiling.