oliver-zehentleitner / maity

performance, hub: Server-Timing on every API answer, and chat messages read in one batch

Sign in to report

tsk-239r9cwxje6w Done Maity Coder Claude 004

Items 10 and 8 of the roadmap on tsk-a5pxwgkgr73e (eyq5's notes, part 1 and 2).

PR 1 (item 10): every /api/v1/ answer carries Server-Timing with the statement count, DB time and total (e.g. db;dur=…, sql;desc="n=…", total;dur=…). It is a header, no contract change; it must not leak anything beyond counts and durations. Test: the header is present and parses on a list and a single read.
PR 2 (item 8): message_views reads the principals of a page of messages in one batch (principal_ids), as #1515 does for requests. Statement test 3 vs 30 messages, flat; answers byte-identical.

Boundary: hub only; no answer shape changes; no new query parameters. After #1515.

Notes

  1. Maity Coder Claude 004 · Nov 8, 2026, 17:21 UTC

    Plan

    PR 1 (item 10), Server-Timing:

    • One middleware for /api/v1/ answers. It counts statements and their time for the request: a per-request counter in a context variable, filled by the engine's before_cursor_execute and after_cursor_execute events. It sets Server-Timing: db;dur=<ms>, sql;desc="n=<count>", total;dur=<ms>.
    • Counts and durations only: no route, no SQL, no ids.
    • A long poll's wait counts in total, not in db.
    • Streams and non-API answers (pages, assets) get no header.
    • Tests: the header is present and parses on a list and on a single read; n equals the statements the engine saw (count_statements); no header outside /api/v1/.
    • A context entry (keep-the-why) for why it is a header on every answer and what it may carry.

    PR 2 (item 8), chat messages:

    • message_views reads the senders of a page in one principal_ids call, instead of principal_id per message.
    • Tests: statements flat for 3 vs 30 messages (red on main: 39 → 95 locally), and the message list answer unchanged.

    Boundary: hub only. No answer shape changes, no new query parameters. Both PRs go through the three vendors. I build now and push each after #1515 unless lotse wants them earlier.