declutter
declutter copied to clipboard
Improve rule execution scheduling
Version: 1.13.x
Description
Currently, all rules are executed every X minutes according to a single global interval.
This approach is:
- Inefficient — rules that don’t need frequent execution still run.
- Inflexible — rules that need faster checks can’t override the interval.
Proposed improvements
- Store the last execution time (
last_run_ts) for each rule. - Allow per-rule schedule configuration (optional, falls back to global default).
- Calculate next execution time for each rule based on its last run + interval.
- Replace the fixed global timer with a dynamic scheduler that wakes only for the nearest due execution.
Expected benefits
- Reduced CPU wake-ups and unnecessary processing.
- More flexible scheduling per rule.
- Scales better with a larger set of rules.
Implementation notes (high-level)
-
DB schema update: add
exec_interval(nullable) andlast_run_ts(INTEGER) torulestable. -
Scheduler logic: compute the nearest
next_run_tsand set timer accordingly. - UI: add interval override option in rule edit form.
- Keep the global default interval in settings to use as fallback.