async_hooks: create the storage hook only when needed#40810
async_hooks: create the storage hook only when needed#40810RaisinTen wants to merge 1 commit intonodejs:masterfrom
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 Details |
The storage hook got created whenever the
async_hooksmodule was beingrequired. There is no reason to do that if we don't use the
AsyncLocalStorageclass later on.Signed-off-by: Darshan Sen darshan.sen@postman.com