Repository navigation
Conversation
7 of 20 tasks
|
0xbrayo
force-pushed
the
perf/session-ingest-single-pass
branch
from
October 8, 2026 19:37
4733dab to
fcfc7a4
Compare
Each run made a PackageManager binder call per session for the app label, iterated queryEvents twice (once for sessions, once for unlocks) allocating an Event per entry, and listed every bucket twice to ensure two buckets exist. Cache labels per run, read sessions and unlocks in one pass reusing a single Event, and ensure both buckets with one listing.
0xbrayo
force-pushed
the
perf/session-ingest-single-pass
branch
from
October 11, 2026 13:13
fcfc7a4 to
662fe5d
Compare
Member
Author
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.
Part of #333.
Session ingest runs hourly, on every app open and on widget refresh, and the first run after install covers all of the usage history Android retains. Each run did avoidable work:
SessionUtils.getAppName(aPackageManagerbinder call) ran once per session, even though most sessions belong to a handful of apps.queryEventswas called and fully iterated twice, once for sessions and once for unlocks, allocating a newUsageEvents.Eventper entry.createBucketHelperserializes every bucket viagetBuckets()to check whether one exists, and ran twice per run.Change
parseEventsIntoSessionscaches app labels for the duration of the run.SessionParser.parseSessionsAndUnlocksSince(sessionsSince, unlocksSince)reads sessions and unlocks in one pass, reusing a singleEvent. It takes separate lower bounds so it composes with fix(watcher): resume unlock ingest from the unlock bucket's last event #335, which gives unlocks their own cursor. The now-unusedparseUsageEventsSinceandparseUnlockEventsSinceare removed.RustInterface.createBucketsHelper(map)ensures several buckets with one listing.createBucketHelperdelegates to it.Notes
Testing
./gradlew :mobile:testStandardDebugUnitTestpasses.UsageStatsManagerand the native library, so this has no new unit test.