Use worker_threads for running tests#674
Closed
lydell wants to merge 2 commits into
Closed
Conversation
lydell
force-pushed
the
worker_threads
branch
2 times, most recently
from
July 20, 2026 15:39
3ed39e7 to
6f4f556
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is much simpler, but somehow slower on a big project. I expected it to be faster.
I committed a benchmark. Note: ChatGPT wrote it for me, and I tweaked it. It tests sending messages to and from:
worker_threadsworker_threadsbut usingJSON.stringifyandJSON.parseinstead of the regular serialization.child_process.forkwithprocess.send(the built-in IPC communication)child_process.forkwithprocess.sendbut usingJSON.stringifyandJSON.parseinstead of the regular serialization.child_process.forkwith a UNIX pipe like we already use in node-test-runner.It tests three scenarios:
What about worker startup time?
worker_threadstakes about 35 ms on my machine, whilechild_process.forktakes about 55 ms. Soworker_threadsshould be slightly faster there. But then the code somehow runs a little bit slower withworker_threadsand I haven’t been able to figure out why.All in all, I don’t think we should switch to
worker_threads.