more logging in sync write

This commit is contained in:
Bruno Windels 2021-03-02 21:29:32 +01:00
parent 8d7cb2a39a
commit 9702c4fd64
2 changed files with 18 additions and 0 deletions

View file

@ -219,6 +219,8 @@ export class Room extends EventEmitter {
await log.wrap("syncWriter", log => this._syncWriter.writeSync(roomResponse, txn, log), log.level.Detail); await log.wrap("syncWriter", log => this._syncWriter.writeSync(roomResponse, txn, log), log.level.Detail);
if (decryptChanges) { if (decryptChanges) {
const decryption = await decryptChanges.write(txn); const decryption = await decryptChanges.write(txn);
log.set("decryptionResults", decryption.results.size);
log.set("decryptionErrors", decryption.errors.size);
if (this._isTimelineOpen) { if (this._isTimelineOpen) {
await decryption.verifySenders(txn); await decryption.verifySenders(txn);
} }
@ -229,6 +231,7 @@ export class Room extends EventEmitter {
} }
decryption.applyToEntries(entries); decryption.applyToEntries(entries);
} }
log.set("entries", entries.length);
let shouldFlushKeyShares = false; let shouldFlushKeyShares = false;
// pass member changes to device tracker // pass member changes to device tracker
if (roomEncryption && this.isTrackingMembers && memberChanges?.size) { if (roomEncryption && this.isTrackingMembers && memberChanges?.size) {
@ -240,6 +243,9 @@ export class Room extends EventEmitter {
entries, isInitialSync, !this._isTimelineOpen, this._user.id); entries, isInitialSync, !this._isTimelineOpen, this._user.id);
// write summary changes, and unset if nothing was actually changed // write summary changes, and unset if nothing was actually changed
summaryChanges = this._summary.writeData(summaryChanges, txn); summaryChanges = this._summary.writeData(summaryChanges, txn);
if (summaryChanges) {
log.set("summaryChanges", summaryChanges.diff(this._summary.data));
}
// fetch new members while we have txn open, // fetch new members while we have txn open,
// but don't make any in-memory changes yet // but don't make any in-memory changes yet
let heroChanges; let heroChanges;

View file

@ -169,6 +169,18 @@ class SummaryData {
this.cloned = copy ? true : false; 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() { cloneIfNeeded() {
if (this.cloned) { if (this.cloned) {
return this; return this;