Log long write transactions

This commit is contained in:
Michelle Linington 2022-03-01 23:06:00 -08:00
parent e322921b10
commit 06af94e7a2

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
//
import Foundation
@ -364,10 +364,12 @@ public class SDSDatabaseStorage: SDSTransactable {
#endif
let benchTitle = "Slow Write Transaction \(Self.owsFormatLogMessage(file: file, function: function, line: line))"
let timeoutThreshold = DebugFlags.internalLogging ? 0.1 : 0.5
InstrumentsMonitor.measure(category: "db", parent: "write", name: Self.owsFormatLogMessage(file: file, function: function, line: line)) {
do {
try grdbStorage.write { transaction in
Bench(title: benchTitle, logIfLongerThan: 0.1, logInProduction: DebugFlags.internalLogging) {
Bench(title: benchTitle, logIfLongerThan: timeoutThreshold, logInProduction: true) {
block(transaction.asAnyWrite)
}
}