perf: optimize Notification Listener via synchronous memory caching#206
Merged
Conversation
- **Data & Persistence**:
- **Memory Caching**: Introduced a `ConcurrentHashMap` memory cache in `AppPreferences` to provide near-instant access to configuration settings without database or DataStore overhead.
- **Reactive Sync**: Implemented `getAllFlow()` in `SettingsDAO` to keep the memory cache automatically synchronized with the underlying Room database.
- **Synchronous Accessors**: Added a suite of synchronous "Sync" getters (e.g., `getGlobalConfigSync`, `getAppIslandConfigSync`) to bypass coroutine suspension for performance-critical operations.
- **Service & Performance**:
- **Notification Processing**: Refactored `NotificationReaderService` to use synchronous preference lookups, eliminating the need for `suspend` modifiers and `.first()` flow collection in the notification processing pipeline.
- **Logic Optimization**: Reordered logic in `onNotificationPosted` to perform the `isAppAllowed` check before launching a coroutine job, reducing unnecessary object allocation.
- **Resource Usage**: Reduced background service overhead and improved battery life by minimizing I/O operations during high-frequency notification events.
- **Localization**:
- **Changelog Updates**: Updated English and Spanish (ES-rES, ES-rEM) resources for v0.5.2, highlighting the background service architecture overhaul and its impact on performance and battery life.
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.
ConcurrentHashMapmemory cache inAppPreferencesto provide near-instant access to configuration settings without database or DataStore overhead.getAllFlow()inSettingsDAOto keep the memory cache automatically synchronized with the underlying Room database.getGlobalConfigSync,getAppIslandConfigSync) to bypass coroutine suspension for performance-critical operations.NotificationReaderServiceto use synchronous preference lookups, eliminating the need forsuspendmodifiers and.first()flow collection in the notification processing pipeline.onNotificationPostedto perform theisAppAllowedcheck before launching a coroutine job, reducing unnecessary object allocation.