J. Nick Koston
82970b640f
merge
2025-07-20 12:27:51 -10:00
J. Nick Koston
232d3a8b89
Merge branch 'api_cleanups_2' into integration
2025-07-20 12:23:12 -10:00
J. Nick Koston
8becc57835
Merge branch 'empty_hidden_side_effects' into integration
2025-07-20 12:18:14 -10:00
J. Nick Koston
f6b989bd9a
cleanup
2025-07-20 12:15:16 -10:00
J. Nick Koston
109eae26a7
[core] Refactor scheduler to eliminate hidden side effects in empty_() method
2025-07-20 12:09:11 -10:00
@RubenKelevra and J. 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
112c6e34a5
move defines
2025-07-19 11:11:32 -10:00
J. Nick Koston
9119ac1c32
fix stale comments
2025-07-19 10:50:40 -10:00
J. Nick Koston
152e3ee587
make more readable
2025-07-19 10:43:57 -10:00
J. Nick Koston
acbcc5f9b8
make more readable
2025-07-19 10:40:21 -10:00
J. Nick Koston
5ed589fc97
make more readable
2025-07-19 10:39:27 -10:00
J. Nick Koston
58696961bd
make more readable
2025-07-19 10:38:28 -10:00
J. Nick Koston
a5f5af9596
make more readable
2025-07-19 10:36:49 -10:00
RubenKelevra
fde80bc530
core/scheduler: split millis_64_ into different platform functions
2025-07-19 21:44:35 +02:00
RubenKelevra
211739bba0
core/scheduler: Make millis_64_ rollover monotonic on SMP
...
The current implementation uses only memory_order_relaxed on all atomic
accesses. That protects each variable individually but not the semantic
link between the low word (last_millis_) and the high-word epoch counter
(millis_major_). On a multi-core target a reader could observe a freshly
stored low word before seeing the matching increment of the epoch,
causing a ~49-day negative jump.
Key fixes
- Release/acquire pairing
- writer: compare_exchange_weak(..., memory_order_release, …)
- reader: first load of last_millis_ now uses memory_order_acquire
- ensures any core that sees the new low word also sees the updated
high word
- Epoch-coherency retry loop
- re-loads millis_major_ after the update and retries if it changed,
guaranteeing monotonicity even when another core rolls over
concurrently
- millis_major_ promoted to std::atomic<uint16_t> on SMP platforms
- removes the formal data race at negligible cost
- new macros for better readability
- ESPHOME_SINGLE_CORE – currently ESP8266/RP2040 only
- ESPHOME_ATOMIC_SCHEDULER – all others except LibreTiny
- Logging and comments
- loads atomics safely in debug output
- updated inline docs to match the memory ordering
Behavior on single-core or non-atomic platforms is unchanged; multi-core
targets now get a provably monotonic 64-bit millisecond clock with
minimal overhead.
2025-07-19 19:09:10 +02:00
J. Nick Koston
72905f5f42
[libretiny] Remove unsupported lock-free queue and event pool implementations ( #9653 )
2025-07-18 23:40:14 +12:00
@RubenKelevra
f8146bd340
core/schedule: fixup out of sync code comment ( #9649 )
2025-07-17 18:54:01 -10:00
J. Nick Koston
f0f76066f3
[scheduler] Fix DelayAction cancellation in restart mode scripts ( #9646 )
2025-07-18 04:07:59 +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
b1048d6e25
Fix lwIP thread safety assertion failures on ESP32 ( #9570 )
2025-07-17 17:06:57 +12:00
Jesse Hills
b6e8f6398c
Revert "Bump ESP32 IDF version to 5.4.2 and Arduino version to 3.2.1" ( #9574 )
2025-07-17 10:25:57 +12:00
Jonathan Swoboda
c93b892ccc
Bump ESP32 IDF version to 5.4.2 and Arduino version to 3.2.1 ( #9305 )
2025-07-17 07:50:42 +12:00
J. Nick Koston and pre-commit-ci-lite[bot]
e40b45cab1
Add ability to have same entity names on different sub devices ( #9355 )
...
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2025-07-16 21:34:51 +12:00
J. Nick Koston
b1c86fe30e
Optimize scheduler timing by reducing millis() calls ( #9524 )
2025-07-16 13:41:55 +12:00
J. Nick Koston
30c4b91697
Remove parsed advertisement support from bluetooth_proxy to save memory ( #9489 )
2025-07-16 13:19:03 +12:00
J. Nick Koston and Keith Burzinski
e012fd5b32
Add runtime_stats component for performance debugging and analysis ( #9386 )
...
Co-authored-by: Keith Burzinski <kbx81x@gmail.com >
2025-07-16 13:13:51 +12:00
6ab3de65a6
remove duplication from component_iterator ( #7210 )
...
Co-authored-by: Samuel Tardieu <sam@rfc1149.net >
Co-authored-by: J. Nick Koston <nick@koston.org >
2025-07-16 13:02:14 +12:00
5d9cba3dce
[nrf52, core] nrf52 core based on zephyr ( #7049 )
...
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com >
Co-authored-by: Samuel Sieb <samuel-github@sieb.net >
Co-authored-by: Tomasz Duda <tomaszduda23@gmai.com >
Co-authored-by: J. Nick Koston <nick@koston.org >
2025-07-16 13:00:21 +12:00
J. Nick Koston and Copilot
9769f8a4cc
Fix timing overflow when components disable themselves during loop ( #9529 )
...
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com >
2025-07-15 21:51:01 +00:00
Jesse Hills and J. Nick Koston
d3342d6a1a
[component] Fix `is_ready` flag when loop disabled ( #9501 )
...
Co-authored-by: J. Nick Koston <nick@koston.org >
2025-07-15 07:20:18 +00:00
J. Nick Koston
d31b8ad2e2
Fix dormant bug in RAMAllocator::reallocate() manual_size calculation ( #9482 )
2025-07-14 00:58:07 +00:00
J. Nick Koston
f5c8595a46
Follow logging best practices by removing redundant component prefix ( #9481 )
2025-07-14 00:41:49 +00:00
J. Nick Koston
02d1894a9f
Refactor format_hex_pretty functions to eliminate code duplication ( #9480 )
2025-07-14 00:32:16 +00:00
J. Nick Koston
dd5ba5a90c
Conditionally compile API user services to save 4.3KB flash (follow-up to #9262 ) ( #9451 )
2025-07-11 19:08:03 -10: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
0d94246858
Exclude internal entities from name uniqueness validation ( #9410 )
2025-07-10 20:34:01 +12:00
Jesse Hills and RubenKelevra
05c5364490
[helpers] Fix `format_hex_pretty` resize without separator ( #9389 )
...
Co-authored-by: RubenKelevra <cyrond@gmail.com >
2025-07-08 22:13:21 +00:00
Jesse Hills
256f9f9943
[helpers] Improve `format_hex_pretty` ( #9380 )
2025-07-08 01:30:23 +00:00
J. Nick Koston
440de12e3f
Don't compile unnecessary platform files (e.g. ESP8266 files on ESP32) ( #9354 )
2025-07-08 09:04:41 +12:00
J. Nick Koston
fe258e1007
Refactor entity lookup methods with macros in preparation for device_id support ( #9371 )
2025-07-08 08:49:23 +12:00
J. Nick Koston
e2de6ee29d
Reduce core RAM usage by 40 bytes with static initialization optimizations ( #9340 )
2025-07-08 08:28:14 +12:00
J. Nick Koston
053feb5e3b
Optimize entity icon memory usage with USE_ENTITY_ICON flag ( #9337 )
2025-07-08 08:22:40 +12:00
J. Nick Koston
3ef392d433
Fix scheduler race conditions and add comprehensive test suite ( #9348 )
2025-07-08 07:57:55 +12:00
Jesse Hills
8147d117a0
[core] Move platform helper implementations into their own file ( #9361 )
2025-07-07 15:55:02 +00:00
e49b89a051
Introduce base Camera class to support alternative camera implementations ( #9285 )
...
Co-authored-by: J. Nick Koston <nick@koston.org >
Co-authored-by: J. Nick Koston <nick+github@koston.org >
2025-07-07 15:45:00 +12:00
J. Nick Koston
492580edc3
Split LockFreeQueue into base and notifying variants to reduce memory usage ( #9330 )
2025-07-07 14:50:14 +12:00
J. Nick Koston and Copilot
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 Koston
20ba035e3b
Reduce RAM usage by optimizing Color constant storage ( #9339 )
2025-07-05 22:30:18 -05:00