Trace perf: clear blob cache before each test

Cache eviction can happen during warmup causing cache misses
while testing. Significant cycles are being spent evicting cache entries
and throwing off power measurement. Since this is already a synthetic
environment where we're lumping in a bunch of caches together,
clear it between tests so that warmup correctly populates
and no cache misses occur within the test run.

If we clear the cache before warmup and everything fits, no eviction
happens and we hit the cache every time post-warmup. This also improves
reproducibility of perf results as they no longer depend on the
specific cache state before running a particular test, the order in
which tests are run etc.

Also fixes acessing unset var when running without --power.

Bug: b/298028816
Change-Id: I704073f70d8859e19a78b23d397e68f5836f3bb2
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4834073
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Commit-Queue: Roman Lavrov <romanl@google.com>
This commit is contained in:
Roman Lavrov
2023-08-31 15:35:39 -04:00
committed by Angle LUCI CQ
parent 9666d4d5f7
commit dcd62fc41c

View File

@@ -113,6 +113,11 @@ def cleanup():
run_adb_command('shell rm -f /sdcard/Download/out.txt /sdcard/Download/gpumem.txt')
def clear_blob_cache():
run_adb_command(
'shell run-as com.android.angle.test rm -rf /data/user_de/0/com.android.angle.test/cache')
def select_device(device_arg):
# The output from 'adb devices' always includes a header and a new line at the end.
result_dev = run_command('adb devices')
@@ -730,6 +735,8 @@ def run_traces(args):
for trace in fnmatch.filter(traces, args.filter):
# Remove any previous perf results
cleanup()
# Clear blob cache to avoid post-warmup cache eviction b/298028816
clear_blob_cache()
test = trace.split(' ')[0]
@@ -747,12 +754,12 @@ def run_traces(args):
logging.debug('Running %s' % test)
test_time = run_trace(test, args)
gpu_power, cpu_power = 0, 0
if args.power:
done_event.set()
power_thread.join(timeout=2)
if power_thread.is_alive():
logging.warning('collect_power thread did not terminate')
gpu_power, cpu_power = 0, 0
else:
gpu_power = power_results['gpu']
cpu_power = power_results['cpu']