Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for parsing chromium_events #62

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions 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 @@ -463,6 +468,11 @@ 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
4 changes: 2 additions & 2 deletions src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,10 @@ impl StructuredLogParser for DumpFileParser {
}
fn parse<'e>(
&self,
lineno: usize,
_lineno: usize,
metadata: Metadata<'e>,
_rank: Option<u32>,
compile_id: &Option<CompileId>,
_compile_id: &Option<CompileId>,
payload: &str,
) -> anyhow::Result<ParserResults> {
if let Metadata::DumpFile(metadata) = metadata {
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
Expand Up @@ -5,6 +5,7 @@ use indexmap::IndexMap;
use regex::Regex;
use serde_json::Value;


use std::fmt::{self, Display, Write};
use std::path::PathBuf;

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
Loading