Commit Graph
66 Commits
Author SHA1 Message Date
J. Nick Koston c1328f1b3a [scheduler] Reduce set_timer_common_ hot path size by 25%
Restructure set_timer_common_ to reduce icache pressure on the hot path
(538 → 405 bytes on ESP32):

- Extract calculate_interval_offset_ as noinline helper - float math and
  random_float() only needed for intervals, not timeouts
- Extract is_retry_cancelled_locked_ as noinline helper - retry path is
  cold and deprecated (removal planned for 2026.8.0)
- Merge duplicated cancel+push_back epilogue by computing a target vector
  pointer (defer_queue_ vs to_add_) before the branch, converging both
  paths at a single cancel+push sequence
- Replace 4-way switch on name_type with unified set_name() method that
  does a single branch + store instead of 4 separate bitfield RMW
  sequences
- Remove now-unused individual name setters (set_static_name,
  set_hashed_name, set_numeric_id, set_internal_id)
2026-02-09 19:24:15 -06:00
J. Nick KostonandJonathan Swoboda e0712cc53b [scheduler] Make core timer ID collisions impossible with type-safe internal IDs (#13882)
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
2026-02-09 13:16:22 -06:00
J. Nick Koston 2383b6b8b4 [core] Deprecate set_retry, cancel_retry, and RetryResult (#13845) 2026-02-09 12:05:32 -06:00
J. Nick Koston 248fc06dac [scheduler] Eliminate heap allocation in full_cleanup_removed_items_ (#13837) 2026-02-09 08:44:20 -06:00
J. Nick Koston d5f557ad1c [scheduler] Eliminate heap allocations for std::string names and add uint32_t ID API (#13200) 2026-01-14 09:15:31 -05:00
J. Nick Koston 3d74d1e7f0 [libretiny] Regenerate boards, enable Cortex-M4 atomics, and consolidate platform code (#13191) 2026-01-13 21:39:11 +00:00
J. Nick Koston 861ed8dd41 [scheduler] Avoid std::string allocation in RetryArgs (#12311) 2025-12-09 09:27:12 -05:00
J. Nick Koston 05826d5ead [scheduler] Fix missing lock when recycling items in defer queue processing (#12343) 2025-12-07 13:30:22 -06:00
J. Nick Koston 80e881655f [scheduler] Fix use-after-free when cancelling timeouts from non-main-loop threads (#12288) 2025-12-04 19:14:22 -06:00
J. Nick Koston 1fadd1227d [scheduler] Fix use-after-move crash in heap operations (#12124) 2025-11-27 10:50:21 -06:00
J. Nick Koston 1888f5ffd5 [scheduler] Add defensive nullptr checks and explicit locking requirements (#11974) 2025-11-18 18:16:18 +00:00
J. Nick Koston fc546ca3f6 [scheduler] Fix timing breakage after 49 days of uptime on ESP8266/RP2040 (#11924) 2025-11-15 22:20:57 -06:00
J. Nick Koston df53ff7afe [scheduler] Extract helper functions to improve code readability (#11730) 2025-11-06 07:13:12 +13:00
J. Nick Koston 4a5e6576c8 [scheduler] Refactor call() for improved code organization (#11643) 2025-11-03 14:29:29 +13:00
J. Nick Koston f25af18655 [scheduler] Replace defer queue deque with vector to avoid 512-byte upfront allocation (#11305) 2025-10-20 07:34:34 +13:00
J. Nick Koston e2c5eeef97 [scheduler] Deduplicate item removal code with template helper (#11017) 2025-10-05 16:32:51 -05:00
J. Nick Koston ac07a00141 [scheduler] Fix timing accumulation in scheduler causing incorrect execution measurements (#10719) 2025-09-14 22:05:56 +00:00
J. Nick Koston 5cc0e21bc7 [core] Reduce unnecessary nesting in scheduler loop (#10644) 2025-09-09 09:04:07 +12:00
J. Nick Koston 8d90f13e97 [core] Store component source strings in flash on ESP8266 (breaking change) (#10621) 2025-09-07 20:10:00 -05:00
J. Nick KostonandCopilot 166ad942ef [scheduler] Reduce SchedulerItem memory usage by 7.4% on 32-bit platforms (#10553)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-09-07 18:51:07 -05:00
J. Nick Koston 28d16728d3 [core] Add memory pool to scheduler to reduce heap fragmentation (#10536) 2025-09-08 10:27:58 +12:00
J. Nick KostonandCopilot b25506b045 [core] Skip redundant process_to_add() call when no scheduler items added (#10630)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-09-08 09:10:55 +12:00
J. Nick Koston 61a5023888 [script] Fix parallel mode scripts with delays cancelling each other (#10324) 2025-08-25 08:49:52 +12:00
J. Nick Koston 6818439109 [core] Fix scheduler race condition where cancelled items still execute (#10268) 2025-08-18 11:14:41 -04:00
J. Nick Koston 85435e6b5f [scheduler] Eliminate more runtime string allocations from retry (#9930) 2025-07-29 08:54:16 +12:00
Clyde Stubbs 2b87589562 [scheduler] Fix null pointer crash (#9893) 2025-07-25 09:12:33 -10:00
J. Nick Koston 88ccde4ba1 [scheduler] Fix retry race condition on cancellation (#9788) 2025-07-25 08:14:15 -10:00
J. Nick Koston 1344103086 [core] Revert #9851 and rename ESPHOME_CORES to ESPHOME_THREAD (#9862) 2025-07-24 11:04:00 +00:00
Clyde Stubbs f9534fbd5d [interval] Fix startup behaviour (#9793) 2025-07-24 08:03:36 +10:00
J. Nick Koston ecd310dae1 [core] Refactor scheduler to eliminate hidden side effects in empty_ (#9743) 2025-07-20 23:11:30 +00:00
@RubenKelevraandJ. Nick Koston 6e31fb181e core/scheduler: Make millis_64_ rollover monotonic on SMP (#9716)
Co-authored-by: J. Nick Koston <nick@koston.org>
2025-07-20 21:57:52 +00:00
J. Nick Koston a18ddd1169 [scheduler] Fix LibreTiny compilation error due to missing atomic operations (#9643) 2025-07-18 14:21:46 +12:00
J. Nick Koston 158a3b2835 [scheduler] Fix cancellation of timers with empty string names (#9641) 2025-07-18 14:20:35 +12:00
J. Nick Koston dfa8c8c77f Fix scheduler rollover detection with concurrent task calls (#9624) 2025-07-17 13:07:36 -10:00
J. Nick Koston b1c86fe30e Optimize scheduler timing by reducing millis() calls (#9524) 2025-07-16 13:41:55 +12:00
J. Nick Koston bef20b60d0 Fix scheduler crash when cancelling items with NULL names (#9444) 2025-07-12 07:11:45 +12:00
J. Nick Koston 3ef392d433 Fix scheduler race conditions and add comprehensive test suite (#9348) 2025-07-08 07:57:55 +12:00
J. Nick KostonandCopilot b6fade7339 Fix defer() thread safety issues on multi-core platforms (#9317)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-07 10:01:51 +12:00
J. Nick KostonandCopilot 140ca070a2 Optimize scheduler string storage to eliminate heap allocations (#9251)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-30 15:40:36 +12:00
J. Nick Koston 7fc5bfd787 Reduce RAM usage for scheduled tasks (#9180) 2025-06-23 14:09:34 +12:00
487e1f871f use `encode_uintXX` (#8847)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-11 17:06:45 +12:00
J. Nick Koston 574aabdede Reduce number of calls to fetch time in the main loop (#8804) 2025-05-19 07:48:57 +12:00
Clyde Stubbs b8d83d0765 [debug] Show source of last software reboot (#8595) 2025-05-04 23:31:37 -05:00
Clyde Stubbs 58fe8b39b2 [scheduler] Properly handle millis() overflow (#8197) 2025-03-27 02:09:22 -05:00
Jimmy Hedman 979f014799 Make scheduler debuging work with idf >= 5 (#5052) 2023-07-05 22:05:27 +12:00
Jimmy Hedman 87c0f48095 Prepare debug and logger component to work with idf 5.0 (#5036) 2023-07-04 12:49:27 +12:00
Jörg Thalheim 421ebcc8b2 use PRIx macros for printing u32/i32 ints (#4671)
This fix compilation issues with the latest esp-idf.
2023-04-10 22:20:02 +00:00
Oxan van Leeuwen 86c0e6114f Lock scheduler items while modifying them (#4410)
* Cosmetic fixes to scheduler code

* Add generic Mutex API

* Lock scheduler items while modifying them

* Always defer MQTT callbacks on Arduino
2023-02-26 18:43:08 +00:00
Dan Jackson 029ac75a04 set_retry: add retries remaining parameter to the provided function (#4251) 2023-01-18 14:26:32 +13:00
Dan Jackson ff4fd497c4 Component::set_retry updates (#3305) 2022-12-22 20:48:15 +13:00