Skip to content

perf(mobile): build the two projected git enums once, not per parse - #21311

Merged
Jinwoo-H merged 1 commit into
mainfrom
hoist-reply-enums
Sep 18, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
hoist-reply-enums

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 0 0 0 0
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

What this is

Two reply-schema helpers built a z.enum(...) inside the function that runs on every reply: readProjectedConflictOperation in git-status-reply-schema.ts and readProjectedCompareStatus in diff-review-reply-schema.ts. Every git.status and git.branchCompare reply paid to construct a schema before using it. The enums are now module constants, and the git-status payload schema reuses the same instance instead of a second copy. Nine lines, two files, behaviour-identical; the comments explaining the coercion fallbacks are kept.

Numbers

Median ns per parse, twenty timed rounds of two thousand parses after five warm-up rounds, same reader result digests on both legs:

reader before after
git.status (branchContextStatusRead, 11 recorded cases, median) 3404 1368
git.branchCompare (reviewBranchCompareRead, median) 2884 628

How it was found

A trial of zod's z.compile (not adopted: 0.89x net across all recorded readers, and Hermes has no new Function so nothing JITs on device) showed these two readers regressing 2.2x under global compile, because compile shims every schema construction and these constructed one per parse. Removing the per-parse construction is the fix regardless of compile.

Gates

Recording suites 23 files, 986 passed; zero goldens moved; source-control + session suites 196 files, 1875 passed; mobile tsc 0; oxfmt and oxlint clean; changed-code quality 0 findings. Lead re-verified in a clean tree under the pinned zod 4.4.3: tsc 0, 52 files / 1210 tests, zero goldens.

`readProjectedConflictOperation` and `readProjectedCompareStatus` constructed
a `z.enum` on every call, so every `git.status` and `git.branchCompare` reply
paid the constructor. Hoisted to module constants; the git-status payload
schema reuses the same instance. Behaviour is unchanged: same arms, same
fallbacks, identical reader output on all eleven recorded matrix cases.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d0230fc6-0c86-465b-8021-b81f12e7d234

📥 Commits

Reviewing files that changed from the base of the PR and between 754134f and a58e01b.

📒 Files selected for processing (2)
  • mobile/src/session/diff-review-reply-schema.ts
  • mobile/src/source-control/git-status-reply-schema.ts

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


📝 Walkthrough

Walkthrough

The change creates module-level Zod enum schemas for branch compare status and conflict operation. The schemas are reused by payload validation and projected-value parsing. Successful parse results and fallback values remain unchanged.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to a58e0

The PR reuses equivalent enum schema instances while preserving parsing and fallback behavior, so it is mergeable with normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description clearly explains the change, rationale, performance results, and validation. However, it omits the required template sections for ELI5, Linked Issue, Visual Proof, Testing checklist, A… Add the missing template sections. Include a linked issue after “Fixes #”, write N/A with a reason under Visual Proof because there is no UI or behavior change, document testing under Testing, complete the required checkboxes, and address…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: hoisting two projected Git enum schemas to module-level constants to avoid per-parse construction.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.
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 clearly explains the change, rationale, performance results, and validation. However, it omits the required template sections for ELI5, Linked Issue, Visual Proof, Testing checklist, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. It also does not provide the required issue link or explicitly state N/A for visual proof.

Resolution

Add the missing template sections. Include a linked issue after “Fixes #”, write N/A with a reason under Visual Proof because there is no UI or behavior change, document testing under Testing, complete the required checkboxes, and address the remaining Notes and Agent skill upstream boundary sections.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

This PR hoists two z.enum(...) constructions out of the functions that run on every reply and into module-level constants.

  • diff-review-reply-schema.ts — adds gitBranchCompareStatusSchema (line 31) and points readProjectedCompareStatus at it.
  • git-status-reply-schema.ts — adds gitConflictOperationSchema (line 28), used by both readProjectedConflictOperation and the conflictOperation field of gitStatusHostPayloadSchema, replacing a second, separate z.enum instance.

The change is behavior-identical. z.enum schemas are stateless and safeParse does not mutate them, and salvagedOptional wraps the schema it is handed in a transform rather than calling .optional() on it in place, so sharing a single instance between the payload schema and the projection reader cannot couple the two parse paths. Both readers are already pinned by tests (session-reply-schema.test.ts, source-control-reply-schema.test.ts), so no new coverage is needed for a pure construction hoist.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 1cd2964 into main Sep 18, 2026
24 checks passed
@Jinwoo-H
Jinwoo-H deleted the hoist-reply-enums branch September 18, 2026 00:35
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…tablyai#21311)

`readProjectedConflictOperation` and `readProjectedCompareStatus` constructed
a `z.enum` on every call, so every `git.status` and `git.branchCompare` reply
paid the constructor. Hoisted to module constants; the git-status payload
schema reuses the same instance. Behaviour is unchanged: same arms, same
fallbacks, identical reader output on all eleven recorded matrix cases.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
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