Repository navigation
perf(history): list channel backfill, resume and Webex sessions from the listing index - #36240
Conversation
Code change approver recommendation: A person should decideWhy: the decider raised 1 possible problem and estimates a 45% chance that this change introduces a defect; a person should check it. The three production call-site swaps to Things to check (possible problems the decider raised; at this confidence many turn out to be fine):
An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
001c2a4 to
5505d75
Compare
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. This moves three more callers onto the existing listing index. The rows and their order stay the same, the 2 s → 5 s lag on another process's appends is a documented trade-off, and a revert undoes it cleanly. [DESIGN-REVIEWED] 288ac17 Description read[DESCRIPTION-READ] 1f16b421c990c574bacb1e1b6e8e069a0aa58bc157caf92db13bc8ea76a74372 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. This is a perf fix that points three callers at the existing listing index, and every remaining full-scan caller is either kept on purpose with a reason or listed under Not a goal. What this change shipsInventory (5 items) — 5 justifiedIntent: the channel backfill, the resume picker and Webex
Siblings counted: I grepped [FIRST-PRINCIPLES-REVIEWED] 288ac17 Description read[DESCRIPTION-READ] dbb651c4013102480903eb42e872ed5cb41ac1ddcf3ecc5a812901eeda2342cf That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
5505d75 to
6b2c212
Compare
…the listing index
6b2c212 to
288ac17
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Read the full diff. Part of #36138 / #33842, the same pattern as #35938. Three callers switch from list_sessions to list_sessions_indexed: the channel folder backfill, the channel resume picker with its title fallback, and the Webex /sessions command. list_sessions_indexed returns the same rows in the same order as fresh copies.
On access: every filter these callers apply happens after the listing and is unchanged. The Webex bucket/generation route match stays as is, and so do the resume picker's eligibility pass and needles_match_text title fallback, and the backfill's per-namespace checks. No app-scoped listing is touched; it keeps the direct scan as before. So no channel user sees a session they could not see on main. The only difference is freshness: another process's append to an existing transcript shows after the next reconcile, up to RECONCILE_SECS. Files created or removed still show on the next call. The spec now lists these callers, and it also documents why backfill_index keeps the scan. The new test pins one row read after an in-process write at every size for all four paths. No regex, no new refusal. LGTM.
Problem / Motivation
Goal: The channel folder backfill, the channel resume picker and the Webex
/sessionscommand list sessions in milliseconds on a busy gateway, instead of re-reading every transcript after each write.These gateway callers still list sessions with the full scan,
ConversationLog.list_sessions(). On a gateway that is writing transcripts, the scan's memo misses after every write, so each call re-reads one row per transcript on a worker thread, holding the GIL. At 9,338 transcripts that is about 1 s per call, against about 15 ms from the listing index (#35938's measurement). #33874 and #35938 moved the dashboard listings and the Shared Crew reads; these are the remaining full-scan callers outside the ones kept on purpose.Why it matters
When several of these scans run at once they fill the shared default executor, and unrelated dashboard requests wait behind them until the tunnel times out with a 524.
Not a goal
list_sessions(keys=...)calls,list_sessions_status()(the channel reconcile), or the callers kept on the scan on purpose:session_revive._consider, the boot restore and the one-shot crew-mode migration.What changed (motivation → approach → change)
The channel folder backfill, the resume picker and the Webex
/sessionscommand now re-read only the transcript that changed, so its cost stays flat as history grows. Each call moves fromlist_sessions()tolist_sessions_indexed(), which returns the same rows in the same order:dashboard/channel_slots.pybackfill_channel_foldermodified, for one channelget_metadatamessaging/session_resume.pyresolve_session_choices(listing and title fallback)memory_modewebex/transport_dispatch_commands.py_handle_sessionsThe one difference is the one #33874 accepted: another process's append to an existing transcript shows within
RECONCILE_SECS(5 s) instead of 2 s. Writes in this process, and files created or removed by anyone, show at once.memory_mode, which the resume picker filters incognito sessions on, comes from the same metadata line in both paths; a metadata rewrite by another process already lagged up to 2 s on the scan. The search index pass (SessionCatalogProjection.backfill_index) stays on the scan. It runs only in the index worker's own spawned process, so it never holds the gateway's GIL or its default executor. That process writes no transcript, so every gateway append would reach its index only after a reconcile, up to two worker passes (60 s each when idle) later, and the process would also hold its own copy of the index.The history spec lists the three moved callers among the index's callers and the search index pass among those kept on the scan, with its reason.
Backwards compatibility
Compatible: same rows, same order; another process's append to an existing transcript shows in these three listings within 5 s instead of 2 s.
Removes nothing: no route, row, key, command or function is taken away.
Tests
test/test_session_listing_callers_index.py: after one in-process append, each caller re-reads 1 row at 600, 1200, 2400 and 4704 transcripts (backfill, resume listing, resume title fallback, Webex/sessions). With the change reverted all 16 fail, readingnrows (assert 600 == 1up toassert 4704 == 1).test/channel_folders_helpers.py,test/discord_sessions_helpers.py,test/test_teams_sessions.py,test/test_webex_dispatch_commands.py: the fake logs servelist_sessions_indexed.test/test_telegram_sessions.py: the two owner-gate tests patchlist_sessions_indexed, the read the picker makes. With the owner gate forced open,test_owner_gate_runs_before_history_read[private-chat-not-user]fails (assert 1 == 0); patchinglist_sessionsinstead passes either way.-n0(16/16 each) and 10 at-n 4 --dist loadgroupbesidetest_channel_folders_backfill.pyandtest_webex_dispatch_commands.py(105/105 each); a shuffled order (seed 36138) of the new file,test_channel_folders_backfill.pyandtest_teams_sessions.pypassed 125/125.Manual verification
N/A: unit coverage of each caller's read path; the index's parity with the scan is covered by
test_history_listing_index.py.Related Issues
Closes #36138
Part of #33842
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)