Skip to content

⚡️cron: arm a one-shot timer for the next job instead of polling at 1 Hz#1659

Merged
gmarull merged 1 commit into
coredevices:mainfrom
Coral-coder:pr/cron-one-shot
Jul 17, 2026
Merged

⚡️cron: arm a one-shot timer for the next job instead of polling at 1 Hz#1659
gmarull merged 1 commit into
coredevices:mainfrom
Coral-coder:pr/cron-one-shot

Conversation

@Coral-coder

@Coral-coder Coral-coder commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Power tweak — one of a series of idle-wakeup reductions that let the SoC spend more time in deep sleep. Companion PRs: #1658 · #1659 · #1660 · #1661 · #1662 · #1663.

The cron service registered a per-second regular_timer callback that locked the job-list mutex and compared the head job's execute time against the clock 86400 times a day, almost always concluding there was nothing to do. Cron already knows exactly when the next job is due, so arm a one-shot new_timer for that instant instead and re-arm on every list mutation (schedule, schedule_after, unschedule, clear) and firing.

Job execution semantics are unchanged: callbacks still run on the timer task at the same second they used to, offset_seconds resolution is preserved, and cron_service_handle_clock_change() still runs due jobs and now re-arms for the new head. The armed interval is capped at one hour so any tick-clock drift across long sleeps stays bounded.

(cherry picked from commit 90a67da)

@Coral-coder Coral-coder changed the title cron: arm a one-shot timer for the next job instead of polling at 1 Hz ⚡️cron: arm a one-shot timer for the next job instead of polling at 1 Hz Jul 9, 2026
@jplexer
jplexer force-pushed the pr/cron-one-shot branch from f3638d3 to 169fb37 Compare July 16, 2026 13:34

@jplexer jplexer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(fixed an edge case)

@jplexer
jplexer force-pushed the pr/cron-one-shot branch from 169fb37 to 94829ff Compare July 16, 2026 14:48
The cron service registered a per-second regular_timer callback that
locked the job-list mutex and compared the head job's execute time
against the clock 86400 times a day, almost always concluding there was
nothing to do. Cron already knows exactly when the next job is due, so
arm a one-shot new_timer for that instant instead and re-arm on every
list mutation (schedule, schedule_after, unschedule, clear) and firing.

Job execution semantics are unchanged: callbacks still run on the timer
task at the same second they used to, offset_seconds resolution is
preserved, and cron_service_handle_clock_change() still runs due jobs
and now re-arms for the new head. The armed interval is capped at one
hour so any tick-clock drift across long sleeps stays bounded.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: GPT-5 <noreply@openai.com>
Signed-off-by: Ara Michelle <coral-coder@proton.me>
(cherry picked from commit 90a67da)
Signed-off-by: Joshua Jun <lets@throw.rocks>
@jplexer
jplexer force-pushed the pr/cron-one-shot branch from 94829ff to 93147f7 Compare July 16, 2026 15:03
@gmarull
gmarull merged commit c5e1fa9 into coredevices:main Jul 17, 2026
42 checks passed
@Coral-coder
Coral-coder deleted the pr/cron-one-shot branch July 17, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants