From 9236f595244d8879972a74264f7e43ffcd3a7b06 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Thu, 26 Aug 2021 08:36:08 -0700 Subject: [PATCH] Log additional latency information on sends --- ts/models/conversations.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index e42b5f8c87..c099f836e7 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -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!