-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
Use CPU time for --warn-long #36226
Use CPU time for --warn-long #36226
Conversation
1f56451
to
c3d1af6
Compare
@@ -1467,7 +1475,7 @@ def report_failure(self, out, test, example, got, globs): | |||
self._fakeout.start_spoofing() | |||
return returnval | |||
|
|||
def report_overtime(self, out, test, example, got, *, check_duration=0): | |||
def report_overtime(self, out, test, example, got, *, check_timer=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old keyword should be deprecated using sage.misc.decorators.rename_keyword
, rather than just changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The keyword wasn't simply renamed -- the type of argument that it takes was changed too. Typically that would be an unfriendly thing to do, but this is essentially a private method. No other part of the sage library uses it (it's referenced exactly once, by self
), and since it's part of sage's custom doctest runner, it's hard to imagine a third party relying on these internal details. Frankly I'd like to change it to an underscore method now that you mention it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The keyword wasn't simply renamed -- the type of argument that it takes was changed too. Typically that would be an unfriendly thing to do, but this is essentially a private method. No other part of the sage library uses it (it's referenced exactly once, by
self
), and since it's part of sage's custom doctest runner, it's hard to imagine a third party relying on these internal details.
Cool. Sage policy is still to deprecate it. So deprecate the old argument and add a new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no way to translate the old argument into the new one. If we keep the old name but ignore its argument, then any code using this function will still be immediately broken, only more quietly and with more steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you feel that strongly about not changing this method's signature, I can copy & paste the entire function into a new private method _report_overtime
. And then we should do the same for _report_success
. That will leave the old methods intact to be deprecated, but I really think we would be wasting our time.
It's going to take time to put the old functions back and to add the deprecation warnings. It will take time to re-review those changes. It's going to take time to run the doctests for two unused functions in the interim. And then eventually someone has to spend the time to remove the functions, and someone else has to spend the time to review that.
Unless there's an (even remotely) plausible reason why anyone would be calling this function in their own code, it's justifiable to bend the deprecation rule. Its intent has been respected. And to do otherwise is wasting our most valuable resource.
Not your job here, but would it be worthwhile to have a summary of overly long doctests printed at the end of doctesting? |
Yes, but my vote would be to collect all warnings into that report. |
c019843
to
21e5d4d
Compare
Documentation preview for this PR (built with commit efa14c3; changes) is ready! 🎉 |
21e5d4d
to
247c635
Compare
@mkoeppe I have two modularization failures (in repl & categories) that I'm sure you know how to fix. Both fail at,
|
The CI has the following test failing on Conda/macOS:
The failure is,
The function either raises an |
Well, sure:
You forgot (a) the preparser makes |
FFS. Thanks. |
Still the two modularization failures. Judging from the line,
in I dare not make this change myself. @mkoeppe y/n? |
d6862d7
to
4f049b6
Compare
Rebased again. I'll try to make that modularization fix myself I guess. If anyone is tired of repeatedly having to split up the test runs in CI only to still get false positives due to timeouts, this is an important step towards addressing the root cause of those failures. |
ab62b56
to
945ae45
Compare
Like ZombieProcess... this can happen. And the doctest framework shouldn't crash if a pexpect process was killed.
98dbd96
to
993327b
Compare
We're importing psutil and trying to catch the ImportError if one is raised. But for that to work, it helps to put "import" inside of the "try" block.
If SystemExit occurs during a doctest, we re-raise it. The same thing should be done for SignalError (from cysignals). Signals can occur at any time, and the doctest runner shouldn't eat them. In particular, this can lead to a Heisenbug where a signal will terminate a doctest example before the timer has a chance to annotate the it with the elapsed walltime and cputime. In that case, we get an "impossible" AttributeError later on when we try to compute the total walltime used by the example.
12c0fa6
to
cf55b38
Compare
CI is finally green 💚 🍏 📗 🟢 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests report slow docstests although those are marked as "long time" (see annotations at the bottom in https://github.com/sagemath/sage/actions/runs/11373830486?pr=36226). Is this by design because those tests take longer than 30s? If yes, what is the plan with these "super long" tests?
Other than this point, the PR looks good to me.
# being rather generous here. | ||
self.options.warn_long = 5.0 | ||
if self.options.long: | ||
self.options.warn_long = 30.0 | ||
|
||
def second_on_modern_computer(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can now be deleted, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it's a "public" function, so I didn't want to start an argument over the deprecation policy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is safe to consider everything in doctest as private. But as a compromise, at least add a deprecation warning so that this can be removed in 1year?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Right. Tests that are marked
That number doesn't depend on I've changed this in two ways:
While 30s is still "super long," I'm trying to avoid turning the test output into an unreadable mess of warnings. We have a lot of tests that are too slow because the current behavior doesn't catch them. My plan was to start at something no one could object to (30s) and then lower it slowly as the existing issues get fixed. |
Okay, this makes a lot of sense. However, on CI you now have quite a bit of warnings at the end - which are usually unrelated to the PR. While this might stimulate people into helping making these tests quicker, I would prefer if the annotations are actually relevant to a given PR. Can you make the warn-long times even higher on CI (check for the CI env variable should do)? Or otherwise hide those warnings for now? |
This method of the DocTestController class is no longer used in the sage library, but technically, it was "public," so we deprecate it for later removal.
Yeah I didn't notice those annotations. I guess github turns the word "Warning" into an error, and doesn't give you a way to disable it, selectively or otherwise. I would like to keep the "slow doctest" warnings from the CI, just not the fake errors. I pushed a commit that will change the "Warning, slow doctest" into "Uh oh, slow doctest" when running under the CI. If it works, we can still ctrl-f the logs for "slow doctest," but they won't get converted to error annotations. |
These annotations are generated here: sage/src/sage/doctest/reporting.py Lines 263 to 280 in 7726cd9
It might be enough to use |
I looked at this but I didn't see a connection to the slow doctest warnings. The error annotations are added in |
No idea...but I assumed it would be generated there, since these annotations are "errors" (red) and not "warnings" (yellow). So if github would just magically parse "Warnings" then they would most likely be shown in yellow.
Probably because the ci uses its own docker container and never sets Line 269 in 7726cd9
|
Ah, thanks. I see invocations like,
So maybe we just need to pass |
205462a
to
0898772
Compare
Back to square one:
I think I've done enough blind debugging of Microsoft's crap today. |
0898772
to
660e8ca
Compare
Switch "Warning, slow doctest:" to "Warning: slow doctest:" so that the leading "Warning: " is consistent with other warnings. This ultimately prevents these slow doctest warnings from being converted into error annotations on the Github CI.
I finally got it to use warning annotations (and not errors) by switching the |
@tobiasdiez is it OK with the warning annotations, or do you want me to suppress them further? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if they wouldn't show up at all, but it's fine like this for me.
Feel free to set it to positive review, or wait a little bit if you still want a second pair of eyes to look at the code.
Ok, thank you. I started working on this in December of 2021 so I'd quite like to take it off my list and start working on the follow-up issues. |
Finally address #32981.
Using wall time to measure which tests are "long" doesn't make much sense. Wall time is subject to every conflating factor:
Ideally, everyone would agree on how long is too long for a test to run. Attaining that ideal is not so easy, but the first step is to switch
--warn-long
away from using wall time and towards using CPU time. A second phase (#33022) will normalize the CPU time.Examples
--warn-long output
The user-facing portion of this can be tested with a low
--warn-long
value,pexpect accounting
Two different methods are used to account for the CPU time, one for linux, and one for everything else. This GAP command uses pexpect and should chew up a good bit of CPU time: