From 75ba8bb5657231ebc8ea1b54b49cb667e11ad3a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Tue, 17 Aug 2021 00:22:52 +0200 Subject: [PATCH] fix: faster room joins --- src/database/abstraction/sqlite.rs | 4 ++-- src/database/rooms.rs | 10 +++++++++- src/server_server.rs | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/database/abstraction/sqlite.rs b/src/database/abstraction/sqlite.rs index 1e55418..5b895c7 100644 --- a/src/database/abstraction/sqlite.rs +++ b/src/database/abstraction/sqlite.rs @@ -49,11 +49,11 @@ impl Engine { fn prepare_conn(path: &Path, cache_size_kb: u32) -> Result { let conn = Connection::open(&path)?; - conn.pragma_update(Some(Main), "page_size", &1024)?; + conn.pragma_update(Some(Main), "page_size", &2048)?; conn.pragma_update(Some(Main), "journal_mode", &"WAL")?; conn.pragma_update(Some(Main), "synchronous", &"NORMAL")?; conn.pragma_update(Some(Main), "cache_size", &(-i64::from(cache_size_kb)))?; - conn.pragma_update(Some(Main), "wal_autocheckpoint", &8000)?; + conn.pragma_update(Some(Main), "wal_autocheckpoint", &2000)?; Ok(conn) } diff --git a/src/database/rooms.rs b/src/database/rooms.rs index 75251aa..e2415a4 100644 --- a/src/database/rooms.rs +++ b/src/database/rooms.rs @@ -392,6 +392,7 @@ impl Rooms { &pdu.sender, None, db, + false, )?; } } @@ -400,6 +401,8 @@ impl Rooms { } } + self.update_joined_count(room_id)?; + self.roomid_shortstatehash .insert(room_id.as_bytes(), &new_shortstatehash.to_be_bytes())?; @@ -1285,6 +1288,7 @@ impl Rooms { &pdu.sender, invite_state, db, + true, )?; } } @@ -2051,6 +2055,7 @@ impl Rooms { sender: &UserId, last_state: Option>>, db: &Database, + update_joined_count: bool, ) -> Result<()> { // Keep track what remote users exist by adding them as "deactivated" users if user_id.server_name() != db.globals.server_name() { @@ -2232,7 +2237,9 @@ impl Rooms { _ => {} } - self.update_joined_count(room_id)?; + if update_joined_count { + self.update_joined_count(room_id)?; + } Ok(()) } @@ -2269,6 +2276,7 @@ impl Rooms { user_id, last_state, db, + true, )?; } else { let mutex_state = Arc::clone( diff --git a/src/server_server.rs b/src/server_server.rs index 7a28e5d..de3eef5 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -2471,6 +2471,7 @@ pub async fn create_invite_route( &sender, Some(invite_state), &db, + true, )?; }