summaryrefslogtreecommitdiff
path: root/api/api_test.go
diff options
context:
space:
mode:
author Junyu Lai <junyulai@google.com> 2023-07-25 13:48:26 +0800
committer Junyu Lai <junyulai@google.com> 2023-07-28 16:28:31 +0800
commit425ec7a92099817e0791dc26afca0f005efa8763 (patch)
tree5326ed48d0719d61375210261b8dad8ed4ed2961 /api/api_test.go
parent5c4b87083d38eed207406e9cee765752c0386dd8 (diff)
Read files in increasing timestamp order in FileRotator
The current design of the readMatching() function reads all files that match a given prefix, but does not guarantee the order in which they are read. This could cause performance problems because the caller is optimized for inserting files in ascending timestamp order but the files are read in a reversed order. This change sorts the list by the timestamp in the file name, which is more natural since the files are written based on timestamp. Benchmarking result shows that testReadFromRecorder_manyUids improved from 1.5s to 1.0s compares to the worst case. Also, this is safe because all callers of the readMatching() function only pass a list of less than 20 files. None of these callers rely on the order in which the files are read. Test: atest ConnectivityBenchmarkTests FileRotatorTest Bug: 269409485 Change-Id: I73f10890e8f454ee98e7d92fa754d1affe598df4
Diffstat (limited to 'api/api_test.go')
0 files changed, 0 insertions, 0 deletions