Add a profiler reference to GraphEncoder
This commit is contained in:
parent
62415e2a95
commit
29cc76f0fc
3 changed files with 18 additions and 33 deletions
|
@ -650,7 +650,7 @@ impl<'tcx> GlobalCtxt<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish(&self) -> FileEncodeResult {
|
pub fn finish(&self) -> FileEncodeResult {
|
||||||
self.dep_graph.finish_encoding(&self.sess.prof)
|
self.dep_graph.finish_encoding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,6 @@ impl<D: Deps> DepGraph<D> {
|
||||||
|
|
||||||
// Instantiate a dependy-less node only once for anonymous queries.
|
// Instantiate a dependy-less node only once for anonymous queries.
|
||||||
let _green_node_index = current.intern_new_node(
|
let _green_node_index = current.intern_new_node(
|
||||||
profiler,
|
|
||||||
DepNode { kind: D::DEP_KIND_NULL, hash: current.anon_id_seed.into() },
|
DepNode { kind: D::DEP_KIND_NULL, hash: current.anon_id_seed.into() },
|
||||||
EdgesVec::new(),
|
EdgesVec::new(),
|
||||||
Fingerprint::ZERO,
|
Fingerprint::ZERO,
|
||||||
|
@ -443,12 +442,7 @@ impl<D: Deps> DepGraphData<D> {
|
||||||
hash: self.current.anon_id_seed.combine(hasher.finish()).into(),
|
hash: self.current.anon_id_seed.combine(hasher.finish()).into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.current.intern_new_node(
|
self.current.intern_new_node(target_dep_node, task_deps, Fingerprint::ZERO)
|
||||||
cx.profiler(),
|
|
||||||
target_dep_node,
|
|
||||||
task_deps,
|
|
||||||
Fingerprint::ZERO,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -871,11 +865,8 @@ impl<D: Deps> DepGraphData<D> {
|
||||||
|
|
||||||
// We allocating an entry for the node in the current dependency graph and
|
// We allocating an entry for the node in the current dependency graph and
|
||||||
// adding all the appropriate edges imported from the previous graph
|
// adding all the appropriate edges imported from the previous graph
|
||||||
let dep_node_index = self.current.promote_node_and_deps_to_current(
|
let dep_node_index =
|
||||||
qcx.dep_context().profiler(),
|
self.current.promote_node_and_deps_to_current(&self.previous, prev_dep_node_index);
|
||||||
&self.previous,
|
|
||||||
prev_dep_node_index,
|
|
||||||
);
|
|
||||||
|
|
||||||
// ... emitting any stored diagnostic ...
|
// ... emitting any stored diagnostic ...
|
||||||
|
|
||||||
|
@ -981,12 +972,8 @@ impl<D: Deps> DepGraph<D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish_encoding(&self, profiler: &SelfProfilerRef) -> FileEncodeResult {
|
pub fn finish_encoding(&self) -> FileEncodeResult {
|
||||||
if let Some(data) = &self.data {
|
if let Some(data) = &self.data { data.current.encoder.steal().finish() } else { Ok(0) }
|
||||||
data.current.encoder.steal().finish(profiler)
|
|
||||||
} else {
|
|
||||||
Ok(0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn next_virtual_depnode_index(&self) -> DepNodeIndex {
|
pub(crate) fn next_virtual_depnode_index(&self) -> DepNodeIndex {
|
||||||
|
@ -1150,6 +1137,7 @@ impl<D: Deps> CurrentDepGraph<D> {
|
||||||
prev_graph_node_count,
|
prev_graph_node_count,
|
||||||
record_graph,
|
record_graph,
|
||||||
record_stats,
|
record_stats,
|
||||||
|
profiler,
|
||||||
)),
|
)),
|
||||||
new_node_to_index: Sharded::new(|| {
|
new_node_to_index: Sharded::new(|| {
|
||||||
FxHashMap::with_capacity_and_hasher(
|
FxHashMap::with_capacity_and_hasher(
|
||||||
|
@ -1183,7 +1171,6 @@ impl<D: Deps> CurrentDepGraph<D> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn intern_new_node(
|
fn intern_new_node(
|
||||||
&self,
|
&self,
|
||||||
profiler: &SelfProfilerRef,
|
|
||||||
key: DepNode,
|
key: DepNode,
|
||||||
edges: EdgesVec,
|
edges: EdgesVec,
|
||||||
current_fingerprint: Fingerprint,
|
current_fingerprint: Fingerprint,
|
||||||
|
@ -1191,8 +1178,7 @@ impl<D: Deps> CurrentDepGraph<D> {
|
||||||
let dep_node_index = match self.new_node_to_index.lock_shard_by_value(&key).entry(key) {
|
let dep_node_index = match self.new_node_to_index.lock_shard_by_value(&key).entry(key) {
|
||||||
Entry::Occupied(entry) => *entry.get(),
|
Entry::Occupied(entry) => *entry.get(),
|
||||||
Entry::Vacant(entry) => {
|
Entry::Vacant(entry) => {
|
||||||
let dep_node_index =
|
let dep_node_index = self.encoder.borrow().send(key, current_fingerprint, edges);
|
||||||
self.encoder.borrow().send(profiler, key, current_fingerprint, edges);
|
|
||||||
entry.insert(dep_node_index);
|
entry.insert(dep_node_index);
|
||||||
dep_node_index
|
dep_node_index
|
||||||
}
|
}
|
||||||
|
@ -1223,8 +1209,7 @@ impl<D: Deps> CurrentDepGraph<D> {
|
||||||
let dep_node_index = match prev_index_to_index[prev_index] {
|
let dep_node_index = match prev_index_to_index[prev_index] {
|
||||||
Some(dep_node_index) => dep_node_index,
|
Some(dep_node_index) => dep_node_index,
|
||||||
None => {
|
None => {
|
||||||
let dep_node_index =
|
let dep_node_index = self.encoder.borrow().send(key, fingerprint, edges);
|
||||||
self.encoder.borrow().send(profiler, key, fingerprint, edges);
|
|
||||||
prev_index_to_index[prev_index] = Some(dep_node_index);
|
prev_index_to_index[prev_index] = Some(dep_node_index);
|
||||||
dep_node_index
|
dep_node_index
|
||||||
}
|
}
|
||||||
|
@ -1261,7 +1246,7 @@ impl<D: Deps> CurrentDepGraph<D> {
|
||||||
let fingerprint = fingerprint.unwrap_or(Fingerprint::ZERO);
|
let fingerprint = fingerprint.unwrap_or(Fingerprint::ZERO);
|
||||||
|
|
||||||
// This is a new node: it didn't exist in the previous compilation session.
|
// This is a new node: it didn't exist in the previous compilation session.
|
||||||
let dep_node_index = self.intern_new_node(profiler, key, edges, fingerprint);
|
let dep_node_index = self.intern_new_node(key, edges, fingerprint);
|
||||||
|
|
||||||
(dep_node_index, None)
|
(dep_node_index, None)
|
||||||
}
|
}
|
||||||
|
@ -1269,7 +1254,6 @@ impl<D: Deps> CurrentDepGraph<D> {
|
||||||
|
|
||||||
fn promote_node_and_deps_to_current(
|
fn promote_node_and_deps_to_current(
|
||||||
&self,
|
&self,
|
||||||
profiler: &SelfProfilerRef,
|
|
||||||
prev_graph: &SerializedDepGraph,
|
prev_graph: &SerializedDepGraph,
|
||||||
prev_index: SerializedDepNodeIndex,
|
prev_index: SerializedDepNodeIndex,
|
||||||
) -> DepNodeIndex {
|
) -> DepNodeIndex {
|
||||||
|
@ -1286,7 +1270,7 @@ impl<D: Deps> CurrentDepGraph<D> {
|
||||||
.map(|i| prev_index_to_index[i].unwrap())
|
.map(|i| prev_index_to_index[i].unwrap())
|
||||||
.collect();
|
.collect();
|
||||||
let fingerprint = prev_graph.fingerprint_by_index(prev_index);
|
let fingerprint = prev_graph.fingerprint_by_index(prev_index);
|
||||||
let dep_node_index = self.encoder.borrow().send(profiler, key, fingerprint, edges);
|
let dep_node_index = self.encoder.borrow().send(key, fingerprint, edges);
|
||||||
prev_index_to_index[prev_index] = Some(dep_node_index);
|
prev_index_to_index[prev_index] = Some(dep_node_index);
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
self.record_edge(dep_node_index, key, fingerprint);
|
self.record_edge(dep_node_index, key, fingerprint);
|
||||||
|
|
|
@ -504,6 +504,7 @@ impl<D: Deps> EncoderState<D> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GraphEncoder<D: Deps> {
|
pub struct GraphEncoder<D: Deps> {
|
||||||
|
profiler: SelfProfilerRef,
|
||||||
status: Lock<EncoderState<D>>,
|
status: Lock<EncoderState<D>>,
|
||||||
record_graph: Option<Lock<DepGraphQuery>>,
|
record_graph: Option<Lock<DepGraphQuery>>,
|
||||||
}
|
}
|
||||||
|
@ -514,10 +515,11 @@ impl<D: Deps> GraphEncoder<D> {
|
||||||
prev_node_count: usize,
|
prev_node_count: usize,
|
||||||
record_graph: bool,
|
record_graph: bool,
|
||||||
record_stats: bool,
|
record_stats: bool,
|
||||||
|
profiler: &SelfProfilerRef,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let record_graph = record_graph.then(|| Lock::new(DepGraphQuery::new(prev_node_count)));
|
let record_graph = record_graph.then(|| Lock::new(DepGraphQuery::new(prev_node_count)));
|
||||||
let status = Lock::new(EncoderState::new(encoder, record_stats));
|
let status = Lock::new(EncoderState::new(encoder, record_stats));
|
||||||
GraphEncoder { status, record_graph }
|
GraphEncoder { status, record_graph, profiler: profiler.clone() }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn with_query(&self, f: impl Fn(&DepGraphQuery)) {
|
pub(crate) fn with_query(&self, f: impl Fn(&DepGraphQuery)) {
|
||||||
|
@ -580,18 +582,17 @@ impl<D: Deps> GraphEncoder<D> {
|
||||||
|
|
||||||
pub(crate) fn send(
|
pub(crate) fn send(
|
||||||
&self,
|
&self,
|
||||||
profiler: &SelfProfilerRef,
|
|
||||||
node: DepNode,
|
node: DepNode,
|
||||||
fingerprint: Fingerprint,
|
fingerprint: Fingerprint,
|
||||||
edges: EdgesVec,
|
edges: EdgesVec,
|
||||||
) -> DepNodeIndex {
|
) -> DepNodeIndex {
|
||||||
let _prof_timer = profiler.generic_activity("incr_comp_encode_dep_graph");
|
let _prof_timer = self.profiler.generic_activity("incr_comp_encode_dep_graph");
|
||||||
let node = NodeInfo { node, fingerprint, edges };
|
let node = NodeInfo { node, fingerprint, edges };
|
||||||
self.status.lock().encode_node(&node, &self.record_graph)
|
self.status.lock().encode_node(&node, &self.record_graph)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish(self, profiler: &SelfProfilerRef) -> FileEncodeResult {
|
pub fn finish(self) -> FileEncodeResult {
|
||||||
let _prof_timer = profiler.generic_activity("incr_comp_encode_dep_graph");
|
let _prof_timer = self.profiler.generic_activity("incr_comp_encode_dep_graph");
|
||||||
self.status.into_inner().finish(profiler)
|
self.status.into_inner().finish(&self.profiler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue