event cache: increase the number of pending updates for a sender

And also log the number of skipped updates, when lagging behind in the
event cache or the timeline.
This commit is contained in:
Benjamin Bouvier
2024-04-04 18:41:42 +02:00
parent 03f4a56bff
commit 742700b7fa
2 changed files with 8 additions and 5 deletions

View File

@@ -172,8 +172,11 @@ impl TimelineBuilder {
let update = match event_subscriber.recv().await {
Ok(up) => up,
Err(broadcast::error::RecvError::Closed) => break,
Err(broadcast::error::RecvError::Lagged(_)) => {
warn!("Lagged behind sync responses, resetting timeline");
Err(broadcast::error::RecvError::Lagged(num_skipped)) => {
warn!(
num_skipped,
"Lagged behind event cache updates, resetting timeline"
);
inner.clear().await;
continue;
}

View File

@@ -203,11 +203,11 @@ impl EventCache {
}
}
Err(RecvError::Lagged(_)) => {
Err(RecvError::Lagged(num_skipped)) => {
// Forget everything we know; we could have missed events, and we have
// no way to reconcile at the moment!
// TODO: implement Smart Matching™,
warn!("Lagged behind room updates, clearing all rooms");
warn!(num_skipped, "Lagged behind room updates, clearing all rooms");
// Note: one must NOT clear the `by_room` map, because if something subscribed
// to a room update, they would never get any new update for that room, since
@@ -460,7 +460,7 @@ impl RoomEventCacheInner {
/// Creates a new cache for a room, and subscribes to room updates, so as
/// to handle new timeline events.
fn new(room: Room) -> Self {
let sender = Sender::new(32);
let sender = Sender::new(128);
Self {
room,