Commit c5e1fa9
cron: arm a one-shot timer for the next job instead of polling at 1 Hz
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>1 parent d14cba9 commit c5e1fa9
2 files changed
Lines changed: 76 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | | - | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 19 | | |
24 | 20 | | |
25 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
26 | 50 | | |
27 | 51 | | |
28 | 52 | | |
| |||
49 | 73 | | |
50 | 74 | | |
51 | 75 | | |
| 76 | + | |
52 | 77 | | |
53 | 78 | | |
54 | 79 | | |
| |||
89 | 114 | | |
90 | 115 | | |
91 | 116 | | |
92 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
93 | 120 | | |
94 | 121 | | |
95 | 122 | | |
| |||
108 | 135 | | |
109 | 136 | | |
110 | 137 | | |
| 138 | + | |
111 | 139 | | |
112 | 140 | | |
113 | 141 | | |
| |||
135 | 163 | | |
136 | 164 | | |
137 | 165 | | |
| 166 | + | |
138 | 167 | | |
139 | 168 | | |
140 | 169 | | |
| |||
160 | 189 | | |
161 | 190 | | |
162 | 191 | | |
| 192 | + | |
163 | 193 | | |
164 | 194 | | |
165 | 195 | | |
| |||
181 | 211 | | |
182 | 212 | | |
183 | 213 | | |
| 214 | + | |
184 | 215 | | |
185 | 216 | | |
186 | 217 | | |
| |||
191 | 222 | | |
192 | 223 | | |
193 | 224 | | |
194 | | - | |
| 225 | + | |
195 | 226 | | |
196 | 227 | | |
197 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
17 | 33 | | |
18 | 34 | | |
19 | 35 | | |
| |||
36 | 52 | | |
37 | 53 | | |
38 | 54 | | |
| 55 | + | |
39 | 56 | | |
40 | 57 | | |
41 | 58 | | |
| |||
66 | 83 | | |
67 | 84 | | |
68 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
69 | 104 | | |
70 | 105 | | |
71 | 106 | | |
| |||
0 commit comments