mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 19:08:23 +00:00
heapprofd profiling showed NotificationSubscription.updateFilter()'s ~30s relay-refresh cycle re-running ApplicationDao.getAll on the raw Room dao, re-decrypting every application row through AndroidKeyStore (a keystore2 binder round-trip per encrypted field) forever. That path was the app's dominant native allocator: ~15% of live native memory plus all periodic ~400KB allocation bursts (1.33MB/90s steady-state churn). getAll is now a read-through cache: a second small LruCache keyed by account pubKey, handing out defensive copies. Every application-table mutation evicts the affected account's entry (or all entries when only the app key is known); permission-only writes never do. Call sites that could bypass the wrapper are routed through the cached dao so the cache cannot go stale: updateFilter's read, HistoryDao's updateLastUsed write, and ConnectivityService's reconnect write. Re-profiled post-fix: decrypt-path stacks 0 rows/0 bytes (was 65 rows/ 1.14MB per 90s); steady-state churn ~0.26MB/90s (was ~1.33MB); no periodic bursts.