Skip to content

perf(workspace): index event polls and share cached stream heads - #789

Merged
zomux merged 1 commit into
developfrom
codex/workspace-poll-index-cache
Oct 15, 2026
Merged

zomux merged 1 commit into
developfrom
codex/workspace-poll-index-cache

Conversation

@zomux

@zomux zomux commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Type-filtered event polls and newest-event lookups walked workspace timestamp indexes and filtered unrelated history, producing multi-second queries. Add concurrent partial indexes for posted messages, agent controls, and tool results, and use matching constant predicates for those known prefixes while preserving existing subtype/LIKE behavior for all callers.

Share newest-event positions across workers through a one-second Redis cache. ORM event inserts, edits, and deletions invalidate it after commit using generation keys, preventing an in-flight old query from repopulating the current generation. Cached heads cannot regress a cursor behind returned messages or a valid incoming cursor. Empty streams are cached without inventing a cursor or dropping history.

Coordinate identical cache fills with token-owned Redis locks and a bounded 100 ms wait; Redis failures and contention fall through to normal queries. Authentication and visibility checks remain before response-cache access. Existing cache scopes and response freshness remain unchanged.

Validation: 50 focused polling, privacy, cursor-race, invalidation/rollback, and cache tests passed, including eight concurrent requests against disposable Redis with one fill and expiry verification. Read-only comparisons on production data returned identical IDs/payloads for old/new predicates in both sort directions. After migration 083, the six tested queries use their intended indexes and execute in 0.028–0.115 ms inside PostgreSQL (roughly 1–4 ms from the backend host). The old parameterized predicates also benefit from the new indexes. Current connector message cursors are already persisted and resumed; no client history behavior was changed. Live API/load validation will follow deployment.

Production verification: released as fd8df41. 50 focused tests passed, including real Redis concurrency. All 101 deployment health checks passed; 13 event-stream connections returned 500 during replacement. The subsequent 60-second sample contained 19,920 application requests, mean 72 ms / p95 203 ms, with zero 5xx. Event polls averaged 68 ms / p95 197 ms; CPU averaged 67%. New index query plans execute in 0.028–0.115 ms internally; production-data comparisons preserved results. Natural-traffic comparisons do not establish an additional mean-latency improvement from Redis beyond the indexes.

@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openagents-workspace Ready Ready Preview Oct 15, 2026 6:09pm UTC

Request Review

@zomux
zomux merged commit fd8df41 into develop Oct 15, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — 6bdfb280 Deployed Oct 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant