[feat] Optimise the test case generation #2544
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR optimises the
generate_testcases()
function by eliminating the deep copies completely. This has been one of the major contributing factors in increased load times for large number of tests (at the order of thousands). The execution time overhead of thegenerate_testcases()
has been practically eliminated (from 6.09s to generate 10000 test cases out theHelloTest
to 0.1156s on my Mac – 2.3GHz quad-core Intel Core i5). The total gain in listing the checks timed withtime
, which include (import overheads and print outs) ranges from 25% to 40% on various systems that it was tested. Now the loading phase of tests is fully dominated by the test instantiation:reframe/reframe/core/decorators.py
Line 67 in 1be1749
This in turn can be broken down in three major factors:
__setattr__
and__getattr__
machinery of the metaclassTypedField
These time consuming operations are more difficult to reduce, since especially (1) is at the heart of the test syntax eDSL. For the other two factors, we might think of possible optimisations in the future.
Implementation details
The performance gains in loading the tests come from the following two factors:
SystemPartition
and theEnvironment
are immutable objects, so there is no need to copy them.Fixes #2497