Skip to content
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

feat: support runtime option #65

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

AriPerkkio
Copy link
Member

@AriPerkkio AriPerkkio commented Jul 24, 2023

 

  • No semver breaking changes
  • Adds new internal common interface TinypoolWorker
  • Moves existing node:worker_threads worker to runtime/thread-worker.ts - backwards compatible
  • Adds new runtime option for pool constructor
  • Creates new TinypoolWorker which runs on node:child_process, runtime/process-worker.ts. This is used when runtime: 'child_process' pool option is used.
  • Adds new channel option for pool.run() method. This is used to pass callback for main thread/process <-> worker communication. This option is not supported by ThreadWorker.
  • Adds new runtime option for pool.recycleWorkers. This can be used to recycle current workers and change the runtime of next set of workers.

 

  • Constructor support: new TinyPool({ runtime: 'child_process' })
  • Pool methods: pool.recycleWorkers({ runtime: 'child_process' })
  • Communication via something like MessagePort - maybe introduce new run() option for this -> channel option created

@AriPerkkio
Copy link
Member Author

This is still very much work-in-progress. Running code in child_process pool works though.

@AriPerkkio AriPerkkio force-pushed the feat/tiny-worker-runtime branch from 151ebb5 to 5d98c2e Compare July 24, 2023 10:59
@AriPerkkio AriPerkkio changed the title feat!: support runtime option feat: support runtime option Jul 24, 2023
@AriPerkkio AriPerkkio force-pushed the feat/tiny-worker-runtime branch 2 times, most recently from 6b598a5 to 3f17746 Compare July 25, 2023 13:05
@ghiscoding
Copy link

you can add Lerna-Lite to the list of project that requires the use of child_process, so are you expecting to land this PR before the official Vitest 1.0 in September? In Lerna-Lite, I have to use --no-thread and it's hyper slow on Windows and I have to use WSL to make it quicker, I assume this PR would help to restore decent speed on Windows as well, right?

@AriPerkkio
Copy link
Member Author

I assume this PR would help to restore decent speed on Windows as well, right?

Yes, this PR would allow Vitest to use multiple child_process runners. Speed should be almost as good as with --threads option. Currently the --no-threads is only option to not use worker_threads, and that option uses only a single child_process.

are you expecting to land this PR before the official Vitest 1.0 in September?

I won't promise anything but hopefully yes. This might introduce breaking changes, e.g. refactoring the --threads, --no-threads, --single-thread arguments.

@ghiscoding
Copy link

I won't promise anything but hopefully yes. This might introduce breaking changes, e.g. refactoring the --threads, --no-threads, --single-thread arguments.

That would be great, thanks for all the info, great job on all the work you do on Vitest and all other indirect projects 😉

@AriPerkkio AriPerkkio force-pushed the feat/tiny-worker-runtime branch 19 times, most recently from 252e642 to 07bc5cd Compare August 13, 2023 12:14
@AriPerkkio AriPerkkio marked this pull request as ready for review August 13, 2023 12:31
src/entry/process.ts Outdated Show resolved Hide resolved
@AriPerkkio AriPerkkio force-pushed the feat/tiny-worker-runtime branch from 07bc5cd to d1b8c9b Compare August 13, 2023 13:29
Copy link
Member

@sheremet-va sheremet-va left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! Thank you for your hard work 🙏

Copy link
Member

@Aslemammad Aslemammad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left open source for a while, but this was a refreshing PR! Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Support child_process runtime
4 participants