Skip to content
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

Account for time spent in garbage collection #3979

Merged
merged 36 commits into from
Jun 5, 2024

Conversation

jobh
Copy link
Contributor

@jobh jobh commented May 10, 2024

Avoid flaky DeadlineExceeded due to garbage collection.

See #3975 (comment).

@jobh jobh requested a review from Zac-HD as a code owner May 10, 2024 11:11
Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I really like this approach! You've already handled most of the tricky double-counting concerns too, so I have fewer nitpicks than I feared 🙂

hypothesis-python/src/hypothesis/statistics.py Outdated Show resolved Hide resolved
hypothesis-python/src/hypothesis/stateful.py Show resolved Hide resolved
hypothesis-python/src/hypothesis/core.py Outdated Show resolved Hide resolved
@jobh jobh force-pushed the gc-accounting branch 3 times, most recently from e452a0c to 3f79ceb Compare May 13, 2024 08:06
@jobh jobh force-pushed the gc-accounting branch 2 times, most recently from c434f20 to 2e5e9cf Compare May 13, 2024 14:31
@jobh

This comment was marked as outdated.

@jobh jobh force-pushed the gc-accounting branch 3 times, most recently from 8d23490 to e580dff Compare May 14, 2024 08:15
@jobh jobh force-pushed the gc-accounting branch 5 times, most recently from 1395d9d to 68e818a Compare May 14, 2024 10:34
@jobh
Copy link
Contributor Author

jobh commented May 14, 2024

All tests passed, finally. There were more complications than I expected, the two major ones are commented above.

The scrutineer part is probably just due to more variation in traces; which can be seen as a good thing, as the variation covers more of real-world usage (although some globbing would be nice to have in that list).

The recursion depth thing may or may not be a problem in practice, I just don't know. I set out to kill one source of flakiness, only to create another. Not happy with that one is ok actually.

Anyway: Ready for re-review :-)

@Zac-HD
Copy link
Member

Zac-HD commented May 14, 2024

(jumping on a flight to PyCon now, but the Scrutineer thing is not a problem, and I'll aim to review the unraisable problem later)

@jobh
Copy link
Contributor Author

jobh commented May 14, 2024

(jumping on a flight to PyCon now, but the Scrutineer thing is not a problem, and I'll aim to review the unraisable problem later)

Thanks @Zac-HD! Have fun at PyCon!

@jobh jobh force-pushed the gc-accounting branch 2 times, most recently from a3af8e8 to d3baf60 Compare May 15, 2024 08:37
@Zac-HD
Copy link
Member

Zac-HD commented May 20, 2024

(just want to note that I haven't forgotten about this; it's just tricky enough that I need a dedicated chunk of time to think about it and make sure I've tested all the edge cases. thanks for your patience 🙏)

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jobh, I've added a last test based on your repro and I think we're ready to merge!

hypothesis-python/RELEASE.rst Outdated Show resolved Hide resolved
hypothesis-python/tests/conjecture/test_engine.py Outdated Show resolved Hide resolved
hypothesis-python/RELEASE-sample.rst Outdated Show resolved Hide resolved
hypothesis-python/RELEASE.rst Outdated Show resolved Hide resolved
@jobh
Copy link
Contributor Author

jobh commented May 31, 2024

@Zac-HD I think it's ready now.

Review guidance:

  • There are no changes in the users of gc_cumulative_time(), i.e. the actual accounting.
  • The "freeze time in conftest.py" patching is reimplemented as separate gc callbacks, to flatten the stack directly and also by avoiding callback indirection.
  • The new recursion test is completely rewritten.

Additionally,

  • I wrapped the actual test execution (inside execute_once) with ensure_free_stackframes, for maximal consistency. Now, it turned out this wasn't enough to remove it from conjecture/engine.py, since the one in engine.py also protects data generation. Rather than trying to narrow down exactly where the stack is needed, I just left it in place.
  • Would you support globbing the scrutineer ignores, something like jobh@5ddfd2e (perhaps additionally simplified by not supporting "**")?
  • Globs in scrutineer ignores
  • New env variable (for internal use) HYPOTHESIS_NO_TRACEBACK_TRIM. Running in verbose mode is not a realistic option for deeply recursive strategies, but I still sometimes want to see the full stack trace. (I think I just patched it out when working on recursion earlier)

@jobh

This comment was marked as outdated.

@tybug
Copy link
Member

tybug commented May 31, 2024

New env variable (for internal use) HYPOTHESIS_NO_TRACEBACK_TRIM

Yes please! I've hacked this locally many times while tracking down internal errors.

test_mostly_does_not_duplicate_blocks_even_when_failing

undoubtedly from #3962. We can just add {1, 4} as a possibility there. I'll do so in #4007 if you don't here

@jobh
Copy link
Contributor Author

jobh commented May 31, 2024

undoubtedly from #3962. We can just add {1, 4} as a possibility there. I'll do so in #4007 if you don't here

Thanks @tybug ! I think #4007 is the better home for it.

@jobh jobh requested a review from Zac-HD June 1, 2024 08:13
Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github apparently didn't notify me for a few days (???), but this looks great! Thanks for persisting through @jobh, it's the accumulation of this kind of careful handling that makes our user experience so good 🤩

@Zac-HD Zac-HD merged commit 7b1d106 into HypothesisWorks:master Jun 5, 2024
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants