mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 10:40:47 +03:00
ESP-IDF Size Metrics Collection
Collects code size metrics for a curated set of apps and uploads them to the esp-metrics database once per CI pipeline.
How it works
- Extraction (per app, in build jobs):
IdfCMakeApp(tools/ci/idf_ci_local/app.py) callscollect_build_metrics.build_raw_metrics_for_build_dir()in_post_build(), while the map files still exist. For apps listed insize_metrics_config.ymlit runsesp-idf-size --archives --format json2on the app map file and adds best-effort bootloader size JSON and.binsize for apps that explicitly opt in. The rawbuild*/build_size_metrics.jsonartifact is written in_finalize(), after build-dir cleanup, and collected via**/build*/build_size_metrics.jsonin.dynamic_jobs.yml. - Aggregation + upload (single
app-size-metricsjob): runs after all builds (test_child_pipeline.yml).generate_metrics.pyaggregates the per-build fragments into one schema-shapedmetrics.json(next toschema.yaml), thenesp-metrics-cli upload -d schema.yaml -i metrics.json. One DB write per pipeline;esp-metrics-cli+ credentials live in this job only.
The size_*.json written by idf-build-apps is left untouched — other CI
consumers (e.g. the binary-size diff in MR build reports) depend on its default
format.
Metric types
Only apps listed in size_metrics_config.yml publish anything; all other built
apps are ignored.
| Family | What | When |
|---|---|---|
app_size |
Total flash/DRAM/IRAM usage | every listed app |
library_size |
Per-.a-archive (= per-component) breakdown |
listed apps with a libs key |
bootloader_size |
bootloader.bin size |
listed apps with bootloader: true |
Config (size_metrics_config.yml)
tools/test_apps/system/startup: # bare entry -> app_size only
examples/get-started/hello_world:
libs: all # every archive (empty `libs:` works too)
bootloader: true # include bootloader.bin size
configs: # only these build configs (omit -> all)
- default
examples/wifi/getting_started/station:
libs: # only these archives
- libesp_wifi.a
- libnet80211.a
targets: # only these targets (omit -> all)
- esp32c6
By default every built target/config of a listed app publishes metrics. The
optional configs and targets lists restrict publishing to specific build
configs/targets; libs/bootloader apply to every matching build.
Aggregating Fragments
cd tools/ci/metrics/size_metrics
python3 generate_metrics.py # fragments -> aggregated metrics.json (no upload)
generate_metrics.py accepts --config /path/to/config.yml.
Troubleshooting
- No metrics: Is the app listed in
size_metrics_config.yml? Do the build dirs still contain the app.mapfiles (extraction must run before cleanup)? - No
library_size: Does the app's entry have alibskey? Does the name match the archive exactly (e.g.libesp_timer.a)? Is PyYAML installed?