Draft
Conversation
The call chain for a non-incremental query includes the following
functions:
- execute_query_non_incr_inner (assert!)
- try_execute_query (assert!)
- execute_job_non_incr (assert!)
And likewise for an incremental query:
- execute_query_incr_inner (assert!)
- try_execute_query (assert!)
- execute_job_incr (expect)
That is five distinct functions. Every one of them has an `assert!` or
`expect` call that checks that the dep-graph is/is not enabled as
expected. Three cheers for defensive programming but this feels like
overkill, particularly when `execute_job{,_non_incr,_incr}` each have a
single call site.
This commit removes the assertions in `execute_query_*` and
`try_execute_query`, leaving a check in each of the `execute_job_*`
functions.
Prior to rust-lang#154122 it wasn't used on all paths, so we only computed it when necessary -- sometimes in `check_if_ensure_can_skip_execution`, sometimes in one of two places in `execute_job_incr` -- and pass around `Option<DepNode>` to allow this. But now it's always used, so this commit makes us compute it earlier, which simplifies things. - `check_if_ensure_can_skip_execution` can be made simpler, returning a bool and eliminating the need for `EnsureCanSkip`. - `execute_job_incr` no longer uses two slightly different methods to create a `DepNode` (`get_or_insert_with` vs `unwrap_or_else`).
There 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.
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`.)
Member
|
I feel very uneasy about the |
Contributor
Author
|
Ok, so what does
Let's think about the things that were within
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves some clumsy control flow in
execute_job_incr, and also fixes some inconsistencies the the scopes ofstart_queryand query profiling.