Switch QueryJobId to a single global counter
This replaces the per-shard counters with a single global counter, simplifying the JobId struct down to just a u64 and removing the need to pipe a DepKind generic through a bunch of code. The performance implications on non-parallel compilers are likely minimal (this switches to `Cell<u64>` as the backing storage over a `u64`, but the latter was already inside a `RefCell` so it's not really a significance divergence). On parallel compilers, the cost of a single global u64 counter may be more significant: it adds a serialization point in theory. On the other hand, we can imagine changing the counter to have a thread-local component if it becomes worrisome or some similar structure. The new design is sufficiently simpler that it warrants the potential for slight changes down the line if/when we get parallel compilation to be more of a default. A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid possibly overflowing it and causing problems; it is effectively impossible that we would overflow a u64 counter in this context.
This commit is contained in:
parent
88fb06a1f3
commit
e240783a4d
7 changed files with 116 additions and 178 deletions
|
@ -117,10 +117,12 @@ impl QuerySideEffects {
|
|||
}
|
||||
|
||||
pub trait QueryContext: HasDepContext {
|
||||
/// Get the query information from the TLS context.
|
||||
fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>;
|
||||
fn next_job_id(&self) -> QueryJobId;
|
||||
|
||||
fn try_collect_active_jobs(&self) -> Option<QueryMap<Self::DepKind>>;
|
||||
/// Get the query information from the TLS context.
|
||||
fn current_query_job(&self) -> Option<QueryJobId>;
|
||||
|
||||
fn try_collect_active_jobs(&self) -> Option<QueryMap>;
|
||||
|
||||
/// Load side effects associated to the node in the previous session.
|
||||
fn load_side_effects(&self, prev_dep_node_index: SerializedDepNodeIndex) -> QuerySideEffects;
|
||||
|
@ -140,7 +142,7 @@ pub trait QueryContext: HasDepContext {
|
|||
/// captured during execution and the actual result.
|
||||
fn start_query<R>(
|
||||
&self,
|
||||
token: QueryJobId<Self::DepKind>,
|
||||
token: QueryJobId,
|
||||
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
|
||||
compute: impl FnOnce() -> R,
|
||||
) -> R;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue