time_in_state: change map format to improve read performance
BPF map formats must be defined at compile time, and the uid_times_map
must be able to accommodate the full range of frequencies available on
a device, but information about the number of available frequencies is
not available at compile time.
The current map format addresses this by using a separate map entry
for every uid-frequency combination that has occurred, but this
results in significant overhead since fetching stats for a single UID
can require dozens of bpf() syscalls.
Instead, define a map where each value holds times for 32
frequencies. This preserves flexibility (devices with more than 32
frequencies per cluster will simply have 2 or more key-value pairs per
UID) while drastically reducing the number of lookups required to
fetch all data for a UID.
Test: libtimeinstate_test passes
Bug: 138317993
Change-Id: I4b4f74ae52bad820f1b9b63212e2d702af97a49f
Signed-off-by: Connor O'Brien <connoro@google.com>
(cherry picked from commit a00b83c46147e15658808245c000baffd439ae78)
Merged-In: I4b4f74ae52bad820f1b9b63212e2d702af97a49f
1 file changed