Repository navigation
perf(cron): skip history checks for future jobs - #128048
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 6:29 PM ET / 22:29 UTC. ClawSweeper reviewWhat this changesThis PR skips Cron run-history status lookup on ordinary scheduler scans when a job has a finite next wake strictly in the future. Merge readinessKeep this maintainer-authored PR open for ordinary exact-head CI and merge review. The early return is at the runnable-job owner, preserves startup missed-run recovery, and current main still has the pre-optimization path. Priority: P3 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherCron loads persisted jobs, filters runnable jobs, and dispatches due work. This change short-circuits ordinary no-due scans before status and backoff logic while leaving startup recovery on its history-aware path. flowchart LR
A[Persisted Cron jobs] --> B[Timer scan]
B --> C[Runnable-job filter]
C --> D{Future finite wake on ordinary tick?}
D -->|Yes| E[Skip history lookup]
D -->|No or startup recovery| F[Status and backoff checks]
F --> G[Due-job selection]
G --> H[Job execution]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +9. Total +9 across 1 file. View PR surface stats
Review metrics
Technical reviewBest possible solution: Land the owner-level future-wake short circuit once the remaining exact-head checks and normal merge gates are satisfied. Do we have a high-confidence way to reproduce the issue? Yes, at source level: ordinary ticks resolve status before discovering a finite future wake, while startup recovery explicitly takes the separate history-aware option. The PR body also supplies a differential benchmark, though this read-only review did not execute it. Is this the best way to solve the issue? Yes. The guard belongs in the runnable-job owner before the pure status coalescer; moving it into startup recovery would risk suppressing the missed-slot behavior that recovery deliberately enables. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against aca83ac00c7b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Land-ready verification
Reproduction and semantic proof
Executed checks
No live Gateway run was needed: this is a deterministic internal due-selection predicate with exact differential, owner/sibling/full-suite, build, and hosted exact-head proof. ClawSweeper's exact-head review (run 32602306206) found no review or security findings, rated the patch correct at 0.93 confidence, and listed no rank-up moves. Its one generic pre-merge item was to await exact-head CI and maintainer merge review; both are now satisfied by run 32602232212 and the validated native review/prepare artifacts. Its terminal proof command referenced the nonexistent path |
|
Merged via squash.
|
What Problem This Solves
Resolves a problem where ordinary Cron scheduler ticks normalized run history for every enabled, inactive job even when its finite
nextRunAtMsalready proved that the job was strictly in the future. Large resident job stores paid this avoidable work on every no-due or small-due scan.Why This Change Was Made
The runnable-job owner now checks the already-persisted next wake before run-history normalization, but only for ordinary ticks. Startup missed-run recovery retains the existing history-aware path, and due/error paths reuse the status already resolved by the owner.
This change was AI-assisted. I reviewed the complete owner, caller, recovery, backoff, and one-shot paths and understand the resulting behavior.
User Impact
Operators with large Cron job stores should see lower scheduler CPU and due-selection latency when most jobs are scheduled in the future. Runnable selection, ordering, startup catch-up, retries, persistence, and delivery behavior are unchanged.
Evidence
dfdbbd3339cb38e7c529cb1a03628cd363d2908c; parent/current-main baseline:b7cafbe7e82686b14c0f7c8e7af83194fd05ad42.75defa96e5f60caaebc78515088b78b4c05df29a1856f3afc3269c9d251806be.node scripts/check-changed.mjs -- src/cron/service/timer-runnable.ts: passed formatting, typechecks, lint, dead exports, guards, and import-cycle checks.pnpm build: passed all core, package, plugin, SDK, postbuild, and Control UI phases.dfdbbd3339cb38e7c529cb1a03628cd363d2908c.OPENCLAW_TESTBOX=1 scripts/pr prepare-run 128048: passed inhosted_exact_or_recent_parentmode without changing the PR head.keep_open, patch correct at 0.93 confidence, no review/security findings, and no rank-up moves. Its terminal proof used the nonexistent pathsrc/cron/service/restart-catchup.test.ts; rerunning the repository-native command against the actual exact-head file,node scripts/run-vitest.mjs src/cron/service.restart-catchup.test.ts, passed 1 file / 26 tests.collectRunnableJobs, due selection, or this performance cause. Open feat(cron): shell precheck gate to skip LLM when no work #112375 adds a separate pre-execution shell gate and does not touchtimer-runnable.ts.