Skip to content

perf(web): reuse a collator when sorting changed-file trees - #23776

Merged
Yash-Singh1 merged 1 commit into
pingdotgg:mainfrom
UtkarshUsername:perf/web-changed-file-collator
Oct 23, 2026
Merged

Yash-Singh1 merged 1 commit into
pingdotgg:mainfrom
UtkarshUsername:perf/web-changed-file-collator

Conversation

@UtkarshUsername

Copy link
Copy Markdown
Contributor

Problem

Changed-file cards repeatedly configure locale comparison while sorting file and directory names. Large changed-file lists spend most of their tree-building time in these comparisons.

Change

Create a collator on the first comparison and reuse it. Preserve the default locale, numeric sorting, base sensitivity, and stable ties. Lazy initialization keeps ICU setup off module import.

Scope and approval

Small, focused performance fix for redundant collation setup in the existing tree builder. The separate diff-review sorter already uses this approach (#18420).

Verification

Files Before, ms/build After, ms/build Speedup
10 0.110 0.023 4.8x
200 2.967 0.315 9.4x
1,000 26.373 2.380 11.1x
  • Node 26.12.1 function benchmarks on Windows: five isolated trials per arm, alternating order, two baseline controls per trial. Maximum A/A difference: 20.3%. These measure tree construction, excluding rendering.
  • Tradeoff: sampled JS allocations increased 5.2% at 200 files and decreased 23.8% at 1,000. Profiled GC time per 300 builds fell from 29.6 to 12.1 ms and 220.0 to 33.5 ms, respectively. One collator is retained after use; native ICU memory was not sized. Module import stayed around 1 ms in fresh-process probes.
  • Four focused tests passed, covering numeric ordering, stable case/accent ties, directory compaction, and aggregated statistics. An additional 7,530 differential cases matched the baseline across five explicit locale probes, including path normalization and Unicode names.
  • vp run check:changed upstream/main: passed format, lint, knip, affected-package typechecks, and adjacent tests.

Implemented with GPT-6.1 Sol (high) through 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 22, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 3a23614

Macroscope's review found this PR approvable — This is a small, self-contained performance improvement that reuses a lazily initialized collator for existing changed-file tree sorting. Sorting semantics and existing application paths remain unchanged, with focused tests added for ordering behavior.

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

@coderabbitai

coderabbitai Bot commented Oct 22, 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 4eae8ae and 3a23614.

📒 Files selected for processing: 2
  • apps/web/src/lib/turnDiffTree.test.ts
  • apps/web/src/lib/turnDiffTree.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

Name sorting now reuses a lazily initialized Intl.Collator configured for numeric sorting and base sensitivity. Tests cover directory and file ordering, nested children, and input order for names tied by case- and accent-insensitive comparison.

Changes: Turn diff tree sorting

Layer / File(s) Summary
Cached collator and sorting tests
apps/web/src/lib/turnDiffTree.ts, apps/web/src/lib/turnDiffTree.test.ts
compareByName lazily initializes and reuses an Intl.Collator. Tests check numeric sorting with directories before files, plus input order for tied names at the root and nested-directory levels.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 3a236

This performance-focused change is mergeable with no identified correctness, availability, or data-integrity risk.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main performance change: reusing a collator when sorting changed-file trees.
Description check Passed The description includes all required sections and provides clear problem context, implementation details, scope rationale, focused verification results, benchmark methodology, tradeoffs, and agent at…
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 and provides clear problem context, implementation details, scope rationale, focused verification results, benchmark methodology, tradeoffs, and agent attribution.

✨ 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.

@Yash-Singh1
Yash-Singh1 merged commit 9828cad into pingdotgg:main Oct 23, 2026
29 checks passed
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Oct 23, 2026
## What's Changed
* fix(server): avoid full shell read on resume by @Yash-Singh1 in pingdotgg/t3code#23987
* test: delete low-value tests and dead test-only exports by @t3dotgg in pingdotgg/t3code#24058
* test(server): restore DST scheduling tests deleted in the test snap by @t3dotgg in pingdotgg/t3code#23991
* test(web): restore project settings permission tests deleted in the test snap by @t3dotgg in pingdotgg/t3code#24011
* test(mobile): restore clipboard secret-redaction test deleted in the test snap by @t3dotgg in pingdotgg/t3code#23980
* fix(web): Cmd+B toggles the sidebar unless text is selected by @t3dotgg in pingdotgg/t3code#24063
* fix(server): agent-browser and Chrome no longer outlive the agent that started them by @josephv123 in pingdotgg/t3code#21299
* test(client-runtime): restore render scheduler tests deleted in the test snap by @t3dotgg in pingdotgg/t3code#23977
* fix(web): cmd+k search hides subagents and favors recent, whole-word matches by @t3dotgg in pingdotgg/t3code#24032
* test(lint): new polling loops in tests now fail lint by @t3dotgg in pingdotgg/t3code#23983
* ci: unused dependency patches fail in check:changed, not after push by @t3dotgg in pingdotgg/t3code#23988
* fix(desktop): PDFs in the preview can be annotated by @shivamhwp in pingdotgg/t3code#24022
* fix(web): instructed compact runs without a bare compaction first by @juliusmarminge in pingdotgg/t3code#24008
* fix(desktop): reduce app crashes when a preview tab's renderer dies during agent screenshots by @shivamhwp in pingdotgg/t3code#24056
* fix(server): Stop stops a thread's subagents again by @shivamhwp in pingdotgg/t3code#23886
* fix(desktop): a stuck quit no longer leaves the app unkillable by @shivamhwp in pingdotgg/t3code#23873
* fix(web): keep blockquote text readable in every theme by @Yash-Singh1 in pingdotgg/t3code#24036
* fix(bitbucket): stop the startup sweep from flooding Bitbucket with 429s by @shivamhwp in pingdotgg/t3code#23889
* fix(web): screen readers hear when the open thread starts, needs you or finishes by @shivamhwp in pingdotgg/t3code#23752
* perf(web): reduce allocations in streaming timeline scans by @UtkarshUsername in pingdotgg/t3code#23739
* perf(web): reuse a collator when sorting changed-file trees by @UtkarshUsername in pingdotgg/t3code#23776
* perf(scripts): check:changed finishes in about 10 s by @t3dotgg in pingdotgg/t3code#23581


**Full Changelog**: pingdotgg/t3code@v0.1.3-nightly.20261023.3566...v0.1.3-nightly.20261023.3579

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.1.3-nightly.20261023.3579
@UtkarshUsername
UtkarshUsername deleted the perf/web-changed-file-collator branch October 23, 2026 20:03
Pipyakas pushed a commit to Pipyakas/t3code that referenced this pull request Oct 23, 2026
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.

2 participants