Performance Optimizations for CarrierPrivilegesTracker
-Reduce the memory usage of CPT by only holding the hash of the SHA digests (a hash of hashes) in memory for each package. This also moves away from using hex strings in favor of doing byte-based comparisons, which saves the conversion from byte->ascii for storage and back to byte during the comparison in UiccPrivilegesRule. Memory saving should be... (Old_Size - New_Size) * Num_Phones * Num Packages Old_Size = (SHA1_len + SHA256_len) * Bytes_Per_AsciiHex_Byte - Bytes_Per_Int * 2 = = (20 + 32) * (2 * 2) = 208 bytes New_Size = 2 * Bytes_Per_Int = 16 Num_Packages = ~350 (208 - 16) * 350 * 2 * 1 = 132KB / installed user -This will also speed up searches in the event that there is no carrier package at the slight cost of increasing the lookup cost in the event that there is one or more carrier packages because a full comparison requires a binder call. Because the circumstances that cause a lookup are pretty rare, this feels like a very minimal regression to me. By combining into a single cache that could operate across multiple phones, we could further simplify; however, I believe that would come with additional complexity that is no longer worthwhile given that the total impact should now be only a few KB per instance. Bug: 162182054 Test: atest CarrierPrivilegesTrackerTest; #note: refactor-only Flag: EXEMPT refactor Change-Id: I9e817a2a2853891a1ee56447157db40cb808ab53
Loading
Please register or sign in to comment