GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-142145: Avoid timing measurements in quadratic behavior test by colesbury · Pull Request #143105 · python/cpython Conversation
|
|
The context for this is that I'm trying to get the full test suite in a state where we can run it under TSan. TSan tends to be much slower, so timing tests are even more flaky. Let me know what you think about this appraoch. For context, I used ChatGPT to generate the test and then edited it. (It was pretty good, but not perfect). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @colesbury, did you happen to run this test with the commit in question reverted to see that this test would indeed catch quadratic behavior in number of accesses? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yes, if you revert the fix then it fails with: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @colesbury!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| @support.requires_resource('cpu') | ||
| def testAppendChildNoQuadraticComplexity(self): | ||
| # Don't use wall-clock timing (too flaky). Instead count a proxy for the |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Elide the model's explanatory comment about the old no longer present code.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self.assertEqual(dom.documentElement.childNodes[-1].data, "Hello") | ||
| dom.unlink() | ||
|
|
||
| @support.requires_resource('cpu') |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
why remove this? i realize the test shouldn't be "slow" now, but the intent of adding it was to mark it as a test that may not be suitable for slow builds and loaded systems. some of our buildbots run with the cpu resource disabled for that reason. it's more of a performance test no matter how it is implemented.
for tests where it isn't platform specific and we just need something in our support tiers to catch an unlikely regression the issue, resource tags save effort.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'll add it back. I removed it because my understanding was that "cpu" was for tests that were CPU-heavy, and now this test is very fast (~30 ms in a debug build).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| total_calls += 1 | ||
| return object.__getattribute__(self, attr) | ||
|
|
||
| with support.swap_attr(Element, "__getattribute__", getattribute_counter): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
doing this is... gross, but likely works. your assertGreater(w1, 0) below covers the case when it stops doing so. LGTM
the other thought i was having as i did the simple "raise the timeout to 4s" to unblock the earlier ones was that we don't need absolute times at all. measuring relative time taken as we increase the amount of work to ensure that it scales - similar to this scaling measurement of attribute accesses - would be sufficient and should produce similar results on super slow builds or heavily loaded systems. it would still be time based (so maybe use resource.getrusage(resource.RUSAGE_SELF).ru_utime instead of time. APIs... though i suspect rusage is low-res) but far less "works on my system"
we have a smattering of other timing based cpu performancy tests in the repo. i don't think we've codified a reusable best practice.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
measuring relative time taken as we increase the amount of work ... would be sufficient
It'd be great to have some sort of standard best practice for this. If resource.getrusage(resource.RUSAGE_SELF).ru_utime isn't too affected by other processes, that would be good.
Some other things I was thinking about:
perf_event_open?)ceval.c in debug builds)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks @colesbury for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…pythongh-143105) Count the number of Element attribute accesses as a proxy for work done. With double the amount of work, a ratio of 2.0 indicates linear scaling and 4.0 quadratic scaling. Use 3.2 as an intermediate threshold. (cherry picked from commit 57937a8) Co-authored-by: Sam Gross <[email protected]>
…pythongh-143105) Count the number of Element attribute accesses as a proxy for work done. With double the amount of work, a ratio of 2.0 indicates linear scaling and 4.0 quadratic scaling. Use 3.2 as an intermediate threshold. (cherry picked from commit 57937a8) Co-authored-by: Sam Gross <[email protected]>
|
GH-143139 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-143140 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
gh-143105) (#143139) Count the number of Element attribute accesses as a proxy for work done. With double the amount of work, a ratio of 2.0 indicates linear scaling and 4.0 quadratic scaling. Use 3.2 as an intermediate threshold. (cherry picked from commit 57937a8) Co-authored-by: Sam Gross <[email protected]>
gh-143105) (#143140) Count the number of Element attribute accesses as a proxy for work done. With double the amount of work, a ratio of 2.0 indicates linear scaling and 4.0 quadratic scaling. Use 3.2 as an intermediate threshold. (cherry picked from commit 57937a8) Co-authored-by: Sam Gross <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.