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
Loading
Please register or sign in to comment