perf: defer + cache cross-package index resolution off the first frame#5
Merged
Conversation
…path - Pre-warm the GoogleSans device font (`warmUpGoogleSans`, dispatched from `Application.onCreate`) so the first text layout doesn't pay the `DeviceFontFamilyName` lookup during the heavy post-first-frame composition (which otherwise queues `WINDOW_FOCUS_CHANGED` and delays the IME). - `BootReceiver` self-skips on the `.benchmark` applicationId: macrobenchmark's StartupMode.COLD re-delivers BOOT_COMPLETED every iteration, which would run AppIndex.refresh (phase B) during the first frame and contaminate TTID. - Regenerate the baseline profile; record the clean benchmark results and update AGENTS.md, ADR-0008/0009 and docs/performance-analysis.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
AppIndex,ShortcutIndex,SettingsPageIndex) resolved other packages' labels/resources viaPackageManagerfromApplication.onCreate, contending with the first-frame composition on ART locks (ResourcesManager#getResourceswas the soleslow_start_reason). That work now runs fromMainActivityafter the first content draw, via aViewTreeObserver.OnDrawListener+decorView.post(aChoreographervsync count fired off-by-one — see ADR-0009).ShortcutIndex+SettingsPageIndexnow persist their entries (*IndexCacheRepository), likeAppIndex. Cold start hydrates (phase A) before the first frame with zerogetResources, so typed results and the blank-state recents render immediately — this fixes recent shortcuts/settings popping in late (they stale-filter against the live index; see ADR-0008).warmUpGoogleSans) so the first text layout doesn't pay theDeviceFontFamilyNamelookup during the heavy post-first-frame composition (which queuesWINDOW_FOCUS_CHANGEDand delays the IME).BootReceiverself-skips on the.benchmarkbuild — macrobenchmark'sStartupMode.COLDre-deliversBOOT_COMPLETEDevery iteration, which otherwise ranAppIndex.refreshduring the first frame and inflated TTID uniformly.time_get_resources376 → 111 ms, no-AOT cold-start floor 240.7 → 178.5 ms;Baseline ≈ None(~177 ms) — the path is now light enough that AOT barely matters. Docs updated (AGENTS.md, ADR-0008/0009,docs/performance-analysis.md).Test plan
./gradlew compileDebugKotlin./gradlew :benchmark:connectedBenchmarkReleaseAndroidTest— clean run, noBOOT_COMPLETED/phaseB.enumeratebefore TTID🤖 Generated with Claude Code