Skip to content

perf(esp32): record the core leg of the concurrent compile region (#1414) - #1816

Merged
zackees merged 3 commits into
mainfrom
agent/perf-compile-core-phase
Oct 31, 2026
Merged

zackees merged 3 commits into
mainfrom
agent/perf-compile-core-phase

Conversation

@zackees

@zackees zackees commented Oct 31, 2026

Copy link
Copy Markdown
Member

Part of #1414 (item 2: "compile-core-variant costs 1.14 s having compiled nothing").

The defect

compile_core_and_sketch runs the framework-core and sketch source sets under one tokio::join!, and the compile-core-variant phase guard covers that join. The phase therefore reports the longer leg, not the core's cost. On a hydrated core cache the core set compiles zero files but still inherits the sketch TU's compile time, so the perf log claims the core spent ~1.3 s compiling nothing.

That is the measurement #1414 item 2 recorded (1,137 ms, "Compiled 0 files"), and it is why the issue's phase table reads as if core compilation were a hot spot.

The change

  • Record compile-core from the core set's own start (before submission), alongside the existing compile-sketch. Both legs are now independent numbers.
  • Keep compile-core-variant as the region measurement, and document that it is the join — the longer of the two legs — so it is no longer readable as "time the core spent".
  • PerfTimer::recorded(name) returns one phase's duration; PerfTimer::activate() forces recording without depending on the cached FBUILD_PERF_LOG OnceLock. Together they let the phase accounting be asserted in tests instead of eyeballed from a log line.

Verification (real builds, FBUILD_PERF_LOG_JSON)

Built fbuild-cli + fbuild-daemon from this branch and ran a fresh esp32-s3-devkitc-1 project directory (arduino-esp32 3.3.12, xtensa-esp-elf 14.2.0), daemon stopped beforehand so the env applies:

scenario compile-core compile-sketch compile-core-variant total
cold (60 core TUs compiled) 2670.7 ms 1341.3 ms 2670.7 ms 5356 ms
hydrated core cache (0 core TUs) 128.8 ms 659.6 ms 659.5 ms 2909 ms

Cold: the region correctly tracks the core (the longer leg). Hydrated: the old log attributed 660 ms to the core while it compiled nothing — the new log says 129 ms, which is the real cost of resolving/stating the 60 already-fresh core objects. That 129 ms residual (not zero) is the next thing worth looking at, and it is now visible.

Tests

  • compile_phases_tests.rs: empty core set records a near-zero compile-core while compile-sketch carries the 60 ms fake compile delay, and the region spans the sketch leg; with two core TUs both legs are recorded independently.
  • perf_log unit tests for recorded (accumulates, None for an unrecorded phase) and activate.
soldr cargo test -p fbuild-build-esp --lib compile_phases  -> 2 passed; 0 failed
soldr cargo test -p fbuild-build-engine --lib perf_log     -> 7 passed; 0 failed
TMPDIR=/home/niteris/t bash test                            -> 4086 passed; 0 failed; 110 ignored (rc 0)
soldr cargo fmt --check                                     -> rc 0
soldr cargo clippy --workspace --all-targets -- -D warnings -> rc 0
ci/check_test_layout.py -> ok    ci/enforce_platform_boundary.py -> rows=44 dylint_rows=43

No behaviour change: this only separates two measurements that were already being taken.

)

compile-core-variant spans a tokio::join! of the core and sketch source
sets, so with a hydrated core cache (zero files compiled) it reported the
sketch's compile time as if it were the core's. Record compile-core from
the core set's own start, alongside the existing compile-sketch, and
document that the region is the join rather than either leg.

Adds PerfTimer::recorded/activate so a caller can assert on one phase
without re-parsing the summary line or mutating process env.
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@zackees

zackees commented Oct 31, 2026

Copy link
Copy Markdown
Member Author

CI note: linux / Check (ubuntu-latest), linux / Python facade tests, Inventory (linux/windows), board validation and Build fbuild are all green, but the required Dylint context fails in setup, before any lint runs:

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> dylint_driver-6.2.0/build/main.rs:5:1
##[error]setup-soldr failed: Error: soldr dylint prepare failed with exit code 1

soldr reports that dylint 6.2.0 has no pre-deployed driver for nightly-2026-05-28 (the channel all 28 dylints/*/rust-toolchain.toml pin) and only ships one for nightly-2026-08-15. Reproduced on a --failed rerun of 41179829243. main was green on the same workflow at 05:51Z, so this is toolchain drift, not this diff. Filed as #1818.

This PR stays unmerged until the pin bump lands; nothing in the diff needs to change.

The custom `ban_std_pathbuf` dylint scans test code too, and the new
compile_phases fixture returned `Vec<std::path::PathBuf>`; Dylint Full failed
on it once the 6.2.0 re-pin (#1819) let the lane actually run. Return
`Vec<NormalizedPath>` instead (it implements `AsRef<Path>`, so
`CompileTarget` is unchanged). Behavior identical: the same two tests pass.
@zackees
zackees added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 7683e35 Oct 31, 2026
36 checks passed
@zackees
zackees deleted the agent/perf-compile-core-phase branch October 31, 2026 10:08
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant