From 5bb17bd27584b85cf9a9dd4d7af75107cf321075 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 29 May 2026 14:12:31 +0200 Subject: [PATCH] Pre-populate decompressed rule cach (#24799) --- CHANGELOG.md | 6 +++--- RELEASENOTES.md | 4 +++- tasmota/tasmota_xdrv_driver/xdrv_10_rules.ino | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86a33a156..c8ddde290 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,8 @@ All notable changes to this project will be documented in this file. - Berry manual tool to compare and verify solidification between C and Python (#24754) - ESP32 VID6608 hardware RMT support for Automotive gauge driver (#24759) - Support for uDisplay ST7305 (#24738) -- Support for hosted MCU different from esp32c6 -- Trigger events to Berry when `USE_RULES` is not enabled +- Support for hosted MCU other than esp32c6 +- Trigger events to Berry when `USE_RULES` is not enabled (#24796) ### Breaking Changed @@ -30,7 +30,7 @@ All notable changes to this project will be documented in this file. - NeoPool possible overflow/div-zero errors and Hydrolysis module detection (#24724) - Seesaw encoder position tracking in light control mode (#24730) - I80 pushColors swap logic for parallel displays (#24766) -- Crash when MQTT-TLS when tcp connection failed +- Crash when MQTT-TLS when tcp connection failed (#24798) ### Removed - `USE_UNIVERSAL_TOUCH` no more forced when `USE_UNIVERSAL_DISPLAY` is enabled (#24743) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 6d39ffd90..e41bfd2ab 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -121,7 +121,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Support for multi-byte chars like emojis (💡) in light device toggle buttons [#24482](https://github.com/arendst/Tasmota/issues/24482) - Support for M5Stack Atom S3R drivers [#24747](https://github.com/arendst/Tasmota/issues/24747) - Support for uDisplay ST7305 [#24738](https://github.com/arendst/Tasmota/issues/24738) -- Support for hosted MCU different from esp32c6 +- Support for hosted MCU other than esp32c6 +- Trigger events to Berry when `USE_RULES` is not enabled [#24796](https://github.com/arendst/Tasmota/issues/24796) - MiElHVAC extend support of AirDirection control [#24675](https://github.com/arendst/Tasmota/issues/24675) - ESP32 VID6608 hardware RMT support for Automotive gauge driver [#24759](https://github.com/arendst/Tasmota/issues/24759) - Berry add support for pre-processor [#24679](https://github.com/arendst/Tasmota/issues/24679) @@ -140,6 +141,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - LVGL splash screen uses default Montserrat-14 instead of Montserrat-20 on small screens [#24735](https://github.com/arendst/Tasmota/issues/24735) ### Fixed +- Crash when MQTT-TLS when tcp connection failed [#24798](https://github.com/arendst/Tasmota/issues/24798) - I80 pushColors swap logic for parallel displays [#24766](https://github.com/arendst/Tasmota/issues/24766) - NeoPool possible overflow/div-zero errors and Hydrolysis module detection [#24724](https://github.com/arendst/Tasmota/issues/24724) - Seesaw encoder position tracking in light control mode [#24730](https://github.com/arendst/Tasmota/issues/24730) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_10_rules.ino b/tasmota/tasmota_xdrv_driver/xdrv_10_rules.ino index b8f6a68a9..add950738 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_10_rules.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_10_rules.ino @@ -304,7 +304,7 @@ String GetRule(uint32_t idx) { // If the cache is empty, we need to decompress from Settings if (0 == k_rules[idx].length() ) { GetRule_decompress(rule, &Settings->rules[idx][1]); - if (!Settings->flag4.compress_rules_cpu) { + if (!Settings->flag4.compress_rules_cpu) { // SetOption93 - (Compress) Keep uncompressed rules in memory to avoid CPU load of uncompressing at each tick (1) k_rules[idx] = rule; // keep a copy for next time } } else { @@ -934,8 +934,7 @@ bool RulesProcess(void) { return false; } -void RulesInit(void) -{ +void RulesInit(void) { // indicates scripter not enabled bitWrite(Settings->rule_once, 7, 0); // and indicates scripter do not use compress @@ -947,6 +946,16 @@ void RulesInit(void) bitWrite(Settings->rule_enabled, i, 0); bitWrite(Settings->rule_once, i, 0); } +#ifdef USE_UNISHOX_COMPRESSION + else { + // Pre-populate k_rules[] cache here (FUNC_PRE_INIT), before WiFi/MQTT/WebServer + // allocate heap, so the persistent cache lands at low heap addresses instead of + // fragmenting the middle of the heap when first rule evaluation occurs later. + if (!Settings->flag4.compress_rules_cpu) { // SetOption93 - (Compress) Keep uncompressed rules in memory to avoid CPU load of uncompressing at each tick (1) + GetRule(i); + } + } +#endif } Rules.teleperiod = false; }