ChargeInsightsStore was saving every 5s (aggregated sample) and 15s (session state), causing a continuous CloudKit WAL checkpoint loop and high CPU. Increased intervals to 30s and 60s respectively — the 12s sample bucket makes sub-bucket saves redundant, and a 60s session flush is sufficient for a multi-hour charge. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@@ -36,8 +36,8 @@ final class ChargeInsightsStore {
|
||
| 36 | 36 |
private let context: NSManagedObjectContext |
| 37 | 37 |
private let stopDetectionHoldDuration: TimeInterval = 20 |
| 38 | 38 |
private let maximumLiveIntegrationGap: TimeInterval = 20 |
| 39 |
- private let activeSessionSaveInterval: TimeInterval = 15 |
|
| 40 |
- private let aggregatedSampleSaveInterval: TimeInterval = 5 |
|
| 39 |
+ private let activeSessionSaveInterval: TimeInterval = 60 |
|
| 40 |
+ private let aggregatedSampleSaveInterval: TimeInterval = 30 |
|
| 41 | 41 |
private let counterDecreaseTolerance = 0.002 |
| 42 | 42 |
private let completionConfirmationCooldown: TimeInterval = 15 * 60 |
| 43 | 43 |
private let pausedSessionTimeout: TimeInterval = 10 * 60 |