Build Hotspot Analyzer (bha) is a C++20 toolchain for measuring, explaining, and improving C and C++ build performance.
Current version: v0.1.0
It combines:
- multi-compiler trace ingestion
- structured build-time analysis
- actionable optimization suggestions
- optional safe auto-apply and rollback workflows
- export pipelines for HTML, JSON, SARIF, CSV, Markdown, and PR annotations
- LSP-powered IDE integrations for editor-driven workflows
Modern C++ builds fail slowly for many different reasons:
- expensive translation units
- pathological include graphs
- repeated template instantiations
- ineffective or missing precompiled headers
- poor unity build partitioning
- bloated headers and unstable implementation boundaries
- weak cache and distributed-build suitability
BHA is built to close that gap with a single workflow:
- record or ingest traces from real builds
- analyze where time and memory go
- explain why those hotspots exist
- generate targeted suggestions
- optionally apply safe edits
- rebuild, compare, and export results for humans and CI
- Clang time-trace JSON
- GCC time-trace JSON
- MSVC traces
- Intel Classic traces
- Intel oneAPI traces
- NVCC traces
- translation unit hotspots
- include/dependency cost
- template-instantiation cost
- symbol and function cost
- circular dependency detection
- stack and memory summaries when present
- cache hit/miss opportunity analysis
- distributed-build suitability
- regression comparison against saved baselines
pchforward-declinclude-removalmove-to-cpptemplate-instantiationunity-buildheader-splitpimpl
cmakeninjamakeand autotools flowsmsbuildmesonbazelbuck2sconsxcodeunreal
htmljsoncsvsarifmd- GitHub and GitLab annotation formats
headers/: public and internal C++ headerssources/: core implementationcli/: command implementation forbhalsp/: optional language server and editor integrationsresources/: HTML/CSS/JS templates and assetstests/: unit tests, integration harnesses, fixtures, subprojectsdocs/: user, architecture, CI, exporter, IDE, and contributor documentation
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -jcmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DBHA_ENABLE_LSP=ON \
-DBHA_BUILD_REFACTOR_TOOLS=ON
cmake --build build -jctest --test-dir build --output-on-failure./build/bha build --clean --output traces --analyze
./build/bha suggest traces --detailed -o suggestions.json --format json
./build/bha export traces --format html --dark-mode -o report.html./build/bha snapshot save baseline build/trace.json
./build/bha snapshot baseline set baseline
./build/bha snapshot save optimized build/trace_after.json
./build/bha compare --baseline optimized --gate-tu 5 --gate-header 8 --gate-template 10./build/bha --help
./build/bha <command> --helpanalyzesuggestapplybuildrecordexportsnapshotcompare
BHA ships editor clients around the bha-lsp server.
Supported in-tree clients:
- VS Code:
lsp/ide-integrations/vscode - Neovim:
lsp/ide-integrations/neovim - Emacs:
lsp/ide-integrations/emacs
cmake -S . -B build -DBHA_ENABLE_LSP=ON
cmake --build build -jPackage and install locally:
cd lsp/ide-integrations/vscode
npm ci
npm run package
code --install-extension build-hotspot-analyzer-0.1.0.vsixRuntime settings:
buildHotspotAnalyzer.serverPathbuildHotspotAnalyzer.autoAnalyzebuildHotspotAnalyzer.trace.server
Main commands:
BHA: Record Build TracesBHA: Record Build Traces (Advanced)BHA: Analyze Build PerformanceBHA: Show SuggestionsBHA: Show Activity LogBHA: Apply SuggestionBHA: Apply All SuggestionsBHA: Revert ChangesBHA: Restart Language Server
Long-running VS Code commands show progress notifications so build recording, analysis, apply, and revert operations are visible while they run. Record, analyze, and apply operations expose a cancel button in the progress notification. Cancellation requests are forwarded to the language server, and build output streams into the activity log during trace recording and rebuild validation.
VS Code also writes command activity, build output summaries, and server/runtime diagnostics to the
Build Hotspot Analyzer output channel. Open it with BHA: Show Activity Log or through the Output panel.
When VS Code records traces into a custom directory, follow-up analysis reuses that directory for the current workspace. The last successful traced build profile is persisted per workspace and reused for apply-time rebuild validation across reloads when the cached build directory, trace directory, and explicit compiler path are still valid.
Recommended workflow:
BHA: Record Build TracesBHA: Analyze Build PerformanceBHA: Show Suggestions
Advanced trace recording supports explicit overrides for compiler, build type, parallel jobs, extra build arguments, trace output directory, and an optional build-system override when auto-detection is not what you want.
Client module:
lsp/ide-integrations/neovim/lua/bha/init.lua
Requirements:
nvim-lspconfigbha-lsponPATHor configured explicitly
Client module:
lsp/ide-integrations/emacs/bha-lsp.el
Requirements:
lsp-modebha-lsponPATHor configured explicitly
BHA does not require Marketplace publication to be usable.
Recommended order:
- GitHub-first distribution
- local or release-attached
.vsixinstall for VS Code - direct GitHub install for Neovim and Emacs
- Marketplace / Open VSX publication later, when needed
This keeps the product usable even when Microsoft Marketplace account setup is blocked by Azure billing or organization requirements.
For the full IDE guide, see docs/ide_integrations.md.
Primary assets:
- banner:
docs/assets/logo.png - square icon:
docs/assets/logo-icon.png - monochrome banner:
docs/assets/logo-mono.png
Source assets:
- banner SVG:
docs/assets/logo.svg - square icon SVG:
docs/assets/logo-icon.svg - monochrome SVG:
docs/assets/logo-mono.svg
The VS Code extension icon is synchronized from:
lsp/ide-integrations/vscode/media/icon.png
docs/readme.md: documentation indexdocs/installation.md: installation and build profilesdocs/quickstart.md: end-to-end workflowsdocs/cli_reference.md: CLI referencedocs/lsp_reference.md: LSP commands, settings, and apply flowdocs/ide_integrations.md: VS Code, Neovim, Emacs, local setup, and user-facing distributiondocs/suggestions_reference.md: suggester behavior, guardrails, and constraintsdocs/export_ci.md: exporters, SARIF, PR annotations, and CI usagedocs/architecture.md: internal architecture and component layoutdocs/development.md: contributor workflow and testingdocs/coverage_matrix.md: documentation coverage statusdocs/troubleshooting.md: common failures and fixesdocs/repo_validation.md: large-repo validation and benchmark notesdocs/docs_strategy.md: documentation strategy used for this repository
- Repository:
https://github.com/gregorian-09/build-hotspot-analyzer - Issues:
https://github.com/gregorian-09/build-hotspot-analyzer/issues
Maintainer: Gregorian Rayne
