fix(rescore): retry an unfinished background pass after a cooldown instead of deferring until the app is opened - #2334
Conversation
…stead of deferring every offload until the app is opened
|
Thanks @Iskrata. The reasoning holds up and I checked the parts that could have bitten: One thing to fix before this goes in. The two new declarations landed inside /// Mark a re-score as owed. Called by `IntelligenceEngine` once a pass is past every gate and is
/// definitely about to work ...
/// Returns the token stamped on this debt. A pass keeps it and hands it back at completion; every
/// other caller (the deferral path) can ignore it, since it is not the one that will settle up.
/// When the last pass started (unix seconds), written only by a pass that is about to work ...
static let lastAttemptStartedAtKey = "noop.rescoreLastAttemptStartedAt"Swift merges consecutive Moving Worth saying that your Everything else is green and it merges clean. Push that and I will take it. |
|
Good catch, thanks. Moved |
|
That is it, thanks @Iskrata. Everything else stood on the first pass: one production caller of Merging. |
What this PR does
A backgrounded offload that finds a re-score already owed, with nothing running, now defers only while the last pass started less than 30 minutes ago (
RescoreBackgroundPolicy.interruptedRetryCooldownSeconds). After that it runs, paced as usual.markRescoreOwed(passStarting: true), fromIntelligenceEngine).Why
The owed rule dates from #1538, when a backgrounded pass was killed by the CPU limit every time and retrying on each offload was the livelock. Pacing (#2296, #2318) now keeps a background pass under that limit. But the rule still deferred on any unfinished debt, with no end, until a
BGProcessingTaskor the next foreground.On one phone (this fork's Release build with #2293 and #2318):
re-score: deferred to a background task — a re-score is already outstanding from an earlier trigger, roughly every 10 minutes.cpu_resource_fatalreports for NOOP. The app was terminated while suspended (the strap log rolled a fresh session at 15:55, 16:35 and 16:55 UTC), which iOS does routinely for memory.The cooldown keeps what #1538 needed, no retry on every offload, without letting one interrupted pass stop scoring for good.
Type of change
How it was tested
RescoreBackgroundPolicyTests:RescoreBackgroundSchedulerTests: a deferral does not make an old attempt look recent. The fixtures that model a just-killed pass now record their attempt time.IntelligenceRRSourceTestspass.doc_comment_lint.pyis clean.Android: nothing to port. Android has no equivalent deferral or background suspension.
Checklist
docs/CONTRIBUTING.mdStrand.xcodeproj/) or any secrets/keystores