diff --git a/src/parsers.rs b/src/parsers.rs index cb1e7a4..737dde8 100644 --- a/src/parsers.rs +++ b/src/parsers.rs @@ -207,7 +207,11 @@ impl StructuredLogParser for CompilationMetricsParser<'_> { ) -> anyhow::Result { let filename = format!("{}.html", self.name()); if let Metadata::CompilationMetrics(m) = metrics { - let output = self.tt.render(&filename, &m)?; + let id = compile_id.clone().map_or("(unknown) ".to_string(), |c| { + format!("{cid} ", cid = c) + }); + let context = CompilationMetricsContext { css:crate::CSS, m: &m, compile_id: id }; + let output = self.tt.render(&filename, &context)?; simple_file_output(&filename, lineno, compile_id, &output) } else { Err(anyhow::anyhow!("Expected CompilationMetrics metadata")) diff --git a/src/templates.rs b/src/templates.rs index 3856888..07a9983 100644 --- a/src/templates.rs +++ b/src/templates.rs @@ -145,56 +145,61 @@ pub static TEMPLATE_FAILURES_AND_RESTARTS: &str = r#" pub static TEMPLATE_COMPILATION_METRICS : &str = r#" + Compilation Metrics -

Compilation Info

+

Compilation Info for {compile_id}

Dynamo Output:

dynamo_output_graph.txt

Compile Time(seconds)

-

Entire Frame [?]: {entire_frame_compile_time_s} -

Backend [?]: {backend_compile_time_s} - {{ if inductor_compile_time_s }} -

Inductor [?]: {inductor_compile_time_s} +

Entire Frame [?]: {m.entire_frame_compile_time_s} +

Backend [?]: {m.backend_compile_time_s} + {{ if m.inductor_compile_time_s }} +

Inductor [?]: {m.inductor_compile_time_s} {{ endif }} - {{ if code_gen_time_s }} -

Code Gen Time: {code_gen_time_s}

+ {{ if m.code_gen_time_s }} +

Code Gen Time: {m.code_gen_time_s}

{{ endif}} -
Dynamo Time Before Restart [?]: {dynamo_time_before_restart_s}
+
Dynamo Time Before Restart [?]: {m.dynamo_time_before_restart_s}

Restarts and Failures

- {{ if fail_type }} -

Failure Exception: {fail_type}

-

Failure Reason: {fail_reason}

-

In file {fail_user_frame_filename}, line {fail_user_frame_lineno}

+ {{ if m.fail_type }} +

Failure Exception: {m.fail_type}

+

Failure Reason: {m.fail_reason}

+ {{ if m.fail_user_frame_filename }} +

In file {m.fail_user_frame_filename}, line {m.fail_user_frame_lineno}

+ {{ endif}} {{ else }}

No failures!

{{ endif }} - {{ if restart_reasons }} + {{ if m.restart_reasons }}

Restart Reasons:

- {{ for restart_reason in restart_reasons }} -

  • {restart_reason }
  • + {{ for restart_reason in m.restart_reasons }} +
  • {restart_reason}
  • {{ endfor }} {{ else }}

    No restarts!

    {{ endif }}

    Cache Metrics

    -

    Cache Size: {cache_size}

    -

    Accumulated Cache Size: {accumulated_cache_size}

    +

    Cache Size: {m.cache_size}

    +

    Accumulated Cache Size: {m.accumulated_cache_size}

    Graph Metrics

    -

    Guard Count: {guard_count}

    -

    Shape Env Guards: {shape_env_guard_count}

    -

    Graph Ops: {graph_op_count}

    -

    Graph Nodes: {graph_node_count}

    -

    Graph Inputs: {graph_input_count}

    +

    Guard Count: {m.guard_count}

    +

    Shape Env Guards: {m.shape_env_guard_count}

    +

    Graph Ops: {m.graph_op_count}

    +

    Graph Nodes: {m.graph_node_count}

    +

    Graph Inputs: {m.graph_input_count}

    Custom Ops

    Compliant Custom Ops:

    - {{ for op in compliant_custom_ops }} + {{ for op in m.compliant_custom_ops }}
  • {op}
  • {{ endfor }}

    Non-Compliant Custom Ops:

    - {{ for op in non_compliant_ops }} + {{ for op in m.non_compliant_ops }}
  • {op}
  • {{ endfor }} diff --git a/src/types.rs b/src/types.rs index 7aacb25..dad8ae7 100644 --- a/src/types.rs +++ b/src/types.rs @@ -197,6 +197,13 @@ pub struct CompilationMetricsMetadata { pub dynamo_time_before_restart_s: Option, } +#[derive(Debug, Serialize)] +pub struct CompilationMetricsContext<'e> { + pub m : &'e CompilationMetricsMetadata, + pub css: &'static str, + pub compile_id: String, +} + #[derive(Debug, Serialize)] pub enum FailureReason { Failure((String, String, String, u32)), // (failure type, failure reason, user frame filename, user frame lineno)