Add python analysis scripts for Clang's time trace (#3644)

This PR introduces a Python toolkit for analyzing Clang's `-ftime-trace` build performance data. This is the foundation for our systematic effort to reduce CK and CK-Tile build times (#3575).

The toolkit provides fast parsing of trace JSON files into pandas DataFrames using orjson, with specialized functions for analyzing template instantiation costs and compilation phase breakdowns. It includes a core library (`trace_analysis/`), example scripts for quick analysis, a comprehensive README with usage documentation, and an interactive Jupyter notebook demonstration.

Key features include memory-efficient DataFrame schemas with optimized dtypes, recursive hierarchical phase analysis, automatic metadata extraction (source file, compilation timing), and template instantiation filtering. The design supports both standalone scripts and interactive Jupyter notebook workflows.

This single-file analysis capability lays the groundwork for future multi-file analysis across thousands of compilation units, enabling data-driven optimization and build time regression detection.
This commit is contained in:
John Shumway
2026-01-26 13:44:36 -08:00
committed by GitHub
parent 2e49b6b2f7
commit a213ce676b
8 changed files with 1653 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
# SPDX-License-Identifier: MIT
"""
Build Trace Analysis - Core library for analyzing Clang -ftime-trace data.
This package provides tools to parse and analyze Clang's -ftime-trace JSON output
for build performance analysis.
"""
from .parse_file import (
parse_file,
get_metadata,
)
from .template_analysis import (
get_template_instantiation_events,
)
from .phase_breakdown import (
get_phase_breakdown,
PhaseBreakdown,
)
__all__ = [
# Core parsing and filtering
"parse_file",
"get_metadata",
# Template analysis
"get_template_instantiation_events",
# Phase breakdown
"get_phase_breakdown",
"PhaseBreakdown",
]