-
Notifications
You must be signed in to change notification settings - Fork 358
Description
Right now, there is the EventCacheStore. To access it, we have an EventCacheStoreLock. It's all good, no problem with that, it's a cross-process lock, all fine. Except that it's not really optimal as each RoomEventCache holds a clone of the same EventCacheStoreLock, which means that each room in the Event Cache uses the same lock over all the rooms of the store. It blocks the possibility to handle updates for each room in parallel (I guess that's why #5426 didn't provide the expected results).
A simple approach would be to derive a particular key for the cross-process lock, like adding a suffix of the form -event-cache-room-{room_id} or something like that. That way, we will have one cross-process lock per room. We can create a RoomEventCacheStoreLock type that will use this new key. See here:
matrix-rust-sdk/crates/matrix-sdk-base/src/event_cache/store/mod.rs
Lines 76 to 80 in a3424a7
| cross_process_lock: Arc::new(CrossProcessLock::new( | |
| LockableEventCacheStore(store.clone()), | |
| "default".to_owned(), | |
| holder, | |
| )), |