Fewer server round trips when showing posts and threads #234

Closed
opened 2026-10-21 19:08:24 +00:00 by littlefox · 1 comment
Owner

Found in the codebase review (#230, D-058). Each round trip to lyskomd costs latency, and more over the relay. These are the places that multiply them:

  • Thread cards are loaded one at a time. The thread loader in app/src/main_view/mod.rs awaits kom.preview(t) for each card in turn. 100 cards at 30 ms take 3 s before the last one shows.
    • Load them in small parallel batches, as Kom::thread already does for stats with BATCH. lyskomd penalises floods, so keep the batches small.
    • Load the cards near the current post first.
  • A preview fetches a stat for every reply, just for the author's name. TextView::build calls kom.text_stat for each comment-to, footnote-to, commented-in and footnoted-in link. A post with 500 comments costs 500 get-text-stat calls to show its card, though the card doesn't show who wrote the replies.
    • Let previews skip the link authors (a lighter preview), or fetch them lazily when the full post is opened.
  • Marking read is one call per text. Kom::mark_read sends one mark-as-read per text per conference, while the protocol takes a list. Reading by scrolling (#180, #228) marks many in a row: collect them for a short moment and send one call per conference.
  • session::who_is_on looks up every session's name with get-uconf-stat, bypassing the uconfs cache in Kom.
  • Hot paths in kom-client copy state:
    • read_set clones the conference's RangeSet on every is_unread. Elisp users often have fragmented read ranges.
    • advance clones the whole seen set on every batch, and seen grows with every post read in the session.
    • Borrow these instead.

Measure with #225: calls per "Läs nästa" and per thread shown (count frames in a test client), and the time to show the last card.

Found in the codebase review (#230, D-058). Each round trip to lyskomd costs latency, and more over the relay. These are the places that multiply them: - **Thread cards are loaded one at a time.** The thread loader in `app/src/main_view/mod.rs` awaits `kom.preview(t)` for each card in turn. 100 cards at 30 ms take 3 s before the last one shows. - Load them in small parallel batches, as `Kom::thread` already does for stats with `BATCH`. lyskomd penalises floods, so keep the batches small. - Load the cards near the current post first. - **A preview fetches a stat for every reply, just for the author's name.** `TextView::build` calls `kom.text_stat` for each comment-to, footnote-to, commented-in and footnoted-in link. A post with 500 comments costs 500 `get-text-stat` calls to show its card, though the card doesn't show who wrote the replies. - Let previews skip the link authors (a lighter `preview`), or fetch them lazily when the full post is opened. - **Marking read is one call per text.** `Kom::mark_read` sends one `mark-as-read` per text per conference, while the protocol takes a list. Reading by scrolling (#180, #228) marks many in a row: collect them for a short moment and send one call per conference. - **`session::who_is_on`** looks up every session's name with `get-uconf-stat`, bypassing the `uconfs` cache in `Kom`. - **Hot paths in `kom-client` copy state:** - `read_set` clones the conference's `RangeSet` on every `is_unread`. Elisp users often have fragmented read ranges. - `advance` clones the whole `seen` set on every batch, and `seen` grows with every post read in the session. - Borrow these instead. Measure with #225: calls per "Läs nästa" and per thread shown (count frames in a test client), and the time to show the last card.
Author
Owner

Merged in #261; main run #437 green (#432 was the npm registry outage, #263). Verified: devserver tests, full e2e on three profiles (332 passed), and tools/perf.sh: inbox open 2.45 → 1.94 s; reading 120 cards by scrolling: layouts 35 → 18, main-thread 0.37 → 0.27 s. Marks were batched in #254.

Merged in #261; main run #437 green (#432 was the npm registry outage, #263). Verified: devserver tests, full e2e on three profiles (332 passed), and `tools/perf.sh`: inbox open 2.45 → 1.94 s; reading 120 cards by scrolling: layouts 35 → 18, main-thread 0.37 → 0.27 s. Marks were batched in #254.
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#234
No description provided.