Rework database checkpointing.

This commit is contained in:
Matthew Chen 2021-07-07 15:13:30 -03:00
parent 6f232977ea
commit a444862311

View File

@ -566,10 +566,10 @@ extension GRDBDatabaseStorageAdapter: SDSDatabaseStorageAdapter {
checkpointBudget -= 1
return
}
// TODO: We might limit checkpoint frequency by time so that heavy write
// activity won't bog down the main thread. Ideally, checkpointing
// is fast enough that we don't need to do this.
var shouldCheckpoint = checkpointBudget <= 0
// Limit checkpoint frequency by time so that heavy write activity
// won't bog down the main thread.
let maxCheckpointFrequency: TimeInterval = 0.25
if shouldCheckpoint,
let lastSuccessfulCheckpointDate = self.lastSuccessfulCheckpointDate,