All Subscriptions' Unread list takes 170-210 ms one time in ten, where its query takes 24-31 ms #501

Open
opened 2026-11-27 20:24:21 -08:00 by rays · 2 comments
Owner

Over 7 days of traces, GET /api/entries (All Subscriptions, Unread, first page of 50) is p50 33 ms, p90 169 ms, p99 208 ms, nearly all of it the step 'page' (e.g. trace 4663465821420d02000d2b47b6a0c27a: page 176 ms, count 18 ms, sanitize 18 ms).

The same query on production, prepared as ipx sends it, for the same account: 24 ms (custom plan), 23 ms (generic plan), 31 ms with EXPLAIN SERIALIZE unpacking the 507 kB of rows, all from shared buffers. The pool is not it: ipx_db_wait_seconds is under 5 ms for all but a handful, 20 connections open and idle. Not on the hour (scans), and not tied to how many other requests the page load made.

So about 150 ms is spent inside ipx's call and outside Postgres's own time, and the trace cannot yet say where. Next: the step records wait_ms and query_ms (the statement's time on its connection, as #367's metric measures it), so a slow trace says which.

Aside: the plan seq-scans all 33k of the account's entry_state rows (about 8 ms) because it estimates 13,117 candidate items where unread_from leaves 667.

Over 7 days of traces, GET /api/entries (All Subscriptions, Unread, first page of 50) is p50 33 ms, p90 169 ms, p99 208 ms, nearly all of it the step 'page' (e.g. trace 4663465821420d02000d2b47b6a0c27a: page 176 ms, count 18 ms, sanitize 18 ms). The same query on production, prepared as ipx sends it, for the same account: 24 ms (custom plan), 23 ms (generic plan), 31 ms with EXPLAIN SERIALIZE unpacking the 507 kB of rows, all from shared buffers. The pool is not it: ipx_db_wait_seconds is under 5 ms for all but a handful, 20 connections open and idle. Not on the hour (scans), and not tied to how many other requests the page load made. So about 150 ms is spent inside ipx's call and outside Postgres's own time, and the trace cannot yet say where. Next: the step records wait_ms and query_ms (the statement's time on its connection, as #367's metric measures it), so a slow trace says which. Aside: the plan seq-scans all 33k of the account's entry_state rows (about 8 ms) because it estimates 13,117 candidate items where unread_from leaves 667.
rays added the bug label 2026-11-27 20:24:21 -08:00
Author
Owner

467ac13, deployed in ipx: database steps now carry wait_ms and query_ms. Checked on trace 20579ce614305f4d72347c71d5d1c93d: page wait_ms 0, query_ms 32. Next slow one: $Q spans '{ span.of = "page" && duration > 120ms }' 7d, then $Q trace . (Tempo stores the two as strings, so filter on duration, not on query_ms.) Left open until a slow trace names the cause.

467ac13, deployed in ipx: database steps now carry wait_ms and query_ms. Checked on trace 20579ce614305f4d72347c71d5d1c93d: page wait_ms 0, query_ms 32. Next slow one: $Q spans '{ span.of = "page" && duration > 120ms }' 7d, then $Q trace <id>. (Tempo stores the two as strings, so filter on duration, not on query_ms.) Left open until a slow trace names the cause.
Author
Owner

Since 467ac13 (deployed 2026-11-28 04:29) every All Subscriptions Unread page has been 15-63 ms, wait_ms 0, so no slow trace has the split yet. Ruled out with a week of metrics: not uptime (fast at 46-67 h up on 11-21/22, slow at 12-18 h on 11-23), not a leak (ipx_runtime_tasks 13-40, ipx_runtime_queue 0, ipx_event_listeners 0-5, open fds 43-61, resident ~150 MB, all flat), not Postgres in general (select average 2.5-5.8 ms, wait 0.15 ms throughout), not the worker, scans, DeadAir or Tower's load. Slow periods: 11-23 ~12-18 UTC and 11-27 ~12 UTC to 11-28 04 UTC, the page step 120-180 ms nearly every time. Waiting for the next one with wait_ms and query_ms on its trace.

Since 467ac13 (deployed 2026-11-28 04:29) every All Subscriptions Unread page has been 15-63 ms, wait_ms 0, so no slow trace has the split yet. Ruled out with a week of metrics: not uptime (fast at 46-67 h up on 11-21/22, slow at 12-18 h on 11-23), not a leak (ipx_runtime_tasks 13-40, ipx_runtime_queue 0, ipx_event_listeners 0-5, open fds 43-61, resident ~150 MB, all flat), not Postgres in general (select average 2.5-5.8 ms, wait 0.15 ms throughout), not the worker, scans, DeadAir or Tower's load. Slow periods: 11-23 ~12-18 UTC and 11-27 ~12 UTC to 11-28 04 UTC, the page step 120-180 ms nearly every time. Waiting for the next one with wait_ms and query_ms on its trace.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rays/ipx#501