Performance: consider uploading files in parallel
Closed this issue · 3 comments
erezrokah commented
Could this loop be done in parallel?
netlify-plugin-nimbella/index.js
Line 31 in beca8fd
Considering this uploads files it could improve performance.
satyarohith commented
I tried to achieve this but the output was a bit distorted. Would be a nice improvement for a future release. Thanks for your suggestion. :)
ehmicky commented
Removing the initial Deploy ${file}...
might help make the logs less distorted:
await Promise.all(files.map(async file => {
const [actionName, extension] = file.split('.');
let command =
`nim action update ${actionName} ${join(functionsDir, file)} ` +
`--timeout=${Number(timeout)} --memory=${Number(memory)} ` +
`--web=raw `;
if (extension === 'js') {
command += '--kind nodejs-lambda:10 --main handler';
}
// Note: since stdout: 'ignore' is used, the returned `stdout` will always be empty
const {stderr, exitCode} = await run.command(command, { reject: false, stdout: 'ignore' });
const message = exitCode === 0 ? 'done.' : String(stderr)
console.log(`Deployed ${file}: ${message}`)
}))
If the files must be sorted in the logs, it could also be possible to do a single console.log()
after all files have been deployed.
satyarohith commented
Thanks for the suggestion, @ehmicky! :)