Skip to content

Turn message search into streams#6661

Merged
stefanceriu merged 5 commits into
mainfrom
stefan/messageSearchingStreams
Jun 26, 2026
Merged

Turn message search into streams#6661
stefanceriu merged 5 commits into
mainfrom
stefan/messageSearchingStreams

Conversation

@stefanceriu

Copy link
Copy Markdown
Member

This series of patches reworks the SDK's message search to expose results as streams instead of the hand-rolled iterators. They reimplemented streaming (manual offset / is_done / batch-buffer bookkeeping) without any of its benefits.

The FFI layer keeps its current interface but it will probably get removed entirely when we introduce the new GlobalSearchService.

@stefanceriu stefanceriu requested a review from poljar June 12, 2026 11:10
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.90%. Comparing base (4bd5e81) to head (d604f47).
⚠️ Report is 12 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6661      +/-   ##
==========================================
+ Coverage   89.89%   89.90%   +0.01%     
==========================================
  Files         396      396              
  Lines      110412   110317      -95     
  Branches   110412   110317      -95     
==========================================
- Hits        99258    99186      -72     
+ Misses       7370     7367       -3     
+ Partials     3784     3764      -20     

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

@codspeed-hq

codspeed-hq Bot commented Jun 12, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing stefan/messageSearchingStreams (d604f47) with main (567463d)

Open in CodSpeed

@stefanceriu stefanceriu marked this pull request as ready for review June 13, 2026 08:39
@stefanceriu stefanceriu requested a review from a team as a code owner June 13, 2026 08:39
@stefanceriu stefanceriu force-pushed the stefan/messageSearchingStreams branch 2 times, most recently from f59d164 to 65b0882 Compare June 25, 2026 08:48
`Room::search_messages` returned a hand-rolled `RoomSearchIterator` with
manual `offset`/`is_done` bookkeeping that reimplemented a stream.

Replace it with real streams that paginate the index lazily as polled with `Room::search_messages` yielding `(score, event_id)` pairs and `Room::search_messages_events`
full timeline events.
Replace the hand-rolled `GlobalSearchIterator` with a `Stream` that performs a
k-way merge across room streams. Similar to the room, `GlobalSearchBuilder::build`
yields `(room_id, score, event_id)` tuples and `GlobalSearchBuilder::build_events`
full timeline events.
Adapt the global and single-room search UI flows to poll the new SDK
search streams directly instead of the removed iterator.
The SDK's message search now exposes streams instead of iterators. Keep
the `RoomSearchIterator`/`GlobalSearchIterator` objects and their batch-
oriented `next_events()` surface unchanged but back them with a boxed SDK search
stream they pull `num_results_per_batch` items from.
@stefanceriu stefanceriu force-pushed the stefan/messageSearchingStreams branch from 65b0882 to acdfff6 Compare June 25, 2026 08:53

@poljar poljar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks mostly good, let's just switch to a stream of pages/chunks.

Comment thread crates/matrix-sdk/src/message_search.rs Outdated
Comment thread crates/matrix-sdk/src/message_search.rs Outdated
Comment thread bindings/matrix-sdk-ffi/src/search.rs Outdated
Have the search streams yield whole pages instead of individual results so
consumers can decide to stop between (potentially expensive) polls, and to
mirror how server-side search pagination works.
@stefanceriu stefanceriu requested a review from poljar June 26, 2026 10:59

@poljar poljar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Neat.

@stefanceriu stefanceriu merged commit 5a0b002 into main Jun 26, 2026
54 checks passed
@stefanceriu stefanceriu deleted the stefan/messageSearchingStreams branch June 26, 2026 12:58
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