Skip to content

perf(mobile): precompute Linear issue sort keys - #20249

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-mobile-linear-sort-keys
Sep 13, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-mobile-linear-sort-keys

Conversation

@nwparker

@nwparker nwparker commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​93 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​89
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​131 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​111

ELI5

Calculate each Linear issue’s sort values once, then reuse them while ordering the list.

Mobile Linear issue sorting repeats date parsing or numeric collation setup inside every comparison. Replace the comparator with a batch sorter used by loading, view projection, and grouping. Dates and priority ranks are computed once per issue; identifier sorting reuses one default-locale numeric collator. Empty/singleton lists skip setup.

Preserves descending updated time, priority-0 ranking, invalid-date fallback, numeric identifier order, stable ties, input immutability, and original issue objects. No RPC, provider, host, workspace, rendering, or persistence behavior changes.

Counterbalanced Node 24/macOS timings against 20ab9950654 with exact output parity (synthetic inputs; not Hermes/device timings):

Issues / mode Before After
200 / identifier 2.410 ms 0.148 ms
200 / priority 0.108 ms 0.031 ms
200 / updated 0.038 ms 0.023 ms
1,000 / identifier 14.733 ms 0.902 ms

Reproduce: ORCA_BACKGROUND_LAUNCH=1 node config/scripts/mobile-linear-sort-benchmark.mjs 20ab9950654.

Validation: 273 task tests pass, plus final focused tests after strengthening tie coverage; mobile typecheck and formatting pass, lint has no errors (the deliberately retained baseline comparator in the parity test triggers the performance advisory). Swedish/Turkish locale runs pass. Three operation-count regressions fail against the baseline comparator through an adapter and pass with the batch implementation. The original source-fingerprint suite passed on baseline; three computation fingerprints were refreshed for the intentional change. All fingerprint counts, runtime-string/semantic, render, and style guards remain unchanged.

Merge order

Stacked on #20233. Merge #20233 first, then retarget this PR to main. Source fingerprints reflect both optimizations; 18 combined sorting/parity tests pass. The intentional baseline comparator is annotated for lint.

@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 1c8ef62d-1b22-4d79-9459-1dbe86a43fa4

📥 Commits

Reviewing files that changed from the base of the PR and between 1a9a5f9 and 584dc8d.

📒 Files selected for processing (10)
  • config/scripts/mobile-linear-sort-benchmark.mjs
  • config/scripts/mobile-task-sort-benchmark.mjs
  • mobile/src/tasks/mobile-linear-sort.test.ts
  • mobile/src/tasks/mobile-task-sort.test.ts
  • mobile/src/tasks/mobile-tasks-refactor-parity.test.ts
  • mobile/src/tasks/mobile-tasks-repository-presentation.ts
  • mobile/src/tasks/mobile-tasks-reviewer-linear.ts
  • mobile/src/tasks/use-mobile-tasks-picker-projection.tsx
  • mobile/src/tasks/use-mobile-tasks-provider-view-projection.tsx
  • mobile/src/tasks/use-mobile-tasks-task-list-loading.tsx

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


📝 Walkthrough

Walkthrough

The change replaces pairwise mobile task and Linear issue comparators with array-level sorting helpers. Sorting consumers now call the shared helpers. New tests verify ordering, stability, immutability, setup costs, and parity. Two benchmark scripts compare output and runtime against baseline revisions.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 584dc

Sorting behavior appears correct, but add identity assertions for empty and singleton repository sorting so a future regression that returns the input array is caught.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the implementation, rationale, performance results, and validation. However, it omits several required template sections, including the linked issue, visual proof or an explic… Add all required template sections. Include a valid issue reference under Linked Issue, provide visual proof or write N/A with a reason, complete Testing and Checklist items, address AI Disclosure, Review, Agent skill upstream boundary, and…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the main change: precomputing Linear issue sort keys for mobile performance.
Full details: Description check

Explanation

The description explains the implementation, rationale, performance results, and validation. However, it omits several required template sections, including the linked issue, visual proof or an explicit N/A explanation, AI disclosure, review, agent skill boundary, notes, and checklist confirmations.

Resolution

Add all required template sections. Include a valid issue reference under Linked Issue, provide visual proof or write N/A with a reason, complete Testing and Checklist items, address AI Disclosure, Review, Agent skill upstream boundary, and Notes.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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 critical issues — one consistency nit inline.

Reviewed changes

  • Batch Linear sorter — mobile-tasks-reviewer-linear.ts replaces the compareLinearIssues comparator with sortLinearIssues, computing taskTime/priority rank once per issue and reusing a single numeric Intl.Collator for identifier order.
  • Call sites — groupLinearIssues plus the view-projection and task-list-loading hooks now delegate to sortLinearIssues.
  • Tests — new mobile-linear-sort.test.ts pins ordering, stable/identity ties, per-pass Date.parse/Intl.Collator counts, and empty/singleton no-ops against an independent oracle.
  • Benchmark — new config/scripts/mobile-linear-sort-benchmark.mjs asserts old/new output parity and reports counterbalanced medians.
  • Parity fingerprints — three computation hashes refreshed; semantics/render/style hashes unchanged, confirming the change surface is limited to sorting.

Verified locally: 273 mobile task tests pass, tsc --noEmit is clean, the benchmark runs and its parity assertion holds, and the changed-code quality gate reports 0 findings. I also confirmed Intl.Collator with numeric: true is supported on Hermes for RN 0.83/Expo 55 and shares the same internal path as localeCompare(..., undefined, { numeric: true }), so the identifier ordering is not a runtime regression.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker changed the base branch from main to nwparker/perf-mobile-task-sort-keys September 12, 2026 07:40

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 1c8ef62d-1b22-4d79-9459-1dbe86a43fa4

📥 Commits

Reviewing files that changed from the base of the PR and between 1a9a5f9 and 584dc8d.

📒 Files selected for processing (10)
  • config/scripts/mobile-linear-sort-benchmark.mjs
  • config/scripts/mobile-task-sort-benchmark.mjs
  • mobile/src/tasks/mobile-linear-sort.test.ts
  • mobile/src/tasks/mobile-task-sort.test.ts
  • mobile/src/tasks/mobile-tasks-refactor-parity.test.ts
  • mobile/src/tasks/mobile-tasks-repository-presentation.ts
  • mobile/src/tasks/mobile-tasks-reviewer-linear.ts
  • mobile/src/tasks/use-mobile-tasks-picker-projection.tsx
  • mobile/src/tasks/use-mobile-tasks-provider-view-projection.tsx
  • mobile/src/tasks/use-mobile-tasks-task-list-loading.tsx

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

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)
mobile/src/tasks/mobile-task-sort.test.ts (1)

85-88: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert fresh arrays for every short-input path.

Lines 85 and 87 only assert structural equality. An early return of the original array would pass for empty input and singleton repository input. Keep references to these inputs and assert not.toBe for both modes.

Proposed test update
-      expect(sortMobileTaskItems([], 'repository', repos)).toEqual([])
+      const empty: TaskItem[] = []
+      expect(sortMobileTaskItems(empty, 'repository', repos)).toEqual([])
+      expect(sortMobileTaskItems(empty, 'repository', repos)).not.toBe(empty)
       const one = [items[0]]
       expect(sortMobileTaskItems(one, 'repository', repos)).toEqual(one)
+      expect(sortMobileTaskItems(one, 'repository', repos)).not.toBe(one)
       expect(sortMobileTaskItems(one, 'updated', repos)).not.toBe(one)

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 1c8ef62d-1b22-4d79-9459-1dbe86a43fa4

📥 Commits

Reviewing files that changed from the base of the PR and between 1a9a5f9 and 584dc8d.

📒 Files selected for processing (10)
  • config/scripts/mobile-linear-sort-benchmark.mjs
  • config/scripts/mobile-task-sort-benchmark.mjs
  • mobile/src/tasks/mobile-linear-sort.test.ts
  • mobile/src/tasks/mobile-task-sort.test.ts
  • mobile/src/tasks/mobile-tasks-refactor-parity.test.ts
  • mobile/src/tasks/mobile-tasks-repository-presentation.ts
  • mobile/src/tasks/mobile-tasks-reviewer-linear.ts
  • mobile/src/tasks/use-mobile-tasks-picker-projection.tsx
  • mobile/src/tasks/use-mobile-tasks-provider-view-projection.tsx
  • mobile/src/tasks/use-mobile-tasks-task-list-loading.tsx

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

@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

  • Merged the stacked base branch (#20233 unified task sorting) at its tip (71468dd8) and reconciled the mobile-tasks parity fingerprints (EXPECTED_SCREEN_HOOKS/EXPECTED_STATEMENTS/EXPECTED_DECLARATIONS) for the combined source; the semantics/render/style hashes stayed unchanged.
  • Annotated the retained baseline localeCompare oracle in mobile-linear-sort.test.ts with the repo-conventional sort-comparator-performance/no-repeated-collator suppression, resolving the prior review's nit.

Verified on the new head: the focused refactor-parity/linear-sort/task-sort mobile suites pass (18 tests, including the reconciled fingerprints), the changed-code quality gate reports 0 findings across the 6 files, the disable directive is not flagged unused, and the merge preserves the base branch tree exactly (empty diff against nwparker/perf-mobile-task-sort-keys for the base-branch files).

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker changed the base branch from nwparker/perf-mobile-task-sort-keys to main September 13, 2026 01:18
@nwparker
nwparker force-pushed the nwparker/perf-mobile-linear-sort-keys branch from 584dc8d to 0c195c9 Compare September 13, 2026 01:24
@nwparker
nwparker merged commit a045af3 into main Sep 13, 2026
29 checks passed
nwparker added a commit that referenced this pull request Sep 13, 2026
Rebasing onto main surfaced two breakages that the earlier ratchet-only fix
could not have caught, because it was computed against a base main had already
superseded:

- The parity oracle called compareLinearIssues, which #20249 deleted in favour
  of sortLinearIssues. Rewrote the oracle to use sortLinearIssues, matching what
  the production memo now calls, and dropped the stale mock override.
- Regenerated EXPECTED_SCREEN_HOOKS and EXPECTED_STATEMENTS from an observed run
  on the rebased tree. Arity assertions (350 hooks, 417 statements) unchanged.

mobile/src/tasks: 37 files, 295 tests pass.
nwparker added a commit that referenced this pull request Sep 13, 2026
* perf(mobile): reuse Linear grouping between list and board

* test(mobile): realign parity oracle and ratchet with current main

Rebasing onto main surfaced two breakages that the earlier ratchet-only fix
could not have caught, because it was computed against a base main had already
superseded:

- The parity oracle called compareLinearIssues, which #20249 deleted in favour
  of sortLinearIssues. Rewrote the oracle to use sortLinearIssues, matching what
  the production memo now calls, and dropped the stale mock override.
- Regenerated EXPECTED_SCREEN_HOOKS and EXPECTED_STATEMENTS from an observed run
  on the rebased tree. Arity assertions (350 hooks, 417 statements) unchanged.

mobile/src/tasks: 37 files, 295 tests pass.
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