Skip to content

Commit

Permalink
Add cache hit/miss/bypass suffix to index report
Browse files Browse the repository at this point in the history
  • Loading branch information
oulgen committed Oct 3, 2024
1 parent 83f03d2 commit c98037d
Show file tree
Hide file tree
Showing 6 changed files with 5,630 additions and 10 deletions.
21 changes: 18 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,23 @@ fn run_parser<'t>(
payload: &str,
output_count: &mut i32,
output: &mut Vec<(PathBuf, String)>,
compile_directory: &mut Vec<(String, String, i32)>,
compile_directory: &mut Vec<(String, String, i32, String)>,
multi: &MultiProgress,
stats: &mut Stats,
) {
if let Some(md) = parser.get_metadata(&e) {
let results = parser.parse(lineno, md, e.rank, &e.compile_id, &payload);
fn extact_suffix(filename: &String) -> String {
if filename.contains("fx_graph_cache_miss") {
"❎".to_string()
} else if filename.contains("fx_graph_cache_hit") {
"✅".to_string()
} else if filename.contains("fx_graph_cache_bypass") {
"❓".to_string()
} else {
"".to_string()
}
}
match results {
Ok(results) => {
for parser_result in results {
Expand All @@ -108,25 +119,29 @@ fn run_parser<'t>(
};
output.push((filename.clone(), out));
let filename_str = format!("{}", filename.to_string_lossy());
let suffix = extact_suffix(&filename_str);
compile_directory.push((
filename_str.clone(),
filename_str,
*output_count,
suffix,
));
*output_count += 1;
}
ParserOutput::GlobalFile(filename, out) => {
output.push((filename.clone(), out));
let filename_str = format!("{}", filename.to_string_lossy());
let suffix = extact_suffix(&filename_str);
compile_directory.push((
filename_str.clone(),
filename_str,
*output_count,
suffix,
));
*output_count += 1;
}
ParserOutput::Link(name, url) => {
compile_directory.push((url, name, *output_count));
compile_directory.push((url, name, *output_count, "".to_string()));
*output_count += 1;
}
}
Expand Down Expand Up @@ -191,7 +206,7 @@ pub fn parse_path(path: &PathBuf, config: ParseConfig) -> anyhow::Result<ParseOu
// Each entry is a compile id => (link, rendered name, output number)
// For files, link and rendered name are the same
// For links, you can specify a custom name for the link
let mut directory: FxIndexMap<Option<CompileId>, Vec<(String, String, i32)>> =
let mut directory: FxIndexMap<Option<CompileId>, Vec<(String, String, i32, String)>> =
FxIndexMap::default();

let mut metrics_index: CompilationMetricsIndex = FxIndexMap::default();
Expand Down
13 changes: 9 additions & 4 deletions src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ pub struct CompilationMetricsParser<'t> {
pub tt: &'t TinyTemplate<'t>,
pub stack_index: &'t RefCell<StackIndex>,
pub symbolic_shape_specialization_index: &'t RefCell<SymbolicShapeSpecializationIndex>,
pub output_files: &'t Vec<(String, String, i32)>,
pub output_files: &'t Vec<(String, String, i32, String)>,
pub compile_id_dir: &'t PathBuf,
}
impl StructuredLogParser for CompilationMetricsParser<'_> {
Expand Down Expand Up @@ -416,11 +416,16 @@ impl StructuredLogParser for CompilationMetricsParser<'_> {
let new_str: String = parts[1..].join("");
new_str
};
let output_files: Vec<(String, String, i32)> = self
let output_files: Vec<(String, String, i32, String)> = self
.output_files
.iter()
.map(|(url, name, number)| {
return (remove_prefix(url), remove_prefix(name), number.clone());
.map(|(url, name, number, suffix)| {
(
remove_prefix(url),
remove_prefix(name),
number.clone(),
suffix.clone(),
)
})
.collect();
let context = CompilationMetricsContext {
Expand Down
2 changes: 1 addition & 1 deletion src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Build products below:
<li><a id="{compile_directory.0}">{compile_directory.0}</a>
<ul>
{{ for path_idx in compile_directory.1 }}
<li><a href="{path_idx.0}">{path_idx.1}</a> ({path_idx.2})</li>
<li><a href="{path_idx.0}">{path_idx.1}</a> {path_idx.3} ({path_idx.2})</li>
{{ endfor }}
</ul>
</li>
Expand Down
4 changes: 2 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ pub struct CompilationMetricsContext<'e> {
pub compile_id: String,
pub stack_html: String,
pub symbolic_shape_specializations: Vec<SymbolicShapeSpecializationContext>,
pub output_files: &'e Vec<(String, String, i32)>,
pub output_files: &'e Vec<(String, String, i32, String)>,
pub compile_id_dir: &'e PathBuf,
pub mini_stack_html: String,
}
Expand Down Expand Up @@ -556,7 +556,7 @@ pub struct DynamoGuardsContext {
pub struct IndexContext {
pub css: &'static str,
pub javascript: &'static str,
pub directory: Vec<(String, Vec<(String, String, i32)>)>,
pub directory: Vec<(String, Vec<(String, String, i32, String)>)>,
pub stack_trie_html: String,
pub unknown_stack_trie_html: String,
pub has_unknown_stack_trie: bool,
Expand Down
Loading

0 comments on commit c98037d

Please sign in to comment.