-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
precondition with lambda function slows down RuleBasedStateMachine considerably #3963
Comments
|
Another related issues seems to be that ast.parse() for some reason is consuming a lot of memory and keeps the memory around while the test is running. Here's Scalene profile produced on the minimal test case above: 40 MB does not look like much, but on my realistic test case the memory usage climbs to 1 GB in the first minute and it keeps going up until terminated by max_examples limit. |
|
Wow, thanks for the detailed report! #3966 will address the performance and likely subsequently the memory...though we may still have an underlying leak somewhere. |
|
Tanks for a quick turnaround! |
|
This should be fixed in |
|
I confirm that CPU-time performance is okay on hypothesis-6.100.4. Memory consumption is still suspicious but I will open a separate issue about it, assuming I'm able to write down sensible bug report. |
Hello once again,
and big thank you for Hypothesis! It's a great tool and helped me to uncover nasty and hard-to-find bugs.
Summary
@preconditiondecorator with a trivial lambda function (one integer comparison + object dereference) causes significant slowdown in RuleBasedStateMachine execution.Versions
Measurement on a realistic test case
I'm going to show measurement numbers for my complex (but realistic) state machine, which uses complex custom strategy to generate inputs. With all the complexity I would not expect
preconditionto take negligible toll on execution time, but that's not the case.pytest reported runtime:
A] including five instances of preconditions
len(self.model) > 0andself.iter_generation == self.testcase.generation:B] Without preconditions (just commented out, they were meant as optimization to steer the state machine into more interesting states):
syscall profiling
perf trace --summarysyscall profiling:In other words, roughly 10 % of runtime was spent in doing
openatsyscall. Huh?Probable cause
Here's what
straceshows during test execution:A bit of light debugging in GDB+python-gdb plugin indicates that these calls originate here:
Confirmation
Just to confirm we are on the right track this cheapskate patch gets runtime for variants with and without precondition to the same values:
Reproducer
Here's smaller test case which does not actually test anything:
test_reproducer.py.gz
The text was updated successfully, but these errors were encountered: