Skip to content

conversation-outline rebuilds 2-3 MB on almost every open of a long, busy thread (0.49.0): key includes outlineSequence and status, no incremental build #7399

Open

Description

@lucascastellanibr

Summary

On bb 0.49.0, opening a long thread shows the skeleton for 1–4 s. GET /api/v1/threads/:id/conversation-outline rebuilds the whole outline of the thread on the event loop whenever the stored copy does not match, and for a busy thread it almost never matches.

This is the same class of problem as #1972 (closed 2026-08-20), still present with the stored projection that replaced the in-memory cache.

Why the stored outline rarely hits (0.49.0 bundle, loadThreadConversationOutline)

  • buildThreadConversationOutlineProjectionKey puts outlineSequence and thread.status in the key ([version, rewriteGeneration, outlineSequence, providerId, providerDisplayName, status, title, titleFallback, completedTurnDisplay, includeClearedContextHistory]). Any new outline-relevant event, or a status change, makes the stored row stale.
  • shouldMaterializeThreadConversationOutline only stores when the thread is idle or error, so a thread that is working is rebuilt in full on every request.
  • On a miss the rebuild is one runEventLoopWorkSync("conversation-outline <id>") over the whole history; nothing is appended to the previous result.

Coordinator threads that receive child notifications all day are the worst case: each click rebuilds 2–3 MB.

Measured (one Linux server, bb 0.49.0, through bb connect)

Stored outlines (thread_conversation_outlines.items_json), largest four: 3.13 MB (thread with 140,688 events), 2.45 MB, 2.40 MB (115,317 events), 2.24 MB. 64 rows in total.

conversation-outline requests since the server started on 0.49.0 (957 requests, originTtfbMs from the connect plugin's log line, so server time only):

ms
p50 68
p90 793
p99 2,535
max 3,796

151 of 957 took more than 0.5 s and 71 more than 1 s. The slowest eight are all the four or five largest threads (2.6–3.8 s each, 140–410 kB compressed response). In the same period the event-loop stall log's longest synchronous work is conversation-outline <thread> or timeline-build <thread> for those threads.

Expected

Opening a long thread should not cost a full rebuild.

Suggested direction

  1. Incremental outline: keep the stored items and append/patch only what changed after the stored outlineSequence, instead of rebuilding from sequence 0. Take status (and other header-only fields) out of the key so a status flip does not invalidate the items.
  2. And/or paginate: return the last N turns first and load older ones on scroll, as the timeline already does with its window.
  3. Materialize for active threads too (or keep the last stored items as the base for 1).

Related: #7281 (single cascade DELETE blocks the server), #6859, #1972.

Activity

  1. added theissue type on Nov 10, 2026
  2. added
    threads
    on Nov 10, 2026
  3. lucascastellanibr commented on Nov 10, 2026

    @lucascastellanibr
    Author

    More data from the same server (bb 0.49.0, about 19 h since the server started on it), for the "Loading latest messages…" state that stays on screen for a long time on these threads.

    Measured, from the server's own Event loop stalled log lines (threshold 500 ms):

    • 1,397 stalls: p50 778 ms, p90 1,483 ms, max 3,685 ms, 1,288 s stalled in total (about 2% of wall time).
    • 1,345 of them are stallAttribution: unattributed. Only 31 carry a candidate, all conversation-outline <thread>.
    • longestSynchronousWork in the stalled interval:
    longest tracked sync work stalls its wall time, summed stall time, summed
    ws:daemon heartbeat 661 1.0 s 544 s
    timeline-build <thread> 544 69.7 s 514 s
    conversation-outline <thread> 157 158.4 s 190 s
    ws:daemon host-rpc.response 21 0.04 s 26 s

    So for the outline rows the tracked work explains the stall. For the other ~1,200 stalls the longest tracked work is far shorter than the stall (a 1 ms heartbeat inside a 0.8 s stall): the time is spent in work that runEventLoopWorkSync does not wrap.

    • lastCompletedWork of the stalled intervals: POST /internal/session/events 453, plugin:provider-codex experimental_thread.events handler 150, POST /api/v1/plugins/automations/cli 106, GET /api/v1/projects 80.
    • Only 385 of the 1,397 stalls have a Slow DB query line in the 5 s before them.

    Reported by the same user on the client (not re-measured here): GET /timeline itself answers in 20–70 ms (150–490 kB) for these threads; the banner is the thread detail's catching-up state, whose refetch waits behind the stalls above.

    Inferred: most of the unattributed stall time is synchronous JS on the server while it ingests session events for threads with 75k–180k events (projection / outline / JSON work), not SQLite.

    Ask: a CPU profile of the server while one or two threads of that size are streaming would show it directly. If there is a supported way to capture one on a production install (a flag or an env var for --cpu-prof / inspector), I can run it here and attach the result.

  4. added
    partial-repro
    on Nov 10, 2026
  5. bb-slop-cop commented on Nov 10, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Medium · threads, perf.
    • Report: Reproduction and root cause, including the complete reproduction test.
    • Verdict: PARTIALLY REPRODUCED · Confidence: High for the measured replay paths · Label: partial-repro.
    • Root cause: Status changes invalidate incremental checkpoints; manager-message-only history never advances its turn-based checkpoint. Incremental completed-turn appends already work.
    • Verification: Both clean checkouts reproduced full reads of 3,000 rows after a status change and 1,001 rows after a manager-message append. The incremental append control selected six rows; 38 existing tests passed. Production latency and payload-size claims remain unverified.
    • No PR: Removing status alone risks stale projected content; a safe status-aware, turn-free checkpoint design was not established within the simple-fix constraints.

    AGENT GENERATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    partial-reproperfthreads

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions