diff options
| author | 2024-04-22 21:18:44 +0000 | |
|---|---|---|
| committer | 2024-04-24 21:43:08 +0000 | |
| commit | d42bd3f0038d34ea4612bc203f746b42752172be (patch) | |
| tree | a0310f295f9a14d960de7bca4a5f5a1c8ffbbfa3 /libs/androidfw/StringPool.cpp | |
| parent | 39af13d259f332be04997df078287894cde4416d (diff) | |
[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
Diffstat (limited to 'libs/androidfw/StringPool.cpp')
0 files changed, 0 insertions, 0 deletions