Skip to content

perf(client): avoid temporary arrays in inbox snapshots - #27467

Open
UtkarshUsername wants to merge 1 commit into
pingdotgg:mainfrom
UtkarshUsername:perf/inbox-snapshot-map
Open

UtkarshUsername wants to merge 1 commit into
pingdotgg:mainfrom
UtkarshUsername:perf/inbox-snapshot-map

Conversation

@UtkarshUsername

Copy link
Copy Markdown
Contributor

Problem

Every sidebar inbox observation converts tracker state into two temporary arrays of entries just to copy working-state flags into a snapshot Map.

Change

Populate the snapshot Map directly. Observations still own a separate snapshot, so later tracker updates cannot change earlier answers.

Scope and approval

Small, focused removal of redundant intermediate allocations under CONTRIBUTING.md's focused-fix exception. No new cache, contract, setting, or intentional product behavior change.

Verification

Sampled allocation bytes per complete inbox observation:

Workload Before After Reduction
100 idle threads 69,912 48,414 30.7%
1,000 idle threads 650,397 437,387 32.8%
1,000 working threads 650,228 433,209 33.4%
  • Node 26.12.1/Windows, Vite-built helper, three separate allocation profiles per arm. Measured independently against upstream main; does not depend on perf(client): skip idle inbox placement serialization #27460.
  • Five isolated A/B timing trials plus five paired A/A controls. Timing is inconclusive against baseline variation; no speedup claim. GC totals generally fell in separate probes; one whole-process diagnostic recorded a higher maximum pause (8.10 → 9.76 ms, including warmup and forced GCs). Peak RSS varied. No retained-memory or GC-pause guarantee.
  • All 22 existing inbox tests and 115,200 generated thread-state comparisons pass, including saved-observation isolation, deadlines, notifications, placement changes, and working transitions.
  • Targeted formatting/lint and client-runtime, desktop, and scripts typechecks pass. The same pre-existing web typecheck errors for two missing secret-provider packages remain. Browser rendering was not measured.
  • Final committed source matches the measured candidate.

Model: gpt-6.1-sol. Harness: Codex in T3 Code.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Oct 30, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 90e3623

Macroscope's review found this PR approvable — Inbox snapshots now populate their Map directly, avoiding temporary arrays while retaining independent snapshot values. The change leaves product behavior and defaults unchanged and presents no obvious material risk.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 305a90d and 90e3623.

Files selected for processing: 1
  • packages/client-runtime/src/state/threadInbox.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

createInboxReturnTracker.observe now builds its observed working-state map by iterating over thread states. The resulting key-value mapping remains unchanged.

Changes: Inbox snapshot

Layer / File(s) Summary
Build observed snapshot
packages/client-runtime/src/state/threadInbox.ts
observedWorking is populated by iterating over states and storing each state’s working value by key.

Priority: Low

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Refactor

Possibly related PRs

Suggested reviewers: t3dotgg, macroscopeapp

Merge Risk: Minimal · up to 90e36

No merge-blocking behavior change was found in this focused allocation optimization.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: removing temporary arrays during inbox snapshot creation. It uses a conventional commit format and matches the changeset.
Description check Passed The description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the focused fix, reports measured allocation results, documents test and typecheck re…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the focused fix, reports measured allocation results, documents test and typecheck results, and identifies known pre-existing errors and limitations.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant