Inbox reads the stat of every text in the mailbox, again on every login anywhere #237

Closed
opened 2026-10-21 19:17:27 +00:00 by littlefox · 2 comments
Owner

Found while looking into scrolling (#230, D-058).

Kom::conversations (crates/kom-client/src/inbox.rs) maps the whole mailbox with local-to-global, then fetches the text stat of every text in it, to group them into chats. For someone who has used LysKOM for years, that is thousands to tens of thousands of get-text-stat calls the first time the inbox is opened (cached afterwards, without limit, see #236).

The resource in InboxPane runs again whenever changes is bumped, and logins and logouts on the server bump it. So while the inbox is open, every login anywhere maps the mailbox again.

A chat then shows only its last CHAT_TEXTS = 50 texts, with no way to see older ones.

Directions:

  • Newest first: walk the mailbox from the end, fetching stats only until the newest ~30 conversations are known; fetch further back on scroll.
  • Remember the conversation list between opens, and update it from the async messages (new text to me), rather than rebuilding it.
  • Don't depend on changes (presence), only on mail.
  • Older texts in a chat: load on scroll, windowed like the rest (#236).

Measure with #225: calls and time to open the inbox for a person with ~5 000 texts in the mailbox (add one to the seed).

Found while looking into scrolling (#230, D-058). `Kom::conversations` (`crates/kom-client/src/inbox.rs`) maps the **whole mailbox** with `local-to-global`, then fetches the text stat of **every text in it**, to group them into chats. For someone who has used LysKOM for years, that is thousands to tens of thousands of `get-text-stat` calls the first time the inbox is opened (cached afterwards, without limit, see #236). The resource in `InboxPane` runs again whenever `changes` is bumped, and logins and logouts on the server bump it. So while the inbox is open, every login anywhere maps the mailbox again. A chat then shows only its last `CHAT_TEXTS = 50` texts, with no way to see older ones. Directions: - **Newest first:** walk the mailbox from the end, fetching stats only until the newest ~30 conversations are known; fetch further back on scroll. - **Remember** the conversation list between opens, and update it from the async messages (new text to me), rather than rebuilding it. - **Don't** depend on `changes` (presence), only on mail. - **Older texts** in a chat: load on scroll, windowed like the rest (#236). Measure with #225: calls and time to open the inbox for a person with ~5 000 texts in the mailbox (add one to the seed).
Author
Owner

Correction after measuring (#225): the inbox does not read the whole mailbox. Kom::conversations takes the newest LOOK_AT = 200 texts, so the first paragraph above is wrong.

Measured, Pelle with 2 500 letters, 30 ms each way to the server: the inbox opens in 2.5 s with 213 calls (200 text stats, names, then a preview for each of the 30 newest conversations, one at a time).

What remains of this issue:

  • It runs again on every changes: every new text anywhere, and today every login and logout (that part goes with #226/#228's presence split).
  • The 30 previews are fetched one after the other; batching them (#234) would cut most of the 2.5 s.
  • Conversations older than the newest 200 texts can't be reached, and a chat shows only its last 50 texts.
Correction after measuring (#225): the inbox does **not** read the whole mailbox. `Kom::conversations` takes the newest `LOOK_AT = 200` texts, so the first paragraph above is wrong. Measured, Pelle with 2 500 letters, 30 ms each way to the server: the inbox opens in **2.5 s with 213 calls** (200 text stats, names, then a preview for each of the 30 newest conversations, one at a time). What remains of this issue: - It runs again on every `changes`: every new text anywhere, and today every login and logout (that part goes with #226/#228's presence split). - The 30 previews are fetched one after the other; batching them (#234) would cut most of the 2.5 s. - Conversations older than the newest 200 texts can't be reached, and a chat shows only its last 50 texts.
Author
Owner

What #237 was about is done: the inbox reads only the newest 200 texts (not the whole mailbox, corrected above), its 30 previews come six at a time (#261: open 2.45 → 1.94 s), and logins and logouts no longer re-run it (#254). Reaching older conversations and older texts in a chat is a feature for later: #265 (1.0).

What #237 was about is done: the inbox reads only the newest 200 texts (not the whole mailbox, corrected above), its 30 previews come six at a time (#261: open 2.45 → 1.94 s), and logins and logouts no longer re-run it (#254). Reaching older conversations and older texts in a chat is a feature for later: #265 (1.0).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
littlefox/neokom#237
No description provided.