Use more fine-grained lock when persisting shortcuts to disk
Currently we are holding service-level lock whenever a process talks to ShortcutService via any of the public apis, which unnecessarily decreases the overall throughput. At the time ShortcutService was implemented, all shortcuts from various packages were persisted into a single xml file on a write-through basis. This was the main reason a single synchoronization lock was required since two parallel updates might corrupt the xml file. Since that shortcuts from different packages are moved into separate xml files, in this CL we: 1. Only write the shortcuts from individual packages into corresponding xml file after there's a change to the shortcuts in that package, as opposed to writing every shortcuts from every packages under that user into corresponding xml files, which was rather inefficient. 2. The write operation is still scheduled as a background job, but it no longer holds the service-level lock. Instead it would only hold package level lock since it is only writing into the xml from that specific package. Given that file I/O is the most time-consuming task in ShortcutService, refrain from holding service-level lock when performing these type of tasks should help overall system throughput. Bug: 186011943 Test: atest CtsShortcutManagerTestCases Change-Id: I773f4c1d7a39e26030a78ee57f29bf0f33848614
Loading
Please register or sign in to comment