-
Notifications
You must be signed in to change notification settings - Fork 50
Add multi-worker support to the beta features menu. #2058
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
Merged
+35
−3
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0188a02
Add multi-worker support to the beta features menu.
griffbrad 6af2a75
Making linter happy.
griffbrad 6627dd7
Remove "experimental" from multi-worker description because it is alr…
griffbrad 6efb3f9
Merge branch 'trunk' into feature/multi-worker-support
fredrikekelund 414e333
Fix types
fredrikekelund 25ae694
Fix tests
fredrikekelund af62618
Merge branch 'trunk' into feature/multi-worker-support
fredrikekelund File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import { cpus } from 'os'; | ||
| import { SupportedPHPVersion, PHPRunOptions } from '@php-wasm/universal'; | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { runCLI, RunCLIArgs, RunCLIServer } from '@wp-playground/cli'; | ||
|
|
@@ -186,6 +187,7 @@ async function startServer( | |
| const defaultConstants = { | ||
| WP_SQLITE_AST_DRIVER: true, | ||
| }; | ||
|
|
||
| const mounts = [ | ||
| { | ||
| hostPath: options.documentRoot, | ||
|
|
@@ -201,7 +203,7 @@ async function startServer( | |
| }, | ||
| ]; | ||
|
|
||
| const args: RunCLIArgs = { | ||
| const args: RunCLIArgs & { command: 'server' } = { | ||
| command: 'server', | ||
| internalCookieStore: false, | ||
| login: false, | ||
|
|
@@ -214,6 +216,15 @@ async function startServer( | |
| wordpressInstallMode: options.wordpressInstallMode, | ||
| }; | ||
|
|
||
| // Enable multi-worker support if beta feature is enabled | ||
| if ( options.enableMultiWorker ) { | ||
| const workerCount = Math.max( 1, cpus().length - 1 ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Edge case consideration: On systems with 1 CPU core, Consider either:
Example: if ( options.enableMultiWorker ) {
const cpuCount = cpus().length;
if ( cpuCount === 1 ) {
console.log( '[playground-cli] Multi-worker support enabled but system has only 1 CPU core, using 1 worker' );
}
const workerCount = Math.max( 1, cpuCount - 1 );
// ...
}Not blocking, but worth considering for better UX. |
||
| console.log( | ||
| `[playground-cli] Enabling experimental multi-worker support with ${ workerCount } workers (CPU cores - 1)` | ||
| ); | ||
| args.experimentalMultiWorker = workerCount; | ||
| } | ||
|
|
||
| if ( options.phpVersion ) { | ||
| args.php = options.phpVersion as SupportedPHPVersion; | ||
| } | ||
|
|
@@ -232,8 +243,11 @@ async function startServer( | |
|
|
||
| server = await runCLI( args ); | ||
|
|
||
| if ( ! server ) { | ||
| throw new Error( 'Could not start server' ); | ||
| // Log actual worker count for verification | ||
| if ( options.enableMultiWorker ) { | ||
| console.log( | ||
| `[playground-cli] Server started with ${ server.workerThreadCount } worker thread(s)` | ||
| ); | ||
| } | ||
|
|
||
| if ( serverOptions.adminPassword ) { | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation suggestion: The description is clear, but you might want to add a note about system requirements or performance characteristics:
This helps users understand that the benefit is tied to having multiple CPU cores available.