-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Refactor slow running tests #20128
Comments
Made a checklist is people want to "claim" some.
|
I can confidently say that
should not be changed. They test important edge case behaviour. Also, these can't really be changed any further after my PR from today lands:
They each run many different benchmark files so there's a Node.js startup cost involved for each additional benchmark that exists. |
@apapirovski I removed those from the lists above. |
The addons tests might also be hard to fix. There's a bootup cost involved and some of those don't do that much. (Also... sorry that I started immediately poking at it... I really appreciate the fact that you put this together! ❤️) |
@BridgeAR I was looking at some of the tests. Can you share some general things to look at for optimizations ? How to benchmark the test and how to see where are the bottlenecks ? Thanks! 😇 |
Hi, it's my first time come here. If I want to improve one of these tests, are there any document or wiki that I can follow? |
@shobhitchittora I did not look at the tests before. It will always be individual for each test case how to improve it. One thing that you could look for are timeouts. Those should likely be minimized while it is important to make sure the test will still cover the same parts as before while also staying reliable. Besides that it is good to check what takes most time in the individual test. That can be done by using e.g. If the test is heavily CPU bound and that is the reason for it to be slow, there is probably little that can be done about it and if that is your finding, please report that back as well. Some times the test could be rewritten in a less CPU bound way while still covering the same parts but if that is not the case, we should just accept that the specific test is going to take the time it takes. @tigercosmos we have a guide how to write tests. See https://github.com/nodejs/node/tree/master/doc/guides/writing-tests.md. Besides that there is no further documentation. The tests are written just as any regular application code and should be mostly straight forward since it is only Node.js core. There are some helper functions that come from the |
Thanks as always @BridgeAR. 👍🏻 |
One of the biggest issues in our tests is that we often use sync code instead of running things in parallel. |
This refactors some tests to reduce the runtime of those. Refs: nodejs#20128
I'm probably in the minority here, but I'm wary of this effort. We seem to be encouraging fairly significant churn just to shave milliseconds here and there off the test suite. Doesn't seem worth it to me. (If the changes have other benefits, like making the code more maintainable, then great. But that doesn't seem to be what happens.) |
@Trott there is another reason to do this: this makes sure our tests will have less timeout errors on slow running machines as these errors are still turning up from time to time. |
@BridgeAR In theory, perhaps that's true. In practice, it seems to me that the proposed changes thus far often introduce complexity and decrease consistency. In turn, that makes tests less maintainable and also risks introducing unintentional unreliability. See #20756. It's likely that a more robust solution for people with slow machines is to run the tests with the I'm all for test changes that improve reliability of tests and reduce timeouts. This approach (EDIT: specifically, encouraging micro-optimizations) isn't passing the smell test for me. I sense a lot of unintended consequences. |
@Trott that highly depends on what test it is and I would not generalize that at all. So far only a few tests were touched at all. |
@nodejs/testing |
@BridgeAR I've looked at speeding up the test suite in the past, making a list of tests that are slow on my machine as you've done here. It's possible the general results will be different this time. But it's also hard for me to disregard my own past experiences. I'm not suggesting that you abandon the effort to make the tests run faster. I just want the pitfalls to be known and for people to watch out for them. And perhaps for a modified approach, specifically a higher threshold than 1 second for listing a test as needing work. Shaving a few milliseconds off a test that takes less than two seconds to run isn't going to help anyone if it's at the expense of consistency and maintainability. People on slow machines who experience timeouts aren't having the problems there. Their problems are with the really long running tests and/or with tests that don't handle system load well. (I would encourage anyone who makes significant changes to any test in There are approaches I would support such as:
Anyway, those are the things I'd consider. Take it into consideration or not. I'm not trying to stop the effort here. Just trying to get it more focused on places where the cost/benefit ratio is higher in my personal estimation. |
this refactors tests for module to reduce runtime Refs: nodejs#20128
Another data point that refactoring tests to shave off 150 ms may create more problems than it solves: #20688 (comment) |
This refactors some tests to reduce the runtime of those. PR-URL: nodejs#20688 Refs: nodejs#20128 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Yang Guo <[email protected]>
When "best practices" are not actually the best practices: Replacing |
This refactors some tests to reduce the runtime of those. PR-URL: #20688 Refs: #20128 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Yang Guo <[email protected]>
The changes to I'm removing the |
This refactors some tests to reduce the runtime of those. PR-URL: #20688 Refs: #20128 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Yang Guo <[email protected]>
First steps towards not needing to require test/common/index.js everywhere. Refs: nodejs#20128 (comment)
Hello folks, |
Refactoring individual tests is unlikely to have much of an effect on our overall test runtime. I'm not bothered by how long it takes to run our tests, but if others are, here's what I would see as a productive way forward:
I'd prefer this issue be closed as I think it seems to attract well-meaning-but-misguided work. Those efforts could be put to better use. |
I thought I already closed this. |
Our test suite takes quite a while currently and we constantly add new tests. A couple of those run really slow and block other tests to run in the meanwhile. So I checked which ones currently take longer than one second on my machine and this is the list:
The sequential ones are particularly bad. A couple of these were just improved by @apapirovski in #20125 ❤️.
I believe we should go through this list and try to refactor a couple of these to reduce the overall load.
Update: I removed all tests where we already know that they should not be changed. This is the case for e.g., all benchmark tests after #20125.
The text was updated successfully, but these errors were encountered: