Page MenuHome

Tests: run suites instead of individual test cases
ClosedPublic

Authored by Sybren A. Stüvel (sybren) on Nov 26 2020, 1:07 PM.

Details

Summary

Group all tests of a test suite into a single test command invocation.
This reduces the number of invocations by ctest by an order of
magnitude.

Since rB56aa5b0d8c6b663, bin/tests/blender_test was run for every
individual test. Having over a 1000 tests made testing slower than
necessary. Individual tests can still be run if desired by invocation of
bin/tests/blender_test --gtest_filter=suitename.testname.

NOTE: For this commit to have an immediate effect, it may be necessary to remove the tests and Testing directories and some CMake files from your build directory and rebuild. Run ctest -N to see the list of tests; there should be less than 200.

On my machine (Ubuntu 20.04, Intel i7-4790K, 32 GB RAM) test execution
time was dominated by the actual test execution and no measurable
performance was gained. However, this may be different on other systems
& platforms.

Diff Detail

Repository
rB Blender

Event Timeline

Sybren A. Stüvel (sybren) requested review of this revision.Nov 26 2020, 1:07 PM

This seems to be a nicer improvement already!

Is it possible to group based on source file, to make behavior closer to as if there was not uber-binary approach? The reason for this is because foo_test.cc might define different fixture names which are testing effectively different aspects of the same underlying codepaths (as in, they make up for code coverage, but might be different fixtures for various reasons).

Actually. Maybe it's possible to make blender_add_test_executable to not "surgeon" on the tests suits at all, and for blender_add_test_lib use the logic you did here?

The GTest discovery works by actually running blender_tests --gtest_list_tests and parsing the output. This is of course only possible after it's been built, which means that we have no info any more as to which module the tests belonged to.

I can modify gtest_add_tests, which tries to run some regexps on the source code in order to find tests. This is a bigger change, because at the time of calling gtest_add_tests there must already be a CMake target defined for the test executable. This means that we have to reorder the root CMakeLists.txt to define the test runner first, and then the rest of Blender. I did this locally as a quick test, and it seems to work well.

Run test executable once for each source module. Tests are now no longer found by running the test binary, but by regexping the source. This reduces the number of test executable invocations further, but may hurt parallelism because all tests in a single module are now run serially.

Just a quick N=1 test reduced the running time of tests from 192.5 sec (master) to 184.4 sec (this patch).

Ray Molenkamp (LazyDodo) requested changes to this revision.EditedNov 27 2020, 9:13 PM

This breaks a few things on windows, unsure what yet, just requesting changes so it doesn't land, will take a look later

edit: got it, working directory is set to the tests folder, resulting in the depended dll's not being found making the process unable to start.

This revision now requires changes to proceed.Nov 27 2020, 9:13 PM

I keep forgetting to mention.
On macOS there is some very measurable overhead when ctest is running a lot of binaries. Not sure details of why is it so, but less invocations ctest does is better here.

As for the issue Ray mentioned, is almost as if it's more efficient if Ray gives a hint of whet to modify or even provides a patch? Unless there is an easy way to check changes on Linux.

Properly set working directory & test install directory. This fixes things on Windows too.

After this patch, the test code needs to be cleaned up & clarified, as it's turning into a nice moist ball of spaghetti: T83222: Clean up CMake scripts for automated tests.

Ray Molenkamp (LazyDodo) accepted this revision.EditedNov 30 2020, 3:56 PM

@Sybren A. Stüvel (sybren) luckily was able to decipher my cryptic "THE WORKING DIRECTORY IS WRONG" clue, so I guess that still worked out, I'll try to find a way to be more specific with my hints in the future when I lack the time to go fix it my self, although it is still unclear what I could have done differently in this occasion.

on a more serious note, ctest -C Release -E cycles (excluded cycles since it "takes a bit" and won't be helped much by this diff)

before145s
after97s

well done!

This revision is now accepted and ready to land.Nov 30 2020, 3:56 PM

Rebased on top of master

On Linux - Pop!_OS 20.04 LTS - AMD Ryzen 9 - 24 logical cores

Before patch

step            elapsed
----            -------
update-code     00:00:03.3398348
compile-code    00:03:50.3780962
test-code-unit  00:02:49.4274320
test-code-smoke 00:00:05.8998064

After patch

step            elapsed
----            -------
clean-code      00:00:00.0112528
compile-code    00:02:44.5886884
test-code-unit  00:01:59.2731646
test-code-smoke 00:00:05.8164091

Although I like the test-code-unit numbers, there is also a similar difference in compile-code time. This may indicate that there was something else going on in the system, as my patch shouldn't cause that difference in compile time.

at 2-3 minutes each perhaps those were an incremental builds?

Yes, incremental build with partial clean (test artifacts only).

The code builds times are only relevant with full clean builds.
However, they are good to track incrementally also, especially if hitting the same builder for each commit.

As a note, the build bot scripts only deletes the install folder and not the build and the test artifacts on the machines.
I do this in the new pipeline in my first step before calling the build bot python scripts.

I normally like to ensure forced full clean builds and then skip it when needed.

On Windows - 10 Pro 1909 - Intel i7 @ 2.3Ghz - 16 logical cores

Before Patch

step             elapsed
----             -------
clean-code       00:00:00.0428429
update-code      00:01:56.6479339
compile-code     00:43:58.8301665
test-code-unit   00:06:30.4856439
test-code-smoke  00:00:09.4788121
package-binaries 00:01:06.3493870

After Patch

step           elapsed
----           -------
clean-code     00:00:00.0004629
update-code    00:00:05.2854835
patch-code     00:00:09.4928776
compile-code   00:05:26.2016864
test-code-unit 00:06:12.8964456

After patch, 1 test failed, did not continue the pipeline
Will run the tests again, without patch from master.
But pretty sure it's svn not on the correct commit vs git commit.
High compile time on windows is casued by CUDA building.

============================
Pipeline Summary
============================
Git Branch: arcpatch-D9649
CPU Model: AMD Ryzen 9 3900X 12-Core Processor
Chassis: desktop
Operating System: Pop!_OS 20.04 LTS
Kernel: Linux 5.8.0-7630-generic
Architecture: x86-64
CPU Model: AMD Ryzen 9 3900X 12-Core Processor
Logical Cores: 24

step            elapsed          exitCode success
----            -------          -------- -------
clean-code      00:00:00.0009560        0    True
update-code     00:00:03.5517703        0    True
patch-code      00:00:13.1443268        0    True
compile-code    00:02:32.1432754        0    True
test-code-unit  00:02:43.1305550        0    True
test-code-smoke 00:00:00.0078440        0    True
============================
Pipeline Summary
============================
Git Branch: arcpatch-D9649
Git Commit: da901bc3538b3410221295f87cfef4c0681ca001
Git Parent Commit: c51a70537b12946bd8e7e66d29ef438a41a8801a
OS Detail: Microsoft Windows 10.0.18363
CPU Model: Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
Logical Cores:  16

step            elapsed          exitCode success
----            -------          -------- -------
clean-code      00:00:00.0009387        0    True
update-code     00:00:06.5730612        0    True
patch-code      00:00:15.8339076        0    True
compile-code    00:06:14.4399478        0    True
test-code-unit  00:05:43.7124562        0    True
test-code-smoke 00:00:07.5167016        0    True

To me clarity of output is less important than the speedup :)

@Sebastián Barschkis (sebbas) could you give this a quick test on macOS to see if it breaks anything?

Ok, so with the patch applied the modifiers and physics_cloth tests are failing for me on macOS. Will investigate.

it's a pretty old patch, you may just need to merge master if you applied the patch with arc.

@Ray Molenkamp (LazyDodo) Right, that is true and did the trick. Thanks for the heads up!