Commit 10e9e9a1 by Manh Nguyen Committed by Commit Bot

Apply multiprocessing to capture_replay_tests.py

Multiple tests are run in paralell to squeeze the most out of CPUs. Tests are stored in a work queue. Whenever a CPU becomes available, the next unrun test is grabbed and run on a spawn process on that CPU. Each cpu gets their own environment and build folders and trace folders so that tests don't overwrite each other. Bug: angleproject:4817 Change-Id: Ifd35c9c75522e480b0257d090d5af70f2a3428ba Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2296040 Commit-Queue: Manh Nguyen <nguyenmh@google.com> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 7c79945a
...@@ -165,4 +165,15 @@ as the GLES driver for your application. ...@@ -165,4 +165,15 @@ as the GLES driver for your application.
``` ```
$ autoninja -C out/Release capture_replay_sample $ autoninja -C out/Release capture_replay_sample
$ out/Release/capture_replay_sample $ out/Release/capture_replay_sample
``` ```
\ No newline at end of file
## Testing
### Regression Testing Architecture
The python script uses the job queue pattern. There are n processes running asynchronously and independently, one on each CPU core. Whenever a process (except for the main process) finishes a job and becomes available, it grabs the next job from a shared job queue and runs that job on its CPU core. They keep doing this until there is no more job in the shared job queue. The main process, after filling up the shared job queue and spawning the (n-1) subprocesses that run on the remaining (n-1) CPU cores, waits until all the subprocesses are finished. It then reports the results and cleans up.
![Point-in-time snapshot of the job queue](https://screenshot.googleplex.com/w2QY5ui5FMg.png)
### Job unit
A job unit is a test batch. Each test has to go through 3 stages: capture run, replay build, and replay run. The test batch batches the replay build stage of multiple tests together, and the replay run stage of multiple tests together.
![A test batch as a job unit](https://screenshot.googleplex.com/A4w8ogsnfLw.png)
...@@ -9,6 +9,9 @@ declare_args() { ...@@ -9,6 +9,9 @@ declare_args() {
# Decide which context to replay, starting with desktop default # Decide which context to replay, starting with desktop default
angle_capture_replay_test_context_id = 1 angle_capture_replay_test_context_id = 1
#Set the trace directory. Default is traces
angle_capture_replay_test_trace_dir = "traces"
} }
if (angle_build_capture_replay_tests) { if (angle_build_capture_replay_tests) {
...@@ -17,15 +20,17 @@ if (angle_build_capture_replay_tests) { ...@@ -17,15 +20,17 @@ if (angle_build_capture_replay_tests) {
angle_executable("capture_replay_tests") { angle_executable("capture_replay_tests") {
testonly = true testonly = true
_contextid = angle_capture_replay_test_context_id _contextid = angle_capture_replay_test_context_id
_trace_folder_relative_path = "./" + angle_capture_replay_test_trace_dir
_trace_sources = _trace_sources =
read_file("traces/angle_capture_context${_contextid}_files.txt", read_file(_trace_folder_relative_path +
"/angle_capture_context${_contextid}_files.txt",
"list lines") + "list lines") +
[ [
"angle_capture_context${_contextid}.cpp", "angle_capture_context${_contextid}.cpp",
"angle_capture_context${_contextid}.h", "angle_capture_context${_contextid}.h",
] ]
sources = sources = rebase_path(_trace_sources, ".", _trace_folder_relative_path) +
rebase_path(_trace_sources, ".", "traces") + [ "CaptureReplayTest.cpp" ] [ "CaptureReplayTest.cpp" ]
deps = [ deps = [
"$angle_root:angle_common", "$angle_root:angle_common",
"$angle_root:angle_compression", "$angle_root:angle_compression",
...@@ -44,11 +49,11 @@ if (angle_build_capture_replay_tests) { ...@@ -44,11 +49,11 @@ if (angle_build_capture_replay_tests) {
suppressed_configs += [ "//build/config/compiler:default_optimization" ] suppressed_configs += [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:no_optimize" ] configs += [ "//build/config/compiler:no_optimize" ]
} }
_data_path = rebase_path("traces", root_out_dir) _data_path = rebase_path(_trace_folder_relative_path, root_out_dir)
defines = [ defines = [
"ANGLE_CAPTURE_REPLAY_TEST_DATA_DIR=\"${_data_path}\"", "ANGLE_CAPTURE_REPLAY_TEST_DATA_DIR=\"${_data_path}\"",
"ANGLE_CAPTURE_REPLAY_TEST_CONTEXT_ID=${_contextid}", "ANGLE_CAPTURE_REPLAY_TEST_CONTEXT_ID=${_contextid}",
"ANGLE_CAPTURE_REPLAY_TEST_HEADER=traces/angle_capture_context${_contextid}.h", "ANGLE_CAPTURE_REPLAY_TEST_HEADER=" + "${angle_capture_replay_test_trace_dir}/angle_capture_context${_contextid}.h",
] ]
} }
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment