Skip to content

ffi: make room and timeline creation orthogonal #4716

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

Closed
wants to merge 2 commits into from

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Feb 25, 2025

This gets rid of the Timeline stored in an FFI Room. There's no good reason why we should create and hold on to a live timeline instance when we have a Room instance, since we might want a Room to only perform Room-related operations.

In general, holding onto live timelines in scattered places may lead to having the auto-linked-chunk-shrink optimization not trigger, so we need to be careful and minimize the number of live timelines at all costs.

As a result, this gets rid of Room::timeline, which would return the cached timeline instance. Room::timeline_with_configuration() can be used to create a new timeline instance for a given room, or RoomListItem::init_timeline() and then RoomListItem::timeline().

Also renamed the FFI Room::inner (which is a… SDK Room) to Room::sdk. Is this too cute? 🥺

cc @jmartinesp @stefanceriu, if you could test it out please :-)

This gets rid of the `Timeline` stored in an FFI `Room`. There's no good
reason why we should create and hold on to a live timeline instance when
we have a `Room` instance, since we might want a `Room` to only perform
`Room`-related operations.

As a result, this gets rid of `Room::timeline`, which would return the
cached timeline instance. `Room::timeline_with_configuration()` can be
used to create a new timeline instance for a given room, or
`RoomListItem::init_timeline()` and then `RoomListItem::timeline()`.
@bnjbvr bnjbvr requested a review from a team as a code owner February 25, 2025 16:01
@bnjbvr bnjbvr requested review from andybalaam and removed request for a team February 25, 2025 16:01
Copy link

codecov bot commented Feb 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.97%. Comparing base (0819ab1) to head (af69fc5).
Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4716   +/-   ##
=======================================
  Coverage   85.97%   85.97%           
=======================================
  Files         290      290           
  Lines       34065    34065           
=======================================
+ Hits        29288    29289    +1     
+ Misses       4777     4776    -1     

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

Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

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

Thanks. FEWER! TIMELINE! FEWER! TIMELINE!

Comment on lines 602 to 605
let timeline = SdkTimeline::builder(&self.inner)
.track_read_marker_and_receipts()
.build()
.await
Copy link
Member

Choose a reason for hiding this comment

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

Is there a risk that the creation of the Timeline and the installation of all its tasks, take a lot of time? Maybe we should add a big warning in the doc?

Copy link
Member Author

Choose a reason for hiding this comment

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

We know it can be slow, if there are many events, especially because of read receipts, so yeah I'll add a comment 👍

bnjbvr added a commit to matrix-org/complement-crypto that referenced this pull request Feb 26, 2025
@bnjbvr
Copy link
Member Author

bnjbvr commented Feb 26, 2025

Dropping this PR: Room::timeline_with_configuration() is actually not a good replacement, as it:

  • doesn't fill the event cache with the old naive event cache from sliding sync, when the new shiny event cache persistent storage isn't enabled
  • doesn't make use of the UTD hook

See dependencies in #4718.

@bnjbvr bnjbvr closed this Feb 26, 2025
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