[Launcher Jank] Make ChangeReporter faster
1. Use compare-and-set in ChangeReporter#reportChange() to reduce 1 read access of isAlreadyReported() to mReportedChanges. Also avoided creating a new ChangeReport obj. 2. Make mReportedChanges thread safe by using ConcurrentHashMap<Uid, SynchronizedSet<ChangeReport>> to remove system-wide lock contention of `ChangeReporter#isAlreadyReported()` The pattern of accessing the data structure is that a thread will serially call 2 `isAlreadyReported()` then 1 `markAsReported()` in a row from `ChangeReporter#reportChange()` https://screenshot.googleplex.com/5bhyuaaPXYQLcmq - I have observed concurrent access to different uid from different tid (meaning two different threads accessing different Set<ChangeReport> concurrently) - I have NOT observed concurrent access to same uid from different tid. So there is no probably no need to optimized for concurrent access to `Set<ChangeReport>` and we can use `SynchronizedSet`. Fix: 336364201 Test: presubmit Flag: NONE Change-Id: I1a0524302a58f948c51eef318ba35c4e907d855d
Loading
Please register or sign in to comment