Pre-populate decompressed rule cach (#24799)

This commit is contained in:
Theo Arends
2026-05-29 14:12:31 +02:00
parent d3d33b452f
commit 5bb17bd275
3 changed files with 18 additions and 7 deletions
+12 -3
View File
@@ -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;
}