-
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
Test Runner is slow #47663
Comments
Just my educated guess as someone who's been watching test_runner development from the outside: The overhead likely comes from Node.js spawning many child processes, one per test file 1. Meanwhile, Mocha is running all tests in the same process. I generated a performance profile 2 like this (in Bash on Linux): $ node --prof --test --test-reporter spec test/ &
$ echo $!
11456 # PID of main process
$ node --prof-process isolate-*-11456-v8.log > processed_main.txt
$ node --prof-process isolate-*-11616-v8.log > processed_test_file.txt There were 20
and the one sample test file:
In both cases it's almost entirely C++. In the C++ section of the profiles, Footnotes |
There is indeed some overhead here from using child processes. You can see mocha slow down on this particular test suite if you run it with The more interesting thing is that there was a huge slowdown on this suite between Node 18.12.1 and 18.13.0. In 18.12.1, the performance is on par with I think we should confirm if that is indeed the culprit. If it is, we can try to optimize the existing code. It would also be worth looking at removing the TAP parser and lexer completely and using a different serialization format such as JSON or even V8's serializer. I think we could serialize the reporter events directly to the parent process (minus the |
This comment was marked as abuse.
This comment was marked as abuse.
Was the cause of that issue introduced in 18.13.0? If not, then there is at least one other performance issue at play.
I would be hesitant to spawn the child processes with an IPC channel. That changes how some APIs work, and could lead to different behavior when a file is run with |
Yep, usage of
I am curios, what does it change? the idea was to use IPC to avoid breaking TAP |
That's great to hear.
I'm not 100% sure what you mean here, but I don't think we would break TAP. This would just be the communication protocol between the CLI runner and the child processes. It should never be visible to users unless they were spawning child processes with It's only really a breaking change because we have documented that |
This comment was marked as abuse.
This comment was marked as abuse.
I've noticed a few things when running your test suite locally with node 20.1.0:
There is definitely still room for improvement in Node's test runner, but I don't think the numbers are quite as drastic as reported in the previous comment. |
Version
18.16.0 same with 20.0.0
Platform
Ubuntu 22.04.2 and Windows 11
Subsystem
test_runner
What steps will reproduce the bug?
Run some simple tests with Nodejs Test Runner. For example:
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
I expect native test runner to run at least as Mocha speed or even faster.
What do you see instead?
duration_ms 1977 when on same tests Mocha runs in 38ms (50x faster, yeah)
Additional information
I also tested it on nodejs 20.0.0 and got same results. Same on Windows 11 and Ubuntu 22.04.2
I was happy to drop Mocha as a dependency, but was not expect to such a slow down.
You can see the switch from Mocha to native Test Runner in this commit egoroof/browser-id3-writer@6d29a06
The text was updated successfully, but these errors were encountered: