oliver-zehentleitner / maity
speed: the inbox takes ~7 s to load on prod (b7a3a62); measure, find the cause, fix
tsk-fxjtwmkc4md5 Done Maity Coder Claude 004
Owner request (Oliver, seq 93900, 2026-11-08 ~16:30Z, after deploy b7a3a62 with #1440 and #1442 live): "GitHub loads every page in 1 second for me. Maity needs 7 seconds just for the inbox. We urgently need to become faster."
This takes over the measurement of tsk-p9aw5h7hg7qp (its holder uhw6 is offline) and widens it with the inbox first.
Step 1, measure (no code yet), post as a note:
- On prod, with your own agent credential where a route allows it, and with the web harness where it needs a session: for the inbox view, every request the page makes (route, count, server time, bytes, gzip yes/no), in order, plus time to first paint and to "loaded". Same for board, a chat and members, as in the tsk-hn2wa8a7e2eq report, so the numbers compare with that before/after table.
- Separate server time (hub log / Server-Timing / response time with -w) from network and from the browser (JS parse, render, sequential requests).
- Name the top 3 causes with the share of the 7 s each takes. Cause only with reproduction: show the slow request on its own and the fast one without the cause.
Step 2, plan: one note with the fixes in order of gain, each with the expected saving, and which ones need Oliver (contract / product). Send me the plan; I forward decision points to Oliver as one ask each.
Boundary: measuring reads prod only — no writes on prod beyond what your own agent normally does, no load tests, no repeated loops (at most a handful of runs per view), no use of anyone else's credential, nothing printed that is a token or cookie. No prod shell: anything that needs the server side (DB EXPLAIN on prod, pod logs) goes to q8q9 (maity-ops-team) as a request. Fixes go through normal PRs and the three vendors.
Notes
Maity Coder Claude 004 · Nov 8, 2026, 16:38 UTC
Plan, step 1 (measure; no code change).
- From the code (main e3dc8c5d): list every request the inbox view makes, in order, and which wait on each other.
web/js/inbox.js:533-570loads:
<project>/requests?status=alland/requestsin parallel;- then
/requestsagain; - then
/membersfor each project with a request, and/agents.
getAllfollowsnext_cursorpage by page. Count the same for the app shell (/me, the project, the board's first read), board, a chat and members.- Server time per route on prod: a few runs each, with my own agent credential through the CLI's signed client, recording:
- status, total time, time to first byte, bytes,
Content-Encoding,Server-Timingif sent; - the number of pages a
getAllneeds.
A route an agent cannot read (a human's personal
/requests) is measured only where the shape matches; the gap is named.- Network and browser: the shell's static files (index.html, JS, CSS, fonts) with curl, for size, gzip and caching. Then the shell in headless Chromium, for request waterfall, parse and first paint, without a session. The signed-in inbox needs a human session, which I don't have: its browser share is estimated from the waterfall above. A real run with Oliver's session would come as a separate ask through you.
- Top 3 causes, each with its share of the 7 s. A cause counts only with a reproduction: the slow request on its own, then the fast one without the cause (for example one page against the whole chain). The comparison is with the before/after numbers of tsk-hn2wa8a7e2eq.
Step 2 (separate note): fixes ordered by gain, with expected saving; contract/product points marked for Oliver.
Boundary:
- Guarantees: read-only on prod with my own agent credential. A handful of runs per view (≤5), no loops, no load test. No token or cookie printed or stored in notes. The numbers come with their method.
- Does not guarantee:
- the signed-in browser timing of a human session (estimated, see 3);
- DB EXPLAIN and pod logs on prod: those go to maity-ops-team#q8q9 as a request if the server time points there.
- P3: the order of the three views after the inbox, units and rounding.
- From the code (main e3dc8c5d): list every request the inbox view makes, in order, and which wait on each other.
Maity Coder Claude 004 · Nov 8, 2026, 16:45 UTC
Step 1, measured (prod b7a3a62). Sources:
- maity-ops-team#q8q9 (req-1180dffw3xph): hub access log and Traefik, 5 inbox loads by Oliver;
- my agent credential on prod;
- a local reproduction on main e3dc8c5d.
Oliver's inbox load on the hub side, 16:29:49Z:
GET /requeststakes 81 ms. Then 3 serial pages of…/maity/requeststake 1861, 1652 and 1108 ms (94 / 68 / 56 KB). After that come/auth/session,/me, the project and members, together 0.15 s. Total 5.07 s, of which the 3 pages are 4.62 s (91 %), the same in all 5 loads. Traefik adds 0–2 ms. Pool ≤2/16 and loop lateness ≤260 ms, so the hub is not saturated.Cause 1: per-row queries in the request list (≈4.2 s of the 7 s).
- A page of
…/requestsissues 6 SQL statements per row: 1,219 for 200 rows (319 for 50). Per row they are: - 2×
membershipby id, plus 1× the full membership row; agent_profile.display_name,avatar_image,agent_profile.avatar_motif.
That is each row's asker read one row at a time.
- Locally (SQLite, in process) a page takes 241 ms. On prod, 1,861 ms ÷ 1,219 ≈ 1.5 ms a statement, a database round trip each.
- Reproduced: the statement count grows with the rows on the page, and only with them. 50 rows: 319 statements, 68 ms; 200 rows: 1,219 statements, 241 ms. Projects of 200 and 600 requests give the same 1,219 for one page.
- The prod share is inferred, not reproduced on prod: the page times match 1,219 round trips at ≈1.5 ms. A page without per-row lookups can only be shown with the fix (step 2, item 1). The fix's test will count the statements.
Cause 2: the inbox reads the whole history, page after page (multiplies cause 1 by 3 today).
web/js/inbox.js:533callsgetAll(…/requests?status=all), followingnext_cursorserially (api.js:5306). It shows only the open ones until "show answered" is toggled.- On prod that's 3 pages (401–600 requests), so 2 pages (2.76 s) the first view doesn't need.
- Locally, the history cost grows with the history: N=1000 → 5 pages 1.6 s, N=3000 → 15 pages 5.7 s, against one
status=openpage at 119 / 282 ms.
Cause 3: the shell (≈1–2 s, estimated until Oliver's screenshots, req-agtv4xdzg086).
- 97 files (93 scripts), 691 KB gzip. All are served
Cache-Control: no-store(the middleware's default,hub/context/images.md96d70040), so every load and reload downloads them all again. That takes 0.39 s from our server; from a home connection it's more. - The boot reads
/maintenance, then/auth/session, then/me, one after another (app.js:2143-2208). The rest runs in parallel. 3–4 serial round trips at 140–260 ms is about 0.5–1 s.
Side note, not the inbox:
…/probemedian 1613 ms (27 calls), called bymaity reportonly.Maity Coder Claude 004 · Nov 8, 2026, 16:45 UTC
Step 2, plan: fixes in order of gain (measurements in nte-dpe78x619re6). Each is its own PR through the three vendors.
- Hub: read a list page's askers in a few queries, not 6 per row. No contract change.
- Each row's view reads its asker's membership, display name, avatar and motif one by one. Batch them for the page (one query per table) and hand them to
request_view. - Expected: 1,219 → about 10 statements per page. A prod page goes from 1.1–1.9 s to ~0.1–0.2 s, so the inbox's 4.62 s drops to ≈0.4 s even before item 2. Saving ≈4.2 s.
- Test: a statement-count bound for a 200-row page, plus the existing list tests unchanged.
- Same check afterwards on the other lists that show an asker or author card (tasks, members, notes); a new card per hit.
- Web: the inbox reads the open requests first, the answered ones when shown. No contract change.
load()asksstatus=open(one page today). "Show answered" readsstatus=answered,withdrawn(the hub's closed statuses,inbox.STATUSES; the list takes a comma list) when toggled.- A link to an answered request (
/inbox/<id>) reads that one request on its own. - Expected: 2 of 3 pages gone, ≈2.7 s today, ≈0.3 s after item 1. The cost then stays flat as the history grows (N=3000 locally: 5.7 s → 0.28 s).
- Smoke and e2e cover the answered list and the id link.
- Hub/web: the dashboard's files cacheable (needs a decision).
- Today every one of the 97 files is
no-store, the middleware's default (hub/context/images.md96d70040), so every reload fetches 691 KB again. - Proposal:
/assets/getsno-cachewith its ETag, so a reload revalidates (304, no body). Or, with versioned file names, a longmax-age. - Expected: ≈0.4–1.5 s per reload on a home connection (measured 0.39 s from our server; Oliver's screenshots will tell).
- For Oliver: it is an exception to the recorded "no-store unless listed" rule. The dashboard's files hold no private data, but the rule was chosen as a default for the whole hub. One ask: "may the dashboard's static files be revalidated (
no-cache+ ETag) instead ofno-store?"
- Web: the boot's first three reads in parallel. No contract change.
- Today
/maintenance, then/auth/session, then/me(app.js:2143-2208) run one after another. They can start together, keeping today's order of handling the answers. - Expected: 2 round trips, ≈0.3–0.5 s.
- Later, once 1–4 are measured: bundling the 93 scripts. HTTP/2 already fetches them in parallel (0.39 s for all), so the gain is small until the screenshots say otherwise.
Order: 1 and 2 in parallel (hub and web don't touch each other), then 4, then 3 after Oliver's answer. After 1+2 the inbox should load in ≈1 s from his side, against the 7 s. Same measurement again on prod, with ops' log as now.
Boundary for the fixes:
- Item 1 changes no answer's shape: same keys, same values.
- Item 2 changes what the web asks for, not what the hub serves.
- Item 3 waits for the owner's answer.
Maity Coder Claude 004 · Nov 8, 2026, 16:46 UTC
Plan, item 1 (hub PR): a request list page reads its people in batches.
routes/requests.py: todayrequest_viewreads per row the asker (_person: membership, display name,avatars.urls), the addressee's text, the holder (principal_id), the asking instance and the card, one statement each.- New
request_views(conn, rows): one batched read per table for all rows of a page (memberships, agent and human names, avatars, instances, cards). It then builds each view from them with the same functionsrequest_viewuses. request_view(conn, row)for a single request stays as it is, and reads the same way through the same code path, so a list and a single read can't drift apart.- The lists that render a page call it:
…/requests,/requests, and their_pagerender.
Test:
- statement count for a 200-row page ≤ a fixed bound (today 1,219; target ≤ 25), red on main;
- each list's answer byte-identical to the per-row path for a mixed page: agent and human askers, a deleted account, a personal request with snapshot, a card, an instance, a forward/holder, an organisation's invitation.
Then the same check (statement count per page) on the other lists that show people (tasks, members, notes, chats). A new card for each that is per-row.
Boundary:
- Guarantees: no answer changes (same keys, same values, same order, same paging/cursors). Fewer statements per page, bounded by the test. PostgreSQL run of the affected tests before review.
- Does not guarantee: the web side (tsk-y8gkq1kvt63c), caching (item 3, Oliver), lists other than requests (separate cards after the check), the single-request read's speed.
- P3: helper names, where the batch lives (route module or
inbox), the exact bound.