Limit concurrency during plugin compilation

Summary:
My MBP just crashed again during startup. I would like to
understand why every plugin compilation appears to start
up a new electron process, but until that's understood
and hopefully fixed, it's probably best to limit the number
of processes we spawn by setting an upper bound here.

N.B. My Linux box doesn't mind this at all.

Reviewed By: jknoxville, danielbuechele

Differential Revision: D17419289

fbshipit-source-id: a11562a21a984059dc35e826eb20d869df218546
This commit is contained in:
Pascal Hartig
2019-09-17 12:19:41 -07:00
committed by Facebook Github Bot
parent ada2327520
commit 2a6462641b
3 changed files with 30 additions and 3 deletions

View File

@@ -126,6 +126,7 @@
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"node-fetch": "^2.3.0", "node-fetch": "^2.3.0",
"openssl-wrapper": "^0.3.4", "openssl-wrapper": "^0.3.4",
"p-map": "^3.0.0",
"pkg": "^4.3.7", "pkg": "^4.3.7",
"promise-retry": "^1.1.1", "promise-retry": "^1.1.1",
"promisify-child-process": "^3.1.1", "promisify-child-process": "^3.1.1",

View File

@@ -12,6 +12,7 @@ const Metro = require('metro');
const util = require('util'); const util = require('util');
const recursiveReaddir = require('recursive-readdir'); const recursiveReaddir = require('recursive-readdir');
const expandTilde = require('expand-tilde'); const expandTilde = require('expand-tilde');
const pMap = require('p-map');
const HOME_DIR = require('os').homedir(); const HOME_DIR = require('os').homedir();
/* eslint-disable prettier/prettier */ /* eslint-disable prettier/prettier */
@@ -38,12 +39,12 @@ module.exports = async (
fs.mkdirSync(pluginCache); fs.mkdirSync(pluginCache);
} }
watchChanges(plugins, reloadCallback, pluginCache, options); watchChanges(plugins, reloadCallback, pluginCache, options);
const compilations = Object.values(plugins).map(plugin => { const compilations = pMap(Object.values(plugins), plugin => {
const dynamicOptions = Object.assign(options, {force: false}); const dynamicOptions = Object.assign(options, {force: false});
return compilePlugin(plugin, pluginCache, dynamicOptions); return compilePlugin(plugin, pluginCache, dynamicOptions);
}); }, {concurrency: 4});
const dynamicPlugins = (await Promise.all(compilations)).filter(c => c != null); const dynamicPlugins = (await compilations).filter(c => c != null);
console.log('✅ Compiled all plugins.'); console.log('✅ Compiled all plugins.');
return dynamicPlugins; return dynamicPlugins;
}; };

View File

@@ -1484,6 +1484,14 @@ agentkeepalive@^2.2.0:
resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-2.2.0.tgz#c5d1bd4b129008f1163f236f86e5faea2026e2ef" resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-2.2.0.tgz#c5d1bd4b129008f1163f236f86e5faea2026e2ef"
integrity sha1-xdG9SxKQCPEWPyNvhuX66iAm4u8= integrity sha1-xdG9SxKQCPEWPyNvhuX66iAm4u8=
aggregate-error@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.0.0.tgz#5b5a3c95e9095f311c9ab16c19fb4f3527cd3f79"
integrity sha512-yKD9kEoJIR+2IFqhMwayIBgheLYbB3PS2OBhWae1L/ODTd/JF/30cW0bc9TqzRL3k4U41Dieu3BF4I29p8xesA==
dependencies:
clean-stack "^2.0.0"
indent-string "^3.2.0"
ajv-keywords@^3.4.0: ajv-keywords@^3.4.0:
version "3.4.1" version "3.4.1"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.4.1.tgz#ef916e271c64ac12171fd8384eaae6b2345854da" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.4.1.tgz#ef916e271c64ac12171fd8384eaae6b2345854da"
@@ -2468,6 +2476,11 @@ class-utils@^0.3.5:
isobject "^3.0.0" isobject "^3.0.0"
static-extend "^0.1.1" static-extend "^0.1.1"
clean-stack@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==
cli-boxes@^2.2.0: cli-boxes@^2.2.0:
version "2.2.0" version "2.2.0"
resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-2.2.0.tgz#538ecae8f9c6ca508e3c3c95b453fe93cb4c168d" resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-2.2.0.tgz#538ecae8f9c6ca508e3c3c95b453fe93cb4c168d"
@@ -4765,6 +4778,11 @@ indent-string@^2.1.0:
dependencies: dependencies:
repeating "^2.0.0" repeating "^2.0.0"
indent-string@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-3.2.0.tgz#4a5fd6d27cc332f37e5419a504dbb837105c9289"
integrity sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=
indexof@0.0.1: indexof@0.0.1:
version "0.0.1" version "0.0.1"
resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d"
@@ -6863,6 +6881,13 @@ p-locate@^3.0.0:
dependencies: dependencies:
p-limit "^2.0.0" p-limit "^2.0.0"
p-map@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/p-map/-/p-map-3.0.0.tgz#d704d9af8a2ba684e2600d9a215983d4141a979d"
integrity sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==
dependencies:
aggregate-error "^3.0.0"
p-reduce@^1.0.0: p-reduce@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa" resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa"