|
1 | 1 | use rustc_data_structures::fx::FxHashMap; |
2 | 2 | use rustc_data_structures::sync::join; |
3 | | -use rustc_middle::dep_graph::{DepGraph, DepKind, WorkProduct, WorkProductId}; |
| 3 | +use rustc_middle::dep_graph::{DepGraph, WorkProduct, WorkProductId}; |
4 | 4 | use rustc_middle::ty::TyCtxt; |
5 | 5 | use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; |
6 | 6 | use rustc_serialize::Encodable as RustcEncodable; |
@@ -148,83 +148,15 @@ fn encode_dep_graph(tcx: TyCtxt<'_>, encoder: &mut FileEncoder) -> FileEncodeRes |
148 | 148 | // First encode the commandline arguments hash |
149 | 149 | tcx.sess.opts.dep_tracking_hash().encode(encoder)?; |
150 | 150 |
|
151 | | - // Encode the graph data. |
152 | | - let serialized_graph = |
153 | | - tcx.sess.time("incr_comp_serialize_dep_graph", || tcx.dep_graph.serialize()); |
154 | | - |
155 | 151 | if tcx.sess.opts.debugging_opts.incremental_info { |
156 | | - #[derive(Clone)] |
157 | | - struct Stat { |
158 | | - kind: DepKind, |
159 | | - node_counter: u64, |
160 | | - edge_counter: u64, |
161 | | - } |
162 | | - |
163 | | - let total_node_count = serialized_graph.nodes.len(); |
164 | | - let total_edge_count = serialized_graph.edge_list_data.len(); |
165 | | - |
166 | | - let mut counts: FxHashMap<_, Stat> = |
167 | | - FxHashMap::with_capacity_and_hasher(total_node_count, Default::default()); |
168 | | - |
169 | | - for (i, &node) in serialized_graph.nodes.iter_enumerated() { |
170 | | - let stat = counts.entry(node.kind).or_insert(Stat { |
171 | | - kind: node.kind, |
172 | | - node_counter: 0, |
173 | | - edge_counter: 0, |
174 | | - }); |
175 | | - |
176 | | - stat.node_counter += 1; |
177 | | - let (edge_start, edge_end) = serialized_graph.edge_list_indices[i]; |
178 | | - stat.edge_counter += (edge_end - edge_start) as u64; |
179 | | - } |
180 | | - |
181 | | - let mut counts: Vec<_> = counts.values().cloned().collect(); |
182 | | - counts.sort_by_key(|s| -(s.node_counter as i64)); |
183 | | - |
184 | | - println!("[incremental]"); |
185 | | - println!("[incremental] DepGraph Statistics"); |
186 | | - |
187 | | - const SEPARATOR: &str = "[incremental] --------------------------------\ |
188 | | - ----------------------------------------------\ |
189 | | - ------------"; |
190 | | - |
191 | | - println!("{}", SEPARATOR); |
192 | | - println!("[incremental]"); |
193 | | - println!("[incremental] Total Node Count: {}", total_node_count); |
194 | | - println!("[incremental] Total Edge Count: {}", total_edge_count); |
195 | | - if let Some((total_edge_reads, total_duplicate_edge_reads)) = |
196 | | - tcx.dep_graph.edge_deduplication_data() |
197 | | - { |
198 | | - println!("[incremental] Total Edge Reads: {}", total_edge_reads); |
199 | | - println!("[incremental] Total Duplicate Edge Reads: {}", total_duplicate_edge_reads); |
200 | | - } |
201 | | - println!("[incremental]"); |
202 | | - println!( |
203 | | - "[incremental] {:<36}| {:<17}| {:<12}| {:<17}|", |
204 | | - "Node Kind", "Node Frequency", "Node Count", "Avg. Edge Count" |
205 | | - ); |
206 | | - println!( |
207 | | - "[incremental] -------------------------------------\ |
208 | | - |------------------\ |
209 | | - |-------------\ |
210 | | - |------------------|" |
211 | | - ); |
212 | | - |
213 | | - for stat in counts.iter() { |
214 | | - println!( |
215 | | - "[incremental] {:<36}|{:>16.1}% |{:>12} |{:>17.1} |", |
216 | | - format!("{:?}", stat.kind), |
217 | | - (100.0 * (stat.node_counter as f64)) / (total_node_count as f64), // percentage of all nodes |
218 | | - stat.node_counter, |
219 | | - (stat.edge_counter as f64) / (stat.node_counter as f64), // average edges per kind |
220 | | - ); |
221 | | - } |
222 | | - |
223 | | - println!("{}", SEPARATOR); |
224 | | - println!("[incremental]"); |
| 152 | + tcx.dep_graph.print_incremental_info(); |
225 | 153 | } |
226 | 154 |
|
227 | | - tcx.sess.time("incr_comp_encode_serialized_dep_graph", || serialized_graph.encode(encoder)) |
| 155 | + // There is a tiny window between printing the incremental info above and encoding the dep |
| 156 | + // graph below in which the dep graph could change, thus making the printed incremental info |
| 157 | + // slightly out of date. If this matters to you, please feel free to submit a patch. :) |
| 158 | + |
| 159 | + tcx.sess.time("incr_comp_encode_serialized_dep_graph", || tcx.dep_graph.encode(encoder)) |
228 | 160 | } |
229 | 161 |
|
230 | 162 | fn encode_work_product_index( |
|
0 commit comments