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

base: cache the computed display name and reuse that in the search filters #3516

Merged
merged 14 commits into from
Jun 11, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jun 6, 2024

Could be reviewed commit by commit. It gets messy only at the end. GLHF.

The computed display name is filled in two cases:

  • when creating a room for the first time,
  • when getting a sync (from sync v3 or sliding sync) update for a room, in all cases.

This means that the first time we see a room during a sync, we'll compute the display name twice 🤷

Recomputing on every sync might be a bit wasteful, but getting all the inputs right when computing the display name is a tad complicated, since this depends on the room summary, the members, the heroes, the room name event and the canonical alias event (and maybe other things I'm forgetting about right now). Alternatives involved: using a dirty flag (bleh), also keeping all the inputs along the cached output (so we could early return when the inputs haven't changed in compute_display_name — could work, but seems frail), making the search filters async (nopenopenope).

@bnjbvr bnjbvr requested a review from a team as a code owner June 6, 2024 10:29
@bnjbvr bnjbvr requested review from poljar and removed request for a team June 6, 2024 10:29
@bnjbvr
Copy link
Member Author

bnjbvr commented Jun 6, 2024

That's new, the CI task is not looking at the right version of the code…

https://github.com/matrix-org/matrix-rust-sdk/actions/runs/9399452164/job/25886897317?pr=3516

@poljar
Copy link
Contributor

poljar commented Jun 6, 2024

That's new, the CI task is not looking at the right version of the code…

https://github.com/matrix-org/matrix-rust-sdk/actions/runs/9399452164/job/25886897317?pr=3516

I think we had it a couple of times, it might happen if the base branch of your PR is too far off from main on the repo.

Try a rebase?

Instead of calling it through `BaseRoomInfo::calculate_room_name`.
…rs, not joined+invited

The previous code would use `ACTIVE` which means "either joined or
invited" members, but the code thereafter considered this to be the
number of joined members.

Also replaced a call to `self.members()` (which does a lot of work under
the hood) with a call to `self.joined_user_ids()`, since we only
retrieve the `.len()` of the resulting vector.
@bnjbvr bnjbvr force-pushed the bnjbvr/cached-computed-display-name branch from 4b843e3 to 81d0e7c Compare June 6, 2024 11:41
@bnjbvr bnjbvr force-pushed the bnjbvr/cached-computed-display-name branch from 81d0e7c to 823226a Compare June 6, 2024 12:25
Copy link

codecov bot commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 98.73418% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.83%. Comparing base (5093af8) to head (5001b27).
Report is 16 commits behind head on main.

Files Patch % Lines
crates/matrix-sdk-base/src/rooms/normal.rs 98.48% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3516      +/-   ##
==========================================
+ Coverage   83.79%   83.83%   +0.04%     
==========================================
  Files         254      254              
  Lines       25723    25739      +16     
==========================================
+ Hits        21554    21579      +25     
+ Misses       4169     4160       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

… way

The test looks at updates of `RoomInfo`s, but these depends on external
factors like the server sending them in one part or multiple ones.

Instead of trying to figure out which partial updates the server sent,
wait for the stream of `RoomInfo`s to stabilize by trying to get the
latest item from the stream, then wait up to N seconds for another item
to show up, and continue as long as items come in.

This should allow us to get rid of some code that was required to
prevent flakey updates.
@bnjbvr
Copy link
Member Author

bnjbvr commented Jun 6, 2024

@poljar This is now ready for review \o/

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments we should discuss.

crates/matrix-sdk/src/sync.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-base/src/rooms/normal.rs Outdated Show resolved Hide resolved
@bnjbvr bnjbvr requested a review from poljar June 10, 2024 14:34
…he cached display name in RoomInfo

So revert a few changes to make some functions async, etc.
…c methods

It's not perfect, but it's honest work.
@bnjbvr bnjbvr force-pushed the bnjbvr/cached-computed-display-name branch from 51a599b to 5001b27 Compare June 10, 2024 14:45
Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I don't think I have any more complaints.

@bnjbvr bnjbvr merged commit 0ec90c2 into main Jun 11, 2024
38 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/cached-computed-display-name branch June 11, 2024 13:44
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

Successfully merging this pull request may close these issues.

2 participants