• webv4 forum: unread counts and thread views look up every message numb

    From Rob Swindell@1:103/705 to GitLab note in main/sbbs on Fri Nov 13 17:35:58 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1339#note_10933

    Item 2 is addressed by the commit "webv4: cache a sub's forum threads instead of rebuilding them per request" (on master, not yet pushed; it will cross-link here when it is).

    `getMessageThreads()` now caches each sub's threads in `data/webv4/threads/<code>.json`, keyed on the `.shd`/`.sid` file dates and sizes plus `max_messages` and `forum_no_spam`. Any post, vote, deletion or header update rebuilds it. Unread counts are computed per user after loading, so nothing per-user is cached. Thread lists, thread views, "load more" and vote refreshes all go through it.

    **Measured on Linux** (cached result byte-identical to a rebuild):

    | Sub | Messages | Before | Cache hit | Rebuild + write |
    |---|---|---|---|---|
    | syncprog | 9,103 | 392 ms | 181 ms | 630 ms |
    | usenet_altcomposwin11 | 23,248 | 925 ms | 433 ms | 1.35 s |
    | usenet_altcomposwin10 | 159,560 | 7.1 s | 2.8 s | 10.1 s |

    Reading headers was only about a third of the old cost: each field read from a `get_all_msg_headers()` header costs about 1 us, so copying 13 fields per message took as long again. On the largest sub a cache hit is still mostly parsing 36 MB of JSON; shrinking that would mean changing what the pages consume.

    **Still open**
    - Item 4: poll tally still reads every header in the sub (needs a native way to get one message's tally).
    - Item 5 (lower priority).

    *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)