Log additional latency information on sends

This commit is contained in:
Fedor Indutny 2021-08-26 08:36:08 -07:00 committed by GitHub
parent 418ce2eb51
commit 9236f59524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 0 deletions

View File

@ -111,6 +111,7 @@ const THREE_HOURS = durations.HOUR * 3;
const FIVE_MINUTES = durations.MINUTE * 5;
const JOB_REPORTING_THRESHOLD_MS = 25;
const SEND_REPORTING_THRESHOLD_MS = 25;
const ATTRIBUTES_THAT_DONT_INVALIDATE_PROPS_CACHE = new Set([
'profileLastFetchedAt',
@ -3674,10 +3675,23 @@ export class ConversationModel extends window.Backbone
const model = new window.Whisper.Message(attributes);
const message = window.MessageController.register(model.id, model);
const dbStart = Date.now();
await window.Signal.Data.saveMessage(message.attributes, {
forceSave: true,
});
const dbDuration = Date.now() - dbStart;
if (dbDuration > SEND_REPORTING_THRESHOLD_MS) {
window.log.info(
`ConversationModel(${this.idForLogging()}.sendMessage(${now}): ` +
`db save took ${dbDuration}ms`
);
}
const renderStart = Date.now();
this.addSingleMessage(model);
if (sticker) {
await addStickerPackReference(model.id, sticker.packId);
@ -3701,6 +3715,16 @@ export class ConversationModel extends window.Backbone
});
this.incrementSentMessageCount();
const renderDuration = Date.now() - renderStart;
if (renderDuration > SEND_REPORTING_THRESHOLD_MS) {
window.log.info(
`ConversationModel(${this.idForLogging()}.sendMessage(${now}): ` +
`render save took ${renderDuration}ms`
);
}
window.Signal.Data.updateConversation(this.attributes);
// We're offline!