Reuse a same buffer per session instead of reallocating each time.
Previously, a fixed size buffer was allocated each time a call to `computeSha256DigestForLargeFile` was made. This causes undesirable performance issues. This change allocates a buffer per apex/module-update session instead. To fix this, that method is amended to take in a buffer passed in by the caller instead. To aid in the usage of this API, a new method called `createLargeFileBuffer` is introduced to help callers allocate a pre-determined buffer size to be passed into the SHA computation method based on whether the device is low RAM device or not. Subsequent RSS benchmarking shows that this helps to significantly lower the RSS high watermark (HWM) for the `system_server` process into just noise. Bug: 229137737 Test: Manual Change-Id: I6d2d17353f999bd6cfb937cd5ae6e6925f1353ac
Loading
Please register or sign in to comment