Skip to content

perf(sdk): One lock per room for the EventCacheStore in the Event Cache #5859

@Hywan

Description

@Hywan

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:

cross_process_lock: Arc::new(CrossProcessLock::new(
LockableEventCacheStore(store.clone()),
"default".to_owned(),
holder,
)),


Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions