-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
async_hooks: move to lazy destroy hook registration in AsyncResource #32429
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
Conversation
|
@vdeturckheim is it too much to ask you to take a look at this PR? |
|
@puzpuzpuz it's on the list rn, but I need a bit more time as I have a lot to do in the next few days. |
I didn't know that. Thanks for the clarification! |
doc/api/async_hooks.md
Outdated
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.
We will probably need to rebase this part over https://github.com/nodejs/node/pull/32514/files
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.
Thanks for the heads up!
As that PR is now merged, I have rebased this PR and slightly changed this new sentence in the AsyncResource doc, so it's more consistent with #32514.
61f8496 to
65a44dd
Compare
|
CI: https://ci.nodejs.org/job/node-test-pull-request/30474/ (:heavy_check_mark:) |
|
Landed in 561dda2 |
PR-URL: #32429 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
PR-URL: #32429 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
PR-URL: #32429 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
PR-URL: #32429 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Adds a check into
AsyncResourceconstructor, so thatregisterDestroyHookonly gets called whenrequireManualDestroyisfalseand there are no activedestroyhooks (previously the check only includedrequireManualDestroyvalue). As below benchmark shows this eliminates a certain overhead related with additional tracking of these objects as a part of GC cycle.This scenario is important considering
AsyncLocalStorageAPI which only usesinithooks.Important note. Obviously, this PR changes the behavior in the following edge case: previously when an
AsyncResourcewas created (but not yet destroyed) before enabling the firstdestroyhook, the hook would be called for the resource. With this change it's not called.Related discussion thread: petkaantonov/bluebird#1472 (comment)
cc @addaleax @vdeturckheim @Qard @Flarna (sorry for such long CC list, but I think all of you might be interested)
Benchmarks
Before this change:
After this change:
Note:
trackingEnabledWithDestroyHookscenario was added as a replacement for the oldtrackingEnabledscenario.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes