-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
async_hooks: create the storage hook only when needed #40810
async_hooks: create the storage hook only when needed #40810
Conversation
Benchmark CI for |
The storage hook got created whenever the `async_hooks` module was being required. There is no reason to do that if we don't use the `AsyncLocalStorage` class later on. Signed-off-by: Darshan Sen <darshan.sen@postman.com>
58f78ec
to
7f96221
Compare
@nodejs/async_hooks review plz. I was also wondering if the benchmarks for
|
I am not sure this is a big change as the hook is disabled until there is a need for it. Also, this makes the code a bit harder to read for me - could we add comments if we go this way? |
@vdeturckheim I didn't know know how long it took to construct the hook compared to the rest of the things that happen when this module gets loaded, so I guessed that this was the main reason for the overhead #40804 (comment) was talking about. I'm okay with closing this if isn't significant but I would still like to know where the overhead comes from when we load |
I don't know really where the overhead is from, it might be useful to do some profiling here :) |
Running the profiler, it seems that the overhead is the same as what you get when you load any module and it doesn't have much to do with
|
The storage hook got created whenever the
async_hooks
module was beingrequired. There is no reason to do that if we don't use the
AsyncLocalStorage
class later on.Signed-off-by: Darshan Sen darshan.sen@postman.com