Skip to content

Run in worker threads #1428

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

Closed
Qix- opened this issue Jun 28, 2017 · 17 comments · Fixed by #2690
Closed

Run in worker threads #1428

Qix- opened this issue Jun 28, 2017 · 17 comments · Fixed by #2690
Labels
enhancement new functionality 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted priority scope:scheduling

Comments

@Qix-
Copy link
Contributor

Qix- commented Jun 28, 2017

Issuehunt badges

See #1428 (comment)


Right now it appears the process is forked for each test and then the test is ran. This is unideal for a vast amount of reasons.

Upon discussion with Sindre, it was decided that we should explore moving into a pooled approach (where instances of the following classes shared a common interface and abstracted away the strategy for executing individual tests):

  • SingleProcessTestPool would run all tests in the main process without forking
  • ForkTestPool would fork the process N times (where N is the number of processors) and distribute tests out between them as they become idle

In the future, this could be expanded to a WorkerTestPool to implement support for workers.

This would give us the ability to decide upon the execution strategy based on a number of factors:

  • For <N tests, use SingleProcessTestPool; otherwise, use ForkTestPool
  • When --no-fork or equivalent flag is provided, force SingleProcessTestPool
  • When --inspect or --inspect-brk is specified, force SingleProcessTestPool (ref Debugging with the Node.js debugger #1108)

I'm not entirely sure how much work this would require, but consider this issue a 'jumping off' point for discussion.

EDIT: This might be of interest as well: https://nodejs.org/api/worker_threads.html


IssueHunt Summary

dnlup dnlup has been rewarded.

Backers (Total: $300.00)

Submitted pull Requests


Tips

@sindresorhus
Copy link
Member

  • SingleProcessTestPool would run all tests in the main process without forking

Would solve #1332.

@unional
Copy link

unional commented Sep 25, 2017

FYI on Jest using workers and also spread work based on the previous test duration:
http://facebook.github.io/jest/blog/2016/03/11/javascript-unit-testing-performance.html

@sindresorhus
Copy link
Member

@unional Yes, that's a good way to handle it, and with the design @Qix- is describing, it shouldn't be too hard to do.

@IssueHuntBot
Copy link

@sindresorhus has funded $60.00 to this issue. See it on IssueHunt

@avajs avajs deleted a comment from ORESoftware Dec 21, 2018
@Qix-
Copy link
Contributor Author

Qix- commented Dec 21, 2018

Issue hunt link is auth-walled :/ Any way to see it without associating it with my account?

@Qix-
Copy link
Contributor Author

Qix- commented Dec 21, 2018

Edited the OP to mention https://nodejs.org/api/worker_threads.html.

@IssueHuntBot
Copy link

IssueHuntBot commented Dec 22, 2018

@issuehuntfest has funded $200.00 to this issue. See it on IssueHunt

@avajs avajs deleted a comment from IssueHuntBot Dec 22, 2018
@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label May 10, 2019
@issuehunt-oss
Copy link

issuehunt-oss bot commented Jul 5, 2019

@futpib has funded $100.00 to this issue.


@novemberborn novemberborn unpinned this issue Sep 15, 2019
@novemberborn
Copy link
Member

We should only support worker threads and Node.js 12.16 or higher. I think it could even be the default on supported platforms. Despite the "pool" concepts discussed here, you'll have a better chance of getting this shipped by modifying lib/fork.js.

@novemberborn novemberborn changed the title Migrate forking to a pooled worker design Run in worker threads May 25, 2020
@sibelius
Copy link

what about using jest-worker for this?

@dnlup
Copy link
Contributor

dnlup commented Feb 17, 2021

👋🏻 @novemberborn

I have worked on this issue, and I should have something ready to review by next week. I have not used a pooled approach, to keep things more similar to the current strategy.

@novemberborn
Copy link
Member

@dnlup if you submit your PR on IssueHunt (I'm not entirely sure how) there's 270 USD waiting for you 😉

@dnlup
Copy link
Contributor

dnlup commented Mar 7, 2021

@dnlup if you submit your PR on IssueHunt (I'm not entirely sure how) there's 270 USD waiting for you

😄 I did submit it, maybe I have to submit it again?

@issuehunt-oss
Copy link

issuehunt-oss bot commented Mar 7, 2021

@novemberborn has rewarded $270.00 to @dnlup. See it on IssueHunt

  • 💰 Total deposit: $300.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $30.00

@issuehunt-oss issuehunt-oss bot added 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt and removed 💵 Funded on Issuehunt This issue has been funded on Issuehunt labels Mar 7, 2021
@Qix-
Copy link
Contributor Author

Qix- commented Mar 8, 2021

Incredible work here, thank you @dnlup.


I can't tell who, but <del> tags have magically appeared in the OP post here, and I'm not sure who did that. I don't use those tags (didn't even know they existed) so it certainly wasn't me.

Can we please not get in the habit of doing that? I didn't write all that just for it to be strike-through'd, and it's quite annoying to have someone else manhandle my text.

Just a sidenote.

@novemberborn
Copy link
Member

I can't tell who, but <del> tags have magically appeared in the OP post here, and I'm not sure who did that.

I can't tell from the edit history either, very strange. I've removed them.

@dnlup
Copy link
Contributor

dnlup commented Mar 8, 2021

Incredible work here, thank you @dnlup.

I can't tell who, but <del> tags have magically appeared in the OP post here, and I'm not sure who did that. I don't use those tags (didn't even know they existed) so it certainly wasn't me.

Can we please not get in the habit of doing that? I didn't write all that just for it to be strike-through'd, and it's quite annoying to have someone else manhandle my text.

Just a sidenote.

thank you @Qix-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new functionality 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted priority scope:scheduling
Projects
None yet
7 participants