Skip to content

perf(automations): reuse collation setup when sorting names - #18823

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-automation-name-sort
Sep 5, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-automation-name-sort

Conversation

@nwparker

@nwparker nwparker commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​91 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​91
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​58 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39

Automation-name sorting resolved collation options for every comparison. Reuse one Intl.Collator per name sort, using the current UI locale each time. Preserve direction, ID tie-breaks, input row identities and input immutability; unsorted, time-sorted and trivial lists avoid collation setup.

Found by the source audit in #18822. This PR is independently based on main. It extends the existing locale-sort benchmark to call the production automation sorter, enables JSX for its real import graph, and uses six counterbalanced rounds with an even-sample median.

Measured on macOS arm64 / Node 24.18.0 (milliseconds per sort):

Rows Previous Candidate
10 0.039 0.004
100 0.952 0.040
1,000 14.603 0.628

The 1,000-row case is a scaling fixture, not a measured user inventory. These are sorter timings, not end-to-end UI latency. Both benchmark arms assert identical output; there is no hardware-dependent timing gate.

Validation: 16 tests across the existing list-view suite and six new regressions; the operation-count test fails on the original implementation. Differential checks cover English, Swedish, Turkish and Japanese, both directions and ties; the count oracle verifies one constructor per sort and zero optioned localeCompare calls. pnpm tc:web, changed-code quality and formatting passed. Run node config/scripts/locale-collator-sort-benchmark.mjs to reproduce. Sorting remains client-side for local and external automation rows; no wire, host-execution, Git-provider or workspace identity changes.

@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

  • Collator reuse in sortAutomationListViewItems — replaces per-comparison localeCompare(…, { sensitivity: 'base' }) with a single new Intl.Collator(getIntlLocale(), { sensitivity: 'base' }) constructed once per name sort; direction inversion, ID tie-break, and input immutability are unchanged.
  • New regression tests — a differential oracle reimplements the old comparator across en/sv/tr/ja and both directions, plus a count oracle proving one collator construction per sort and zero optioned localeCompare calls, plus coverage for unsorted/time-sorted/trivial lists.
  • Benchmark extension — adds an automation arm calling the production sorter, enables jiti jsx, and moves to six counterbalanced rounds with an even-sample median.

The change is semantically equivalent to the prior implementation: sensitivity: 'base' with default usage: 'sort' behaves identically between String.prototype.localeCompare and Intl.Collator, and extracting .compare is safe because Intl.Collator.prototype.compare returns a bound function. The items.length < 2 early return changes nothing observable (a ≤1-element list is already sorted). Tests are meaningful and can fail against a regression. No behavioral surface beyond the intended perf win.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 66b20a4b-96c0-4a41-82cb-e9223e80f6bd

📥 Commits

Reviewing files that changed from the base of the PR and between a823f97 and dd96f7f.

📒 Files selected for processing (3)
  • config/scripts/locale-collator-sort-benchmark.mjs
  • src/renderer/src/components/automations/automation-list-view-sort.test.ts
  • src/renderer/src/components/automations/automation-list-view.ts

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


📝 Walkthrough

Walkthrough

The automation list sorter now returns copied results for unsorted and short lists. Name sorting uses Intl.Collator with the active locale and base sensitivity. Tests cover locale-specific ordering, stable tie-breaking, array identity, mutation, and collator usage. The benchmark now runs six counterbalanced rounds, computes the median from the two middle samples, and compares manual sorting with the production sorter across three list sizes.

Merge Risk: ⚪ Minimal · up to dd96f

Automation name sorting now reuses locale-aware collation setup while preserving ordering, tie-breaks, and input behavior. The change is ready to merge with no current-head risk identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the implementation, motivation, benchmark results, testing, and linked issue context. However, it does not follow the required template and omits the required Visual Proof sec… Update the description to include all template sections. Add visual proof or write exactly N/A with a reason if there is no visual or interaction change. Complete the Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, a…
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 8 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main performance change: reusing collation setup during automation name sorting.
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 explains the implementation, motivation, benchmark results, testing, and linked issue context. However, it does not follow the required template and omits the required Visual Proof section or an explicit N/A explanation, testing checkboxes, AI Disclosure, Review, boundary confirmation, Notes, and Checklist.

Resolution

Update the description to include all template sections. Add visual proof or write exactly N/A with a reason if there is no visual or interaction change. Complete the Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections.

  • Fix all pre-merge checks with AI
✨ 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.

@nwparker
nwparker merged commit 9c3d957 into main Sep 5, 2026
29 checks passed
@nwparker
nwparker deleted the nwparker/perf-automation-name-sort branch September 5, 2026 20:19
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