From 9702c4fd64768e8c4fe0c8b8b7bb5dd6198d7f8c Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 2 Mar 2021 21:29:32 +0100 Subject: [PATCH] more logging in sync write --- src/matrix/room/Room.js | 6 ++++++ src/matrix/room/RoomSummary.js | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/matrix/room/Room.js b/src/matrix/room/Room.js index 0f4d80ab..392ef264 100644 --- a/src/matrix/room/Room.js +++ b/src/matrix/room/Room.js @@ -219,6 +219,8 @@ export class Room extends EventEmitter { await log.wrap("syncWriter", log => this._syncWriter.writeSync(roomResponse, txn, log), log.level.Detail); if (decryptChanges) { const decryption = await decryptChanges.write(txn); + log.set("decryptionResults", decryption.results.size); + log.set("decryptionErrors", decryption.errors.size); if (this._isTimelineOpen) { await decryption.verifySenders(txn); } @@ -229,6 +231,7 @@ export class Room extends EventEmitter { } decryption.applyToEntries(entries); } + log.set("entries", entries.length); let shouldFlushKeyShares = false; // pass member changes to device tracker if (roomEncryption && this.isTrackingMembers && memberChanges?.size) { @@ -240,6 +243,9 @@ export class Room extends EventEmitter { entries, isInitialSync, !this._isTimelineOpen, this._user.id); // write summary changes, and unset if nothing was actually changed summaryChanges = this._summary.writeData(summaryChanges, txn); + if (summaryChanges) { + log.set("summaryChanges", summaryChanges.diff(this._summary.data)); + } // fetch new members while we have txn open, // but don't make any in-memory changes yet let heroChanges; diff --git a/src/matrix/room/RoomSummary.js b/src/matrix/room/RoomSummary.js index 2f1e7703..8c7c8576 100644 --- a/src/matrix/room/RoomSummary.js +++ b/src/matrix/room/RoomSummary.js @@ -169,6 +169,18 @@ class SummaryData { this.cloned = copy ? true : false; } + diff(other) { + const props = Object.getOwnPropertyNames(this); + return props.reduce((diff, prop) => { + if (prop !== "cloned") { + if (this[prop] !== other[prop]) { + diff[prop] = this[prop]; + } + } + return diff; + }, {}); + } + cloneIfNeeded() { if (this.cloned) { return this;