Skip to content

perf: ⚡️ speed up the Hono API, data loading and React rendering across the repo - #885

Merged
aXenDeveloper merged 2 commits into
canaryfrom
claude/perf-improvements
Oct 18, 2026
Merged

aXenDeveloper merged 2 commits into
canaryfrom
claude/perf-improvements

Conversation

@aXenDeveloper

Copy link
Copy Markdown
Owner

API

  • SSR hands API calls to the in-process Hono app instead of looping over HTTP
  • withPagination runs the count and the page query in parallel
  • in-memory LRU cache (15s TTL cap) when Redis is not configured
  • fewer and parallel staff-permission queries, per-request device/epoch memos
  • core middleware object built once at boot; event listeners indexed by name
  • timeouts on captcha, SSO, cron and storage fetches
  • hono/compress on the standalone API, pre-compressed static assets
  • queue drains batches with limited concurrency, set-based status updates
  • emails processed right after the response, pooled SMTP transport
  • cron jobs claimed atomically so multi-instance deploys run them once
  • websocket: stringify once, user/room indexes, heartbeat, client backoff
  • notifications: skip recipientIds on read paths, sliced fanout, seekable
    inbox cursor, cached admin overview totals
  • search: bulk upsert, container deletes in one statement, capped ES totals
  • AI policies and action settings resolved in batches
  • indexes for roleId, session expiry, delivery eventId, queue retention,
    AI history, user files and the moderation queue

Content Engine

  • never-public draft edits no longer expire the public page cache
  • generation-keyed public list/detail cache, cached container trees
  • parallel hydration, optional publicApi.listFields, narrow delivery metadata
  • concurrent write effects, dependent search reindex on the queue

Web

  • session refresh no longer blocks navigation; 75ms intent preload
  • profile timeline streams from the loader; cached llms/docs text
  • AutoForm memoizes its schema, WAAPI shake instead of motion
  • visual editor split contexts and memoized blocks; debounced TipTap onChange
  • dnd-kit lazy-loaded only for reorderable tables
  • marketing.css loaded per route; no transition-all; cheaper glows
  • forum: cached stats, topics with stats in one request, lazy composer

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01BpbpzvNwCm19By2HEKWq7d

@github-actions github-actions Bot added the 🚀 Performerce Improves performance label Oct 17, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T20:41:03.766397Z 19a4c02 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b67a8070a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/api/src/index.ts
Comment thread packages/vitnode/src/api/models/email.ts Outdated
@aXenDeveloper
aXenDeveloper force-pushed the claude/perf-improvements branch from 9b67a80 to 7e73002 Compare October 18, 2026 10:18
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 19a4c02.

@aXenDeveloper
aXenDeveloper force-pushed the claude/perf-improvements branch from 7e73002 to 603871f Compare October 18, 2026 10:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 603871f64d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/vitnode/src/api/modules/queue/helpers/process-queue-tasks.ts Outdated
…ss the repo

API
- SSR hands API calls to the in-process Hono app instead of looping over HTTP
- withPagination runs the count and the page query in parallel
- in-memory LRU cache (15s TTL cap) when Redis is not configured
- fewer and parallel staff-permission queries, per-request device/epoch memos
- core middleware object built once at boot; event listeners indexed by name
- timeouts on captcha, SSO, cron and storage fetches
- hono/compress on the standalone API, pre-compressed static assets
- queue drains batches with limited concurrency, set-based status updates
- emails processed right after the response, pooled SMTP transport
- cron jobs claimed atomically so multi-instance deploys run them once
- websocket: stringify once, user/room indexes, heartbeat, client backoff
- notifications: skip recipientIds on read paths, sliced fanout, seekable
  inbox cursor, cached admin overview totals
- search: bulk upsert, container deletes in one statement, capped ES totals
- AI policies and action settings resolved in batches
- indexes for roleId, session expiry, delivery eventId, queue retention,
  AI history, user files and the moderation queue

Content Engine
- never-public draft edits no longer expire the public page cache
- generation-keyed public list/detail cache, cached container trees
- parallel hydration, optional publicApi.listFields, narrow delivery metadata
- concurrent write effects, dependent search reindex on the queue

Web
- session refresh no longer blocks navigation; 75ms intent preload
- profile timeline streams from the loader; cached llms/docs text
- AutoForm memoizes its schema, WAAPI shake instead of motion
- visual editor split contexts and memoized blocks; debounced TipTap onChange
- dnd-kit lazy-loaded only for reorderable tables
- marketing.css loaded per route; no transition-all; cheaper glows
- forum: cached stats, topics with stats in one request, lazy composer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BpbpzvNwCm19By2HEKWq7d
@aXenDeveloper
aXenDeveloper force-pushed the claude/perf-improvements branch from 603871f to b1978bb Compare October 18, 2026 12:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1978bbf87

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/vitnode/src/api/models/search.ts
Comment thread packages/vitnode/src/content/server/public-cache.ts Outdated
- queue: save each task's result as it finishes, fenced by its claim, so a
  slow sibling can't push finished tasks past their lease
- search: delete from the provider before the canonical rows, so a failed
  provider call stays retryable
- content cache: the public generation bump rethrows a failed write, so
  invalidation retries instead of serving the old generation
- email/notifications: run after-response delivery on the request's
  waitUntil where the runtime provides one (web bridge, in-process SSR)
- api: give JSON responses a Content-Length so compress() skips small bodies
- create-vitnode-app: register the in-process API like apps/web

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BpbpzvNwCm19By2HEKWq7d

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19a4c02017

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


// Without Redis, sessions, devices and staff permissions would otherwise hit
// the database on every request. One store per app, shared by its requests.
const memoryCache = cacheClient ? null : new MemoryCacheStore();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep no-Redis domain caching disabled

When multiple API instances run without REDIS_URL, this creates independent process-local caches: a staff-permission grant cached on instance B is not cleared when a permission removal is handled by instance A, so B can continue authorizing the removed grant for up to the 15-second memory TTL. Leave CacheModel unbacked in this configuration or add shared invalidation; the repository explicitly defines domain caching as a no-op when Redis is absent.

AGENTS.md reference: AGENTS.md:L53-L53

Useful? React with 👍 / 👎.

Comment on lines +386 to +390
const requestedOffset =
requestedPage === undefined ? 0 : (requestedPage - 1) * pageSize;
const [totalCount, speculativeEdges] = await Promise.all([
fetchTotalCount(c, table, baseWhere),
pageAt(requestedOffset),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clamp numbered pages before issuing the OFFSET query

For any numbered-pagination endpoint, page accepts values up to Number.MAX_SAFE_INTEGER, so a request such as page=9007199254740991 now starts an enormous OFFSET query before the count is known. PostgreSQL must scan and discard the matching rows, and after the count clamps the page this code issues another page query, turning an otherwise cheap out-of-range request into multiple full scans; count and clamp numbered pages before starting their row query, or bound the page number.

Useful? React with 👍 / 👎.

* instances can never point reads back at an older generation.
*/
export const invalidateForumStats = async (c: Context): Promise<void> => {
await c.get("cache").setSystem(GENERATION_KEY, randomUUID());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Propagate forum generation write failures

When Redis transiently rejects this new forum-generation write, the default setSystem path catches the error and resolves, so the event listener reports successful invalidation while readers keep using the old forum/topic counts and latest-topic data for the full 300-second TTL. Use the strict cache-write option here so the existing event failure handling can observe and retry the invalidation.

Useful? React with 👍 / 👎.

@aXenDeveloper
aXenDeveloper merged commit 93d9bf2 into canary Oct 18, 2026
7 checks passed
@aXenDeveloper
aXenDeveloper deleted the claude/perf-improvements branch October 18, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚀 Performerce Improves performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants