-
Notifications
You must be signed in to change notification settings - Fork 246
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
feat(base) Client-side sorting, prelude: Implement Client::rooms_stream
#3068
Conversation
64e8798
to
e0dc148
Compare
e0dc148
to
0e7e6be
Compare
54c587b
to
0186631
Compare
1375bbf
to
20e62dc
Compare
Client::rooms_stream
57d54a9
to
ff04efb
Compare
This patch updates `Store::rooms` from a `Arc<StdRwLock<BTreeMap<OwnedRoomId, Room>>>` to a `Arc<StdRwLock<Rooms>>` where `Rooms` is a new type that mimics a `BTreeMap` but that is observable. It uses an `ObservableVector` for saving us the costs of writing a new `ObservableMap` type in `eyeball-im`. It would have too much implications that are clearly not necessary. The major one being that an `ObservableMap` must emit `MapDiff`, but we expect `VectorDiff` everywhere in the SDK where rooms are observable. It would break too many API and too many projects. The benchmark is coming, but here are the results (for 10'000 rooms, extreme case): * `get_rooms` and `get_rooms_filtered` are twice faster (in practise, it means 650µs is saved per call), * `get_room` and `get_or_create_room` are 10% slower (in practise, it means 8-10ns is lost per call). Overall, I believe these results are acceptable, and even an improvement for the first one.
This patch rewrites `Rooms` to a generic `ObservableMap` struct. It also adds documentation and tests for this type.
This patch basically implements `ObservableMap::stream` which returns a batched stream of the values.
This patch implements a new `Store::rooms_stream` method that forwards the result of `ObservableMap::stream`.
…tion` is enabled. Running `cargo test -p matrix-sdk-base --features e2e-encryption` makes the code to fail to compile because `crate::latest_event` isn't defined. And indeed, it must be defined if `experimental-sliding-sync` is enabled, but also if `e2e-encryption` is enabled.
This patch implements `Client::rooms_stream`, which forwards the result of the recently added `Store::rooms_stream` method.
…iding-sync` aren't enabled.
ff04efb
to
858f56d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet, can you add some basic smoke test for rooms_stream()
please?
Some(position) => *position, | ||
None => { | ||
let value = default(); | ||
self.insert(key.to_owned(), value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Same comment as previous applies here too, we may be doing the lookup once too many)
This patch implements `Client::rooms_stream` by forwarding the result of `matrix_sdk_base::Client::rooms_stream`, and mapping the `matrix_sdk_base::Room` to `matrix_sdk::Room`.
This patch creates an `ObservableMap` for `wasm32-unknown-unknown` which simply wraps a `BTreeMap`, and without the `stream` method. Indeed, the first implementation uses `eyeball_im::ObservableVector` which requires `Send` and `Sync` on its values, which cannot compile to Wasm.
858f56d
to
cb029ce
Compare
This patch adds an integration test for `Client::rooms_stream`.
d5698c2
to
717c68d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3068 +/- ##
==========================================
- Coverage 83.83% 83.80% -0.04%
==========================================
Files 253 254 +1
Lines 25884 25931 +47
==========================================
+ Hits 21701 21731 +30
- Misses 4183 4200 +17 ☔ View full report in Codecov by Sentry. |
Client::rooms_stream
Client::rooms_stream
This patch defines the basis to get client-side sorting inside the
RoomList
. The first step is to get aStream
ofRoom
from aClient
, and this is what this patch does! It's only for non-wasm targets.It's built on top of #3561 to avoid Clippy warnings.
Blocked by:
SortBy
stream adapter jplatte/eyeball#43[Meta]SlidingSyncRoom
tech debt #3079