perf(agent-org): reuse bounded time formatters - #1224
Open
ShiboSheng wants to merge 1 commit into
Open
Conversation
Repeated team and member transitions rebuilt Intl formatters on each render, creating avoidable WebKit allocation churn. Route hot-path time labels through the shared 64-entry cache while preserving locale output. Verification: - pnpm test -- --reporter=dot (1323 files, 10381 tests passed) - pnpm run lint - pnpm run typecheck - pnpm run check:circular (6403 modules) - pnpm run check:test-placement (443 directories) - ORGII_AGENT_ORG_REDESIGN=1 pnpm run tauri:build:fast - Packaged ORG2: 20 Group/Planner cycles and 5-minute hidden idle
ShiboSheng
marked this pull request as ready for review
September 2, 2026 07:09
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.
Problem
Fixes #765
Repeatedly switching between the Agent Org Group projection and individual Member pages rebuilt browser-local
Intl.DateTimeFormat/ ICU formatters during rendering. The Group activity rows, Member turn-page range, Member timing labels, and discussion events bypassed the existing bounded formatter cache, creating avoidable WebKit allocation churn across remounts.The remaining
psRSS increase is not retained dirty memory: macOSfootprintclassifies more than the RSS delta as reclaimable JavaScriptCore pages while physical footprint and dirty WebKit malloc both fall below baseline. This PR fixes the real formatter churn and records both metrics rather than claiming that raw RSS immediately returns pages to the OS.Solution
Add short local-time helpers backed by the existing 64-entry
Intl.DateTimeFormatLRU and route every affected Group/Member hot path through them. The helpers preserve the prior locale inputs and formatting options, including the Member page's 24-hour output.The resulting invariant is: Agent Org render paths must reuse the shared bounded date formatter instead of constructing locale formatters per render. Regression tests cover the Group projection owner and prove that repeated Member page/timing formatting does not call
Date#toLocaleTimeStringor construct additionalIntl.DateTimeFormatinstances.Potential risks
Verification
pnpm exec vitest run --config config/vitest.config.ts src/util/data/formatters/dateLocalDisplay.test.ts src/engines/ChatPanel/ChatHistory/utils/__tests__/turnPageFormatting.test.ts src/engines/ChatPanel/ChatHistory/utils/__tests__/turnTimingFormatting.test.ts src/engines/ChatPanel/ChatHistory/utils/__tests__/turnFormattingIntlCache.test.ts src/engines/ChatPanel/ChatHistory/GroupChatView/__tests__/AgentOrgGroupProjectionView.test.ts— 5 files, 29 tests passed.pnpm test -- --reporter=dot— 1,336 files and 10,516 tests passed.pnpm run typecheck— passed.pnpm run lint— oxlint and ESLint passed with zero errors/warnings.pnpm run check:circular— no circular dependencies across 6,426 modules.pnpm run check:test-placement— passed across 445 directories.ORGII_AGENT_ORG_REDESIGN=1 pnpm run tauri:build:fast— passed; webpack runtime 49121; packagedsrc-tauri/target/dev-build/bundle/macos/ORG2.appin 494.9 seconds.862e7dc7656bb15081e1328b01620662717c581f7c0570da0a75d614d6bbe2d6.Performance evidence
No polling, timer, subscription, worker, persistence, or cache-lifecycle mechanism was added. The hidden process showed no staircase growth after its transition.