Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p=1 req taking 4s to return for large accounts #375

Open
ara4n opened this issue Nov 10, 2023 · 3 comments
Open

p=1 req taking 4s to return for large accounts #375

ara4n opened this issue Nov 10, 2023 · 3 comments

Comments

@ara4n
Copy link
Member

ara4n commented Nov 10, 2023

while looking into element-hq/element-x-ios#2062, @kegsay noted that the p=1 req for my acct took 4s to return, which feels worryingly long (especially if the app is incorrectly blocking the UI waiting for it to return).

@kegsay
Copy link
Member

kegsay commented Nov 10, 2023

The bulk of the time was spent inside RoomStateAfterEventPosition for 100 all_rooms, 4.53/4.8s.

@kegsay
Copy link
Member

kegsay commented Nov 10, 2023

"required_state":[["m.room.avatar",""],["m.room.encryption",""],["m.room.member","$LAZY"],["m.room.power_levels",""]],"timeline_limit":1

Unfortunately, $LAZY means we would need to query membership_events array for each room :(

@kegsay
Copy link
Member

kegsay commented Nov 16, 2023

I wonder if we can optimise just that particular query, i.e cases where:

  • you want lazy members
  • timeline limit = 1

In that case, it might be quicker to just guess from the events table e.g SELECT event_nid FROM syncv3_events WHERE event_type='m.room.member' AND state_key='@sender' AND room_id='!theroom' AND (membership='join' OR membership='_join'). Then do a simple existence check in the membership_events array. If it is in the array, great we saved a ton of time. If it isn't, boo, we still need to check as we may have guessed the wrong membership event (e.g a join from months ago).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants