Repository navigation
[Perf-LH] Reuse renderer locale collators - #13444
Merged
Merged
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThe change adds cached locale-text comparators for numeric and base-sensitivity ordering. Renderer sorting paths now use these shared comparators for issue identifiers, skills, and palette results. Tests verify ordering parity and lazy collator initialization. A benchmark measures sorting performance across deterministic numeric and text datasets. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes seven renderer sort expressions reuse the expensive locale-collation setup they currently repeat for every comparison.
In plain language: several Orca lists need “human” ordering, such as putting
TASK-2beforeTASK-10or comparing names without case/accent sensitivity. Today those callString.localeComparewith an options object from inside the sort callback. A sort invokes that callback roughlyn log ntimes, and each option-bearing call resolves the same ICU collation configuration again.The affected paths are:
What changes
A small renderer module now owns two exact comparison modes:
undefined,sensitivity: 'base'undefined,numeric: trueEach comparator initializes its
Intl.Collatoronly when that comparison mode is first used, then reuses it for every later comparison.The lazy initialization is important. Constructing the first ICU collator can itself take several milliseconds in a fresh renderer process. Eager module-level construction would move that cost into module loading even when the user never opens one of these sorted surfaces. This implementation keeps the old “pay only on first use” behavior and removes only repeated setup.
The following intentionally remain unchanged:
undefined, so each platform keeps using the same runtime-default locale it used before;localeComparefallback still breaks equal-name ties;fileNameCollatoris not reused because it pins locale toenand adds a code-unit tie-breaker;Benchmark
Run:
node config/scripts/locale-collator-sort-benchmark.mjsThe committed harness:
sortJiraIssuesproduction function for the numeric arm;Results from Node 24.18 on the same machine:
localeCompareWhy these sizes:
This is a large comparator-level improvement but a modest common-case end-to-end improvement: normal 36–50-row sorts save roughly 0.2–0.35 ms. Palette impact depends on how often earlier score/context fields already decide ordering, and numeric issue sorting is user-selected rather than the default updated-time order. The PR does not claim that the complete UI interaction becomes 13–26× faster.
Screenshots
No visual change. Ordering is deliberately unchanged.
Testing
pnpm lint— full repository lint was not run; targetedoxlintpassed andpnpm run check:code-quality:changedreported 0 new standard, type-aware, or React Doctor findings across all 9 changed files.pnpm typecheck— the affected renderer target passed withpnpm run typecheck:web; Node and CLI targets are untouched.pnpm test— the full repository suite was not run; 110 focused tests passed across 8 affected palette, Jira, native-chat, open-tab, and comparator test files.pnpm build— not run; no bundler configuration, dependency, native module, or packaging behavior changed.Additional checks:
localeCompareexpressions;pnpm run check:max-lines-ratchetpassed with no new bypasses;git diff --checkpassed;AI Review Report
The review traced all seven production expressions and verified their exact locale, options, fallback ordering, call frequency, and surrounding sort behavior.
The first implementation eagerly constructed two collators at module load. Review identified that this could shift approximately 5 ms of first-ICU initialization into renderer startup. The implementation was changed to lazy comparator functions, and a regression test now proves both “no construction on import” and “one construction per comparison mode.”
Review also checked:
TASK-2versusTASK-02;The final independent review found no high- or medium-severity issues. Its benchmark-order concern was addressed by interleaving measurement arms, and its base-mode reuse concern was addressed by exercising that comparator twice in the laziness test.
Security Audit
This change performs no I/O and introduces no new authority boundary.
No security follow-up is required.
Notes