-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
fs: Performance Enhancement: Concurrent Execution of Async Tasks with Promise.all
✈
#51215
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
base: main
Are you sure you want to change the base?
fs: Performance Enhancement: Concurrent Execution of Async Tasks with Promise.all
✈
#51215
Conversation
Promise.all
✈Promise.all
✈
Lint fix
Lint fixes
Lint fixes
Fix Co-authored-by: Antoine du Hamel <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
Sorry @aduh95, I didn't understand what the |
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.
You need to import ArrayPrototypsePush
and SafePromiseAllReturnVoid
from the primordials
object at the top of the file.
node/doc/contributing/primordials.md
Lines 66 to 84 in b044369
Primordials wrap the original prototype functions with new functions that take | |
the `this` value as the first argument: | |
```js | |
const { | |
ArrayPrototypePush, | |
} = primordials; | |
const array = [1, 2, 3]; | |
ArrayPrototypePush(array, 4); | |
console.log(JSON.stringify(array)); // [1,2,3,4] | |
Array.prototype.push = function push(val) { | |
return this.unshift(val); | |
}; | |
ArrayPrototypePush(array, 5); | |
console.log(JSON.stringify(array)); // [1,2,3,4,5] | |
``` |
Co-authored-by: Antoine du Hamel <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
Thanks for the explanation. I will fix it ASAP. |
I hope the current code changes are correct. Apologies for any inconvenience. (@aduh95 ) |
@@ -159,10 +160,11 @@ class FSWatcher extends EventEmitter { | |||
if (file.isFile()) { | |||
this.#watchFile(f); | |||
} else if (file.isDirectory() && !file.isSymbolicLink()) { | |||
await this.#watchFolder(f); |
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.
Moving to Promise.all
, this code will not probably throw EMFILE, too many open files?
Do we have a good benchmark for this? I am surprised that this should improve the performance, I would actually expect it to be identical. In deno, there were a few changes that made it run in parallel but this should already execute things in parallel. |
Hello,
This pull request introduces a performance improvement by executing asynchronous tasks concurrently using
Promise.all
. This enhancement aims to optimize the utilization of hardware resources effectively.This PR draws inspiration from a similar one (though not identical) in the Deno runtime, where the execution time was reduced by 85% through concurrent processing. For reference, please see: denoland/std#3363.
Additionally, a comparable pull request has been made in the Deno JavaScript runtime, as demonstrated in: denoland/std#3683.
Thank you for considering these enhancements.