Skip to content

Commit

Permalink
Add support for parsing chromium_events
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesjwu committed Aug 6, 2024
1 parent 5208bc3 commit d555eed
Show file tree
Hide file tree
Showing 5 changed files with 54,369 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ pub fn parse_path(path: &PathBuf, config: ParseConfig) -> anyhow::Result<ParseOu

let mut all_parsers = default_parsers(&tt, &config);
all_parsers.extend(config.custom_parsers);
let mut chromium_events : Vec<serde_json::Value> = Vec::new();

while let Some((lineno, line)) = iter.next() {
bytes_read += line.len() as u64;
Expand Down Expand Up @@ -438,6 +439,10 @@ pub fn parse_path(path: &PathBuf, config: ParseConfig) -> anyhow::Result<ParseOu
unknown_stack_trie.insert(stack.clone(), None);
}

if let Some(_) = e.chromium_event {
chromium_events.push(serde_json::from_str(&payload)?);
}

if let Some(specialization) = e.symbolic_shape_specialization {
symbolic_shape_specialization_index
.borrow_mut()
Expand All @@ -462,7 +467,12 @@ pub fn parse_path(path: &PathBuf, config: ParseConfig) -> anyhow::Result<ParseOu
));
pb.finish_with_message("done");
spinner.finish();


output.push((
PathBuf::from("chromium_events.json"),
serde_json::to_string_pretty(&chromium_events).unwrap(),
));

eprintln!("{:?}", stats);
if unknown_fields.len() > 0 {
eprintln!(
Expand All @@ -485,6 +495,7 @@ pub fn parse_path(path: &PathBuf, config: ParseConfig) -> anyhow::Result<ParseOu
unknown_stack_trie_html: unknown_stack_trie.fmt(Some(&metrics_index)).unwrap(),
has_unknown_stack_trie: !unknown_stack_trie.is_empty(),
num_breaks: breaks.failures.len(),
has_chromium_events: !chromium_events.is_empty(),
};
output.push((
PathBuf::from("index.html"),
Expand Down
7 changes: 7 additions & 0 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ phase generates:
<li>Inductor will apply some post grad FX passes, producing <code>inductor_post_grad_graph</code></li>
<li>Inductor will perform code generation, producing the final <code>inductor_output_code</code> which will be executed at runtime. This output is a valid Python program and can be directly run.</li>
</ol>
{{ if has_chromium_events }}
<h2> Chromium Events </h2>
PT2 generates <a href='chromium_events.json'>Chromium Trace Events</a> in JSON on specific events during compilation.
You can download and view them in a tool like <a href='https://ui.perfetto.dev/'>Perfetto</a>.
{{ endif }}
<p>
Build products below:
</p>
Expand All @@ -139,6 +145,7 @@ Build products below:
{{ endfor }}
</ul>
</div>
{{ if has_unknown_stack_trie }}
<div>
<h2>Unknown stacks</h2>
Expand Down
3 changes: 3 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use core::hash::BuildHasherDefault;
use std::io::Empty;
use fxhash::{FxHashMap, FxHasher};
use html_escape::encode_text;
use indexmap::IndexMap;
Expand Down Expand Up @@ -452,6 +453,7 @@ pub struct Envelope {
pub describe_tensor: Option<TensorDesc>,
pub describe_source: Option<SourceDesc>,
pub dump_file: Option<DumpFileMetadata>,
pub chromium_event: Option<EmptyMetadata>,
#[serde(flatten)]
pub _other: FxHashMap<String, Value>,
}
Expand Down Expand Up @@ -561,6 +563,7 @@ pub struct IndexContext {
pub has_unknown_stack_trie: bool,
pub num_breaks: usize,
pub custom_header_html: String,
pub has_chromium_events: bool,
}

#[derive(Debug, Serialize)]
Expand Down
Loading

0 comments on commit d555eed

Please sign in to comment.