Skip to content

perf(ios): cache ISO-8601 parsers instead of allocating per call#3457

Merged
BunsDev merged 1 commit into
mainfrom
cody/perf-iso-formatter-cache
Jul 19, 2026
Merged

perf(ios): cache ISO-8601 parsers instead of allocating per call#3457
BunsDev merged 1 commit into
mainfrom
cody/perf-iso-formatter-cache

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

Fourth PR in the iOS performance pass. Cuts avoidable allocations in list scrolling/sorting.

Root cause

caveParseISO() allocated up to two ISO8601DateFormatter instances on every call, and it's called per item inside sorted/filter/map across the tasks, calendar, reminders, and thread lists (e.g. FamiliarThreadsView sort comparator, CalendarView grouping). ISO8601DateFormatter is comparatively expensive to construct, so this was avoidable churn during scroll and re-sort.

Fix

Hoist the two formatters (fractional + plain) to shared, lazily-initialized module-level instances and reuse them. ISO8601DateFormatter is thread-safe for reads; parsing behavior is identical (try fractional, then plain).

Verification

  • xcodebuild build (scheme CovenCave, iOS Simulator) → BUILD SUCCEEDED.

Blast radius

Tiny — 1 file, pure internal caching. Same inputs/outputs.

Notes

Part of the perf series (#3454 chat render, #3455 stream coalescing, #3456 persist debounce). CI does not build the Swift app; local xcodebuild is the iOS gate.

caveParseISO() allocated up to two ISO8601DateFormatter instances on every
call, and it's invoked per item inside sort/filter/map across the tasks,
calendar, reminders and thread lists. ISO8601DateFormatter is comparatively
expensive to construct, so this added avoidable churn while scrolling and
re-sorting those lists.

Hoist the two formatters (fractional + plain) to shared, lazily-initialized
instances and reuse them. ISO8601DateFormatter is thread-safe for reads, and
behaviour is identical (try fractional, then plain).

Verified: xcodebuild build (scheme CovenCave, iOS Simulator) succeeds.
Copilot AI review requested due to automatic review settings July 18, 2026 22:59

Copilot AI 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.

Pull request overview

This PR improves iOS list scrolling/sorting performance by avoiding repeated ISO8601DateFormatter allocations during ISO-8601 parsing, which is used heavily in per-item sort/filter/map paths across multiple list views.

Changes:

  • Hoists two ISO8601DateFormatter instances (fractional + plain) into shared cached instances.
  • Updates caveParseISO(_:) to reuse the cached formatters instead of allocating new ones per call.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@romgenie

Copy link
Copy Markdown
Member

Verification complete

Reviewed the exact head 21f25a1fafe2916db1109ab6934d47990d108cc8. The cached formatters preserve the existing fractional-then-plain fallback order; no actionable defects or review threads were found, and current main is an ancestor of the PR head (no conflict). No follow-up commit was needed.

Validation:

  • git diff --check origin/main...HEAD
  • pnpm check:tests-wired — 1,072 test files wired
  • Exact-head GitHub CI is green, including Frontend build (typecheck, app/API/mobile tests, production build), E2E (104 passed, 2 skipped), Rust, cross-environment, Linux/Windows sidecar runtime, CodeQL, and the required aggregate checks.

The local WSL worktree does not provide Xcode; the PR author's recorded iOS Simulator xcodebuild result remains the native iOS build evidence. The branch is MERGEABLE / CLEAN and ready for maintainer review.

@BunsDev
BunsDev merged commit ef5b1ef into main Jul 19, 2026
16 checks passed
@BunsDev
BunsDev deleted the cody/perf-iso-formatter-cache branch July 19, 2026 14:11
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.

3 participants