Skip to content

perf: introduce windowed message storage API - #554

Merged
boxdot merged 22 commits into
mainfrom
dima/message-window-api
Jul 12, 2026
Merged

perf: introduce windowed message storage API#554
boxdot merged 22 commits into
mainfrom
dima/message-window-api

Conversation

@boxdot

@boxdot boxdot commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Messages were held in an in-memory cache (MemCache) over the storage
backend, loading a channel's whole history into memory. Replace it with
a windowed API: the app requests a bounded window around the selection
and refills it every frame, so memory usage is constant regardless of
channel size.

This significantly improves the memory usage and start up time of the app.

boxdot added 12 commits June 12, 2026 17:51
The primary key on arrived_at alone was globally unique, so REPLACE in
store_message could silently delete a message with the same timestamp
in another channel. The composite key matches the semantics of
MessageId and serves as the index for windowed message queries.

Also link messages to their channel via a foreign key (deleting a
channel deletes its messages), and remove Storage::message_channel,
which is ambiguous under the composite key.
The app was not starting with: `Error: The cursor position could not be
read within a normal duration.`

The problem was most likely twofold: first `cargo install --path .`
ignored the lockfile. Further ratatui was upgraded and now probes the
terminal in `terminal.clear` which was blocked by already started event
stream.

This commit upgrades ratatui and corresponding dependencies, and open
event reading *after* clearing the screen.
@boxdot
boxdot marked this pull request as draft June 15, 2026 08:54
@boxdot boxdot changed the title refactor: introduce windowed message storage API perf: introduce windowed message storage API Jul 11, 2026
@boxdot
boxdot marked this pull request as ready for review July 12, 2026 10:49
@boxdot
boxdot merged commit 220f64f into main Jul 12, 2026
10 checks passed
@boxdot
boxdot deleted the dima/message-window-api branch July 12, 2026 10:51
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.

1 participant