Open uriesk opened 2 months ago
JFYI i am in a room with hundreds of users and storing the cache takes >20ms producing a 4MB file.
diff --git a/Quotient/connection.cpp b/Quotient/connection.cpp
index 1474ddc3..78befbef 100644
--- a/Quotient/connection.cpp
+++ b/Quotient/connection.cpp
@@ -1422,6 +1422,9 @@ void Connection::saveRoomState(Room* r) const
if (!d->cacheState)
return;
+ QElapsedTimer et;
+ et.start();
+
QFile outRoomFile { stateCacheDir().filePath(
SyncData::fileNameForRoom(r->id())) };
if (outRoomFile.open(QFile::WriteOnly)) {
@@ -1435,6 +1438,8 @@ void Connection::saveRoomState(Room* r) const
qCWarning(MAIN) << "Error opening" << outRoomFile.fileName() << ":"
<< outRoomFile.errorString();
}
+
+ qCDebug(PROFILER) << "Room state cache for" << r->id() << "generated in" << et;
}
void Connection::saveState() const
This was made as low-maintenance way to store the room state back before we had to have a database. I think saving the most recent state is valuable to make sure it doesn't get lost in case of crashes but if we save it to the database instead of a CBOR file we could at least save it in a more fine-grained manner, into a file that is already open anyway.
The room state cache gets saved to disk on almost all Room::change events. That state can be multiple MB and is freshly written on every new message. Is this necessary or is it possible to limit this?