Repository navigation
fix: stop decoding saved JSON on every one-second tick - #1103
Merged
1 commit merged intoNov 9, 2026
Merged
1 commit merged into
1 commit merged into
Conversation
The account views tick every second and each tick reloaded and decoded the shared-account cache, building a new ISO 8601 formatter for every saved date. Build the shared presentation document once per model change or minute, and reuse three formatters. Client-impact: visible
Contributor
Author
|
Ready for the merge train Head: 733a14c |
Contributor
Author
|
Launchplane completed the merge-train step for this pull request.
Launchplane landed this pull request through protected batch PR #1104. Launchplane manages this comment and will update it as the train moves. |
shiny-code-app Bot
added a commit
that referenced
this pull request
Nov 9, 2026
…-d5ab7e865a0f804f: merge PR #1103
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.
Why
Clicks to change pages or expand sections took about a second on 1.0.80. The account pages tick every second, and every tick read the shared-account cache from disk and decoded it on the main thread. Each saved date in it also built new ISO 8601 formatters.
Hot path
Symbolicated with
atosagainst the shipped 1.0.80 binary from Ship run 42538090475. Its local symbol table is intact, so offsets from the user'ssampleresolve directly:TimelineView(.periodic(by: 1))content closureclosure #1 in AccountDashboard.body.getter(0x608e8)ContextPanelAppModel.accountPresentation(at:)(0x61288)SnapshotRefreshService.sharedAccountPresentation(...)(0x41a8a8;presentationDocumentinlined)MacSharedAccountCache.load(now:)(0x315440)MacSharedAccountCache.Payload.init(from:), thenCompanionSyncDocument.init(from:), thenUseNextEvidence.init(from:)decoding thelaunchesmapJSONDecoder.contextPanelISO8601date closure, thenContextPanelDateFormatting.date(from:), which allocated up to threeISO8601DateFormatters per dateThe user's cache file is 47 KB with 564 dates. 26 KB of it is launch evidence.
Regression
The per-access rebuild has existed since 1.0.76. 1.0.80 made it expensive: a749ad9 added
launchEvidencetoCompanionSyncDocument, so the cache read on every tick now carries hundreds of launch dates.What changed
SnapshotRefreshService.sharedAccountPresentationbecomessharedPresentationDocument. It returns the document so the caller can reuse it.ContextPanelDateFormattingreuses three formatters instead of building new ones per call.Measurements
Same Mac, same data.
top1 s samplesJSONDecoder.decodesample) and 41.2% (713 of 1729, earlier 3 s sample)currentSnapshotreadThe after CPU figure for the running app needs this build installed. The benchmark ran against a private copy of the cache file, outside the app's data folders.
Verification
swift buildswift test --filter ContextPanelCoreTests: 1363 tests pass.accountPresentationReusesSavedFilesUntilTheModelChangesOrAMinutePasses. It fails if a tick rereads saved files, and fails if a model reload does not pick up new files. Checked by forcing a rebuild on every access: the test fails.Closes #1098
Removed: an
ISO8601DateFormatterallocation per decoded date; disk reads and JSON decoding on each 1 s tick and eachcurrentSnapshotread.Net lines: +47 (+10 source, +37 test).