Patch Playground to reduce worker count on low-memory machines#2696
Patch Playground to reduce worker count on low-memory machines#2696sejas wants to merge 2 commits intorelease/1.7.5from
Conversation
Patch @wp-playground/cli to use 3 workers instead of 6 when the machine has less than 8GB of free RAM, reducing memory pressure on Windows and other memory-constrained environments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This rule would make more sense if the total available system memory was 8GB. Given that a site process uses ~1.6 GB, this seems like a too harsh limit right now. There's also the fact that this will make some sites slower than others with no clear explanation as to why… I'm not immediately sure about the best solution here, but looking at |
|
What if we limit the number of workers based on OS? Windows -> 3 , else -> 6. |
|
That would make consistent the performance of each site for both platforms. |
|
With 3 workers, Parallels (8GB RAM) can run 6 sites in parallel (from 3 without the patch). |
totalmem is more reliable than freemem for determining machine capacity, as free memory fluctuates based on caching and other transient factors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@fredrikekelund, I think your suggestion is the best approach. Let's use |
Related issues
How AI was used in this PR
Planned with Opus 4.6 and created the code, patch, and PR fully automated. Tweaked a bit the testing instructions. Reviewed and tested the PR.
Proposed Changes
@wp-playground/clito dynamically set worker count based on available memoryTesting Instructions
nvm use && npm inpm startnode_modules/@wp-playground/cli/run-cli-Cv4FHhj_.jsline 1284 containsq.freemem() < 8 * 1024 ** 3 ? 3 : 6node_modules/@wp-playground/cli/run-cli-NCnYfPz7.cjsline 47 containsG.freemem()<8*1024**3?3:6npm installand verify the patch applies without errorsPre-merge Checklist