[build] Add build timing report and dependency analysis tools#25643
[build] Add build timing report and dependency analysis tools#25643lihuay merged 2 commits intosonic-net:masterfrom
Conversation
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This pull request adds build performance analysis and instrumentation tools to sonic-buildimage. The PR introduces three new scripts and a Make target to help developers identify build bottlenecks and optimization opportunities.
Changes:
- Added
scripts/build-timing-report.shto parse build logs and generate per-package timing analysis with parallelism statistics - Added
scripts/build-dep-graph.pyto parse dependency relationships from Makefile rules and generate critical path analysis - Added
scripts/build-resource-monitor.shto sample system resources during builds - Added
make build-reporttarget inslave.mkto run timing and dependency analysis
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 22 comments.
| File | Description |
|---|---|
| slave.mk | Added build-report Makefile target and updated .PHONY declarations |
| scripts/build-timing-report.sh | Shell script that parses build log timestamps to generate timing reports |
| scripts/build-resource-monitor.sh | Shell script that samples CPU, memory, and disk I/O metrics during builds |
| scripts/build-dep-graph.py | Python script that extracts and analyzes the build dependency graph from .mk files |
6ad8bf2 to
f4c184b
Compare
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
f4c184b to
fd858c6
Compare
yxieca
left a comment
There was a problem hiding this comment.
LGTM. AI agent on behalf of Ying.
yxieca
left a comment
There was a problem hiding this comment.
LGTM. AI agent on behalf of Ying.
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Copilot Review — All 22 Threads AddressedPushed commit Code Fixes (17):
Not Real Issues (5) — Resolved with explanation:
|
|
AI agent on behalf of Ying: CI is still running; will re-check and approve once green. |
|
AI agent on behalf of Ying: CI not clean yet (Azure.sonic-buildimage still in progress; optional kvmtest-t1-lag-vpp failed). Please update once green. |
|
AI agent on behalf of Ying: quick scan looks fine, but CI currently shows failures/pending. Please check the failing jobs and rerun; I’ll re-review once green. |
|
CI shows failures (Azure/impacted-area tests). Please re-run or confirm if infra flake. Once green, I can approve.\n\nAI agent on behalf of Ying. |
|
AI agent on behalf of Ying: quick check shows outstanding issues.
|
yxieca
left a comment
There was a problem hiding this comment.
AI agent on behalf of Ying. Quick review: [build]. No issues found.
yxieca
left a comment
There was a problem hiding this comment.
AI agent on behalf of Ying. Quick review: [build] Add build timing report and dependency analysis tools. No issues found.
4733d4e to
6d1c672
Compare
yxieca
left a comment
There was a problem hiding this comment.
AI agent on behalf of Ying.
6d1c672 to
8111d36
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Add three scripts for build performance instrumentation: - scripts/build-timing-report.sh: Parse per-package timing from build logs (HEADER/FOOTER timestamps), generate sorted duration table, phase breakdown, parallelism timeline, and CSV export. - scripts/build-dep-graph.py: Parse rules/*.mk dependency graph, compute critical path, fan-out/fan-in bottleneck analysis, and generate DOT/JSON output for visualization. - scripts/build-resource-monitor.sh: Sample CPU, memory, disk I/O, and Docker container count during builds for resource utilization analysis. Add "make build-report" target to slave.mk that runs the timing report and dependency analysis after a build completes. Example output from a VS build on 24-core/30GB machine: - 210 packages built in 53m wall time (173m CPU) - Max concurrency: 5 (with SONIC_CONFIG_BUILD_JOBS=4) - Critical path: 14 packages deep (libnl -> libswsscommon -> utilities) - Top bottleneck: LIBSWSSCOMMON with 48 downstream dependents Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com>
- Use free -m with division instead of free -g to avoid rounding (#1) - Add = and ?= to Makefile dependency regex patterns (sonic-net#2, sonic-net#7) - CPU calculation now uses /proc/stat delta (two reads) (sonic-net#3, sonic-net#14) - Fix misleading 'critical path estimate' comment (sonic-net#4) - Fix parallelism timeline comment (60s not 10s) (sonic-net#5) - Include after-relationship packages in fan stats (sonic-net#6) - Guard disk I/O division by zero when INTERVAL<=1 (sonic-net#8) - Remove unused elapsed_line variable (sonic-net#9) - Remove redundant LIBSWSSCOMMON_DBG check (sonic-net#10) - Remove active_make_jobs from CSV header comment (sonic-net#11) - Wire up _RDEPENDS parsing to build reverse deps (sonic-net#12) - Remove unnecessary 'if v' filter on rdeps JSON (sonic-net#13) - Remove unused REPORT_FORMAT parameter (sonic-net#15) - Add cycle detection to critical path algorithm (sonic-net#16) - Add execute permission check for companion scripts (sonic-net#17) Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com>
8111d36 to
da18f0d
Compare
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…net#25643) * [build] Add build timing report and dependency analysis tools Add three scripts for build performance instrumentation: - scripts/build-timing-report.sh: Parse per-package timing from build logs (HEADER/FOOTER timestamps), generate sorted duration table, phase breakdown, parallelism timeline, and CSV export. - scripts/build-dep-graph.py: Parse rules/*.mk dependency graph, compute critical path, fan-out/fan-in bottleneck analysis, and generate DOT/JSON output for visualization. - scripts/build-resource-monitor.sh: Sample CPU, memory, disk I/O, and Docker container count during builds for resource utilization analysis. Add "make build-report" target to slave.mk that runs the timing report and dependency analysis after a build completes. Example output from a VS build on 24-core/30GB machine: - 210 packages built in 53m wall time (173m CPU) - Max concurrency: 5 (with SONIC_CONFIG_BUILD_JOBS=4) - Critical path: 14 packages deep (libnl -> libswsscommon -> utilities) - Top bottleneck: LIBSWSSCOMMON with 48 downstream dependents Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com> * Address Copilot review: fix 17 bugs in build analysis scripts - Use free -m with division instead of free -g to avoid rounding (sonic-net#1) - Add = and ?= to Makefile dependency regex patterns (sonic-net#2, sonic-net#7) - CPU calculation now uses /proc/stat delta (two reads) (sonic-net#3, sonic-net#14) - Fix misleading 'critical path estimate' comment (sonic-net#4) - Fix parallelism timeline comment (60s not 10s) (sonic-net#5) - Include after-relationship packages in fan stats (sonic-net#6) - Guard disk I/O division by zero when INTERVAL<=1 (sonic-net#8) - Remove unused elapsed_line variable (sonic-net#9) - Remove redundant LIBSWSSCOMMON_DBG check (sonic-net#10) - Remove active_make_jobs from CSV header comment (sonic-net#11) - Wire up _RDEPENDS parsing to build reverse deps (sonic-net#12) - Remove unnecessary 'if v' filter on rdeps JSON (sonic-net#13) - Remove unused REPORT_FORMAT parameter (sonic-net#15) - Add cycle detection to critical path algorithm (sonic-net#16) - Add execute permission check for companion scripts (sonic-net#17) Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com> --------- Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com> Co-authored-by: Rustiqly <rustiqly@users.noreply.github.com> Signed-off-by: Feng Pan <fenpan@microsoft.com>
What I did
Add three build instrumentation scripts and a
make build-reporttarget for analyzing SONiC build performance.Scripts
scripts/build-timing-report.shParses per-package timing from build logs (HEADER/FOOTER timestamps in
target/*.log). Generates:scripts/build-dep-graph.pyParses all
rules/*.mkfiles to extract the dependency graph (_DEPENDS,_AFTER,_RDEPENDS, etc.). Generates:scripts/build-resource-monitor.shSamples system resources during builds (CPU, memory, disk I/O, Docker containers) at configurable intervals. Outputs CSV for correlation with build timeline.
Make target
make build-reportruns timing + dependency analysis after a build completes.Why I did it
Build performance optimization requires measurement. Currently there is no aggregated view of per-package timing or dependency bottlenecks. These tools provide the baseline data needed to identify and prioritize optimization opportunities.
Example findings from a VS build (24-core, 30GB RAM, JOBS=4):
How I verified it
Ran all three scripts against a successful nightly VS build: