Commit Graph
667 Commits
Author SHA1 Message Date
J. Nick Koston 99c80b7dfa [ci] Address copilot review feedback on import-time check
- determine-jobs: trigger on changes to requirements_test.txt too; that
  file is hashed into the venv cache key and installed during
  restore-python, so a change there can alter the import environment.
- ci.yml: merge the --check and --har steps so we only run
  importtime-waterfall once per job (was measuring twice: ~7-8s of
  wasted CI time per run). Uses the new script/check_import_time.py
  --check --har <path> combination; the HAR reflects the same
  measurement that produced the pass/fail decision.
- script/check_import_time.py: refactor the CLI so --har is a standalone
  option rather than a mutually-exclusive mode. --check and --update
  each accept an optional --har PATH that writes the HAR from the same
  subprocess invocation. Plain --har is still supported for local use.
- tests: add tests/script/test_check_import_time.py covering HAR parsing,
  root lookup, offender ranking/dedup, budget round-trip, and the three
  --check exit paths (pass, regression, missing budget) plus the new
  --check --har combined write. Add requirements_test.txt case to the
  should_run_import_time parametrized test.
2026-04-23 14:47:03 -05:00
J. Nick Koston 6b7e834174 [ci] Always print top import-time offenders, not just on regression
Seeing the top contributors every run — regression or not — gives
reviewers and future-PR authors a running reference for which imports
are currently most expensive. That's the data we need to prioritize
lazy-import refactors, so there's no reason to hide it on pass.
2026-04-23 14:23:27 -05:00
J. Nick Koston 64e000de13 [ci] Tighten import-time margin to 15%
CI measured 126.2ms against 123ms baseline + 25% ceiling (153.8ms). That's
27.6ms of headroom — enough slack that a real regression could hide under
it. Drop to 15% (ceiling 141.5ms, ~15ms headroom over observed). Still
well above GHA runner variance, tight enough to catch the class of
regression we care about (zeroconf-style top-level import additions).
2026-04-23 14:22:33 -05:00
J. Nick Koston 900232be21 [ci] Parse importtime-waterfall HAR JSON; raise budget for CI runner
The previous parser walked `-X importtime` stderr by hand (string-splitting
on `|`, indent-width math). Replace it with a load of the HAR JSON that
importtime-waterfall already produces: each entry carries the module name,
self-time, and cumulative — no tree reconstruction needed. Drops the
hand-rolled retry loop too, since importtime-waterfall does best-of-6
internally.

The committed budget (75.2ms) was seeded on a fast local machine; GHA
runners measured 122.8ms, so the first CI run tripped the check. Reset
the baseline to 123ms with a 25% margin (ceiling ~154ms) to absorb GHA
variance. Tighten later once we have several data points.

Adds unit tests for should_run_import_time across the trigger matrix and
wires the new mock into the existing test_main_* suite.
2026-04-23 14:20:31 -05:00
J. Nick Koston 0dd2a57ba4 [ci] Add import-time regression check for esphome.__main__
Adds a CI gate that runs `python -X importtime -c "import esphome.__main__"`
via importtime-waterfall's best-of-N harness, compares the root cumulative
time against a checked-in budget (script/import_time_budget.json, seeded
at 75.2ms with a 15% margin), and fails the build when top-level imports
regress.

The CLI pays this cost on every invocation before the requested command
even runs, so silently adding a top-level dep chain (the recent zeroconf
move in #13135 being the motivating case) hurts every user. The check
gives us a signal without waiting for user reports.

- script/check_import_time.py: --check / --update / --har PATH modes.
  On regression, prints a ranked top-15 offenders table by self-time.
- script/import_time_budget.json: baseline + margin_pct.
- script/determine-jobs.py: should_run_import_time() gates the job on
  esphome/**/*.py, requirements.txt, requirements_dev.txt, pyproject.toml,
  or changes to the check itself.
- .github/workflows/ci.yml: new import-time job, runs when gated and
  uploads a waterfall HAR artifact (14-day retention) for inspection.
2026-04-23 14:13:01 -05:00
J. Nick Koston b8165a0ad9 Merge remote-tracking branch 'upstream/dev' into integration 2026-04-22 18:33:03 -05:00
Keith Burzinski 70b1d9a087 [api_protobuf] Support compound ifdef conditions in proto generator (#15930) 2026-04-22 17:57:15 -05:00
J. Nick Koston 67576d4879 [rp2040] Tune oversized lwIP defaults for ESPHome (#14843) 2026-04-22 06:29:13 +02:00
J. Nick Koston 00da5d0a26 Merge remote-tracking branch 'upstream/fast-millis-esp32' into integration 2026-04-21 04:55:03 +02:00
J. Nick Koston 0d3a3552da [core] Move heap-allocating helpers to alloc_helpers.h/cpp (#15623) 2026-04-21 04:39:49 +02:00
J. Nick Koston ba775b7a0a Merge remote-tracking branch 'upstream/dev' into integration 2026-04-18 16:23:21 -05:00
J. Nick KostonandCopilot Autofix powered by AI b293be23b0 [ci] Honor CONFLICTS_WITH when grouping component tests (#15834)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-04-18 08:11:38 -05:00
J. Nick Koston e347d65b64 Merge remote-tracking branch 'upstream/sensor/throttle-with-priority-nan-specialize' into integration 2026-04-18 06:32:18 -05:00
J. Nick Koston c122fc8c78 [ci] Apply conflict split before CI batch distribution
Previously split_conflicting_groups ran only inside test_build_components.
The CI-side batcher (split_components_for_ci.py / determine-jobs.py)
still saw the pre-split group, so its weight budgeting assumed one build
where runtime produces two. Apply the split where the groups are formed
so batch distribution reflects actual build counts.
2026-04-18 06:30:03 -05:00
J. Nick Koston 897dd7cd5e [ci] Move conflict-aware grouping helpers into script/helpers.py with tests 2026-04-18 06:26:03 -05:00
J. Nick Koston 698dbbdcb5 [ci] Simplify conflict walk 2026-04-18 06:21:43 -05:00
J. Nick Koston 875de948e8 [ci] Scope conflict parsing to batch components only 2026-04-18 06:19:35 -05:00
J. Nick Koston 9e714a3942 [ci] Clean up AST-target dispatch in _component_conflicts 2026-04-18 06:18:02 -05:00
J. Nick Koston fe00a5445e [ci] Honor CONFLICTS_WITH when grouping component tests
The test-grouping pipeline merged components that share a bus signature
into a single config without checking CONFLICTS_WITH. When
bme68x_bsec2 declared CONFLICTS_WITH=["bme680_bsec"] (and vice versa),
the merged YAML containing both failed validation.

Statically parse AUTO_LOAD and CONFLICTS_WITH from every component
__init__.py, propagate conflicts through AUTO_LOAD, and split any
group that contains a conflicting pair into separate builds.
2026-04-18 06:15:40 -05:00
J. Nick Koston fd42f43da0 Merge remote-tracking branch 'upstream/dev' into integration 2026-04-15 19:46:17 -10:00
J. Nick Koston e7194dce75 [core] Deduplicate entity type boilerplate with X-macro pattern (#15618) 2026-04-15 17:45:01 -10:00
J. Nick Kostonandpre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> 53ce2a2f7f [api] Add speed_optimized to SubscribeLogsResponse (#15698)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-04-14 06:25:05 +12:00
J. Nick Koston 34c617f046 Merge branch 'proto-speed-log-response' into integration 2026-04-12 22:45:34 -10:00
J. Nick Koston 4bcf3b9661 fix existing bug 2026-04-12 22:44:02 -10:00
J. Nick Koston b4982b9bff Merge remote-tracking branch 'upstream/proto-speed-log-response' into integration 2026-04-12 21:50:41 -10:00
J. Nick Kostonandpre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> 5b4385a084 [api] Add speed_optimized proto option for hot encode paths (#15691)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-04-13 07:42:31 +00:00
J. Nick Koston c62a75ee17 [benchmark] Use -Os to match firmware optimization level (#15688) 2026-04-13 01:40:33 -05:00
J. Nick Koston 1703602c0f Merge branch 'proto-speed-optimized-v2' into integration 2026-04-12 20:30:34 -10:00
pre-commit-ci-lite[bot] a463e25aa1 [pre-commit.ci lite] apply automatic fixes 2026-04-13 06:23:08 +00:00
J. Nick Koston 603d5a2b54 Fix clang-tidy NOLINT for optimize(O2) in generated protobuf code 2026-04-12 20:21:43 -10:00
J. Nick Koston 830af94b2c Merge branch 'app-loop-optimize-speed' into integration 2026-04-12 19:57:45 -10:00
J. Nick Koston e1ea9cb66b Revert "Merge branch 'benchmark-crypto-o2' into integration"
This reverts commit c58447ad3a, reversing
changes made to 3b02c6d5ef.
2026-04-12 19:26:54 -10:00
J. Nick Koston d217ab3cd4 [api] Add speed_optimized proto option for hot encode paths
Add a new (speed_optimized) message option that emits
__attribute__((optimize("O2"))) on the generated encode() and
calculate_size() methods. Under -Os, GCC does not inline the small
ProtoEncode helpers (write_raw_byte, encode_varint, etc.) into the
generated methods, causing significant overhead on hot paths.

Apply to SensorStateResponse and BluetoothLERawAdvertisementsResponse
which are the highest-frequency encode paths.
2026-04-12 19:23:39 -10:00
J. Nick Koston 70dd732821 [api] Add speed_optimized proto option for hot encode paths
Add a new (speed_optimized) message option that emits
__attribute__((optimize("O2"))) on the generated encode() and
calculate_size() methods. Under -Os, GCC does not inline the small
ProtoEncode helpers (write_raw_byte, encode_varint, etc.) into the
generated methods, causing significant overhead on hot paths.

Apply to SensorStateResponse and BluetoothLERawAdvertisementsResponse
which are the highest-frequency encode paths.
2026-04-12 19:21:47 -10:00
J. Nick Koston c58447ad3a Merge branch 'benchmark-crypto-o2' into integration 2026-04-12 19:17:20 -10:00
J. Nick Koston 02f828fcbf [benchmark] Use -Os to match firmware optimization level
CodSpeed benchmarks were building with -O2, while all firmware
targets (ESP8266, ESP32, LibreTiny) use -Os. This mismatch means
the benchmarks cannot detect inlining regressions that affect real
devices — GCC under -O2 inlines functions that -Os outlines due to
its size-conscious cost model.

Switch to -Os with -ffunction-sections/-fdata-sections for proper
dead-code stripping (needed because -Os preserves references that
-O2 optimizes away at compile time).
2026-04-12 18:37:50 -10:00
J. Nick Koston ab64916c37 [benchmark] Use -Os to match firmware optimization level
CodSpeed benchmarks were building with -O2, while all firmware
targets (ESP8266, ESP32, LibreTiny) use -Os. This mismatch means
the benchmarks cannot detect inlining regressions that affect real
devices — GCC under -O2 inlines functions that -Os outlines due to
its size-conscious cost model.

Remove the -Os unflag and -O2 override so benchmarks use the
platform default -Os, matching what actually runs on devices.
2026-04-12 18:32:03 -10:00
J. Nick Koston ec420d5792 [api] Add (inline_encode) proto option for sub-message inlining (#15599) 2026-04-10 15:33:56 +12:00
J. Nick Koston efa334b79c Merge remote-tracking branch 'origin/entity-types-xmacro' into integration 2026-04-09 14:57:57 -10:00
J. Nick Koston 053cee4ec9 [core] Use ENTITY_TYPES_H_TARGET constant in helpers.py 2026-04-09 14:52:37 -10:00
J. Nick Koston 7d87b32033 [core] Exclude entity_types.h from clang-tidy all-include.cpp
The X-macro file requires macros to be defined before inclusion and
cannot be included bare in the clang-tidy all-include header.
2026-04-09 14:52:04 -10:00
J. Nick Koston affb20a9cf [core] Rename entity_types.inc to entity_types.h
Neither PlatformIO nor ESP-IDF/CMake copy .inc files to the build
directory. Rename to .h so it's recognized by both build systems.
Exempt from pragma-once lint since this file is intentionally included
multiple times with different macro definitions.
2026-04-09 14:44:52 -10:00
J. Nick Koston b9d0f96053 Merge remote-tracking branch 'origin/inline-encode-ble-adv' into integration 2026-04-09 11:57:55 -10:00
J. Nick Koston 781ab59611 Remove duplicate unrolled inline size cases, always use loop 2026-04-09 00:16:07 -10:00
J. Nick Koston 382202334a Simplify field_ifdef handling in inline blocks 2026-04-09 00:15:24 -10:00
J. Nick Koston 277552cef0 Address review: reserve_byte, varint(0), field_ifdef, getattr guard 2026-04-09 00:13:36 -10:00
J. Nick Koston 1279e6112a Support max_data_length in get_max_encoded_size for string types 2026-04-08 23:42:08 -10:00
J. Nick Koston 24edb9c98e Eliminate sub_size variable, accumulate directly into size 2026-04-08 23:29:51 -10:00
J. Nick Koston 1ac2a73267 Remove redundant body_start variable in inline encode 2026-04-08 23:25:12 -10:00
J. Nick Koston 14a4a2c618 Remove redundant block scoping inside loop bodies 2026-04-08 23:12:47 -10:00