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: fix Promises with later enabled hooks #13242

Closed
wants to merge 6 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@addaleax
Member

addaleax commented May 26, 2017

Based on #13224

Fixes: #13237

/cc @AndreasMadsen @matthewloring @Fishrock123 @nodejs/diagnostics

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

async_hooks

Show outdated Hide outdated src/async-wrap.cc Outdated
@AndreasMadsen

AndreasMadsen approved these changes May 26, 2017 edited

LGTM.

Although, I do think we should use

uint32_t* fields_ptr = async_hooks->fields();
if (fields_ptr[AsyncHooks::kInit] +
    fields_ptr[AsyncHooks::kBefore] +
    fields_ptr[AsyncHooks::kAfter] +
    fields_ptr[AsyncHooks::kDestroy] > 0) {

}

instead of #13177 for a more consistent performance, when createHook() has been called but no hooks are enabled. But that is not relevant in this PR.

@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax May 26, 2017

Member

@AndreasMadsen Yes, I see no problem with doing that too; but I would really like to keep the SetPromiseHook() call lazy so that non-async_hooks users don’t pay the price for it.

Member

addaleax commented May 26, 2017

@AndreasMadsen Yes, I see no problem with doing that too; but I would really like to keep the SetPromiseHook() call lazy so that non-async_hooks users don’t pay the price for it.

@AndreasMadsen

This comment has been minimized.

Show comment
Hide comment
@AndreasMadsen

AndreasMadsen May 26, 2017

Member

Yes, I see no problem with doing that too; but I would really like to keep the SetPromiseHook() call lazy so that non-async_hooks users don’t pay the price for it.

Makes sense.

edit: the goal is that there is no difference between calling .disable() and never having called require('async_hooks'), but that is not a trivial task and is likely over-optimistic.

Member

AndreasMadsen commented May 26, 2017

Yes, I see no problem with doing that too; but I would really like to keep the SetPromiseHook() call lazy so that non-async_hooks users don’t pay the price for it.

Makes sense.

edit: the goal is that there is no difference between calling .disable() and never having called require('async_hooks'), but that is not a trivial task and is likely over-optimistic.

@matthewloring

This comment has been minimized.

Show comment
Hide comment
@matthewloring

matthewloring May 26, 2017

Contributor

This looks good on my end. Sorry for the lack of bandwidth to address this on #13224 directly.

Contributor

matthewloring commented May 26, 2017

This looks good on my end. Sorry for the lack of bandwidth to address this on #13224 directly.

@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax May 26, 2017

Member

@matthewloring No problem! This PR is me cleaning up my own mistake. If you want you can still cherry-pick 0ec3eba0534f7de36c6c2e8baa38188a5279727f into your PR so that it can land a bit earlier.

Member

addaleax commented May 26, 2017

@matthewloring No problem! This PR is me cleaning up my own mistake. If you want you can still cherry-pick 0ec3eba0534f7de36c6c2e8baa38188a5279727f into your PR so that it can land a bit earlier.

@matthewloring

This comment has been minimized.

Show comment
Hide comment
@matthewloring

matthewloring May 26, 2017

Contributor

As long as it gets in to node 8 I'm happy either way :)

Contributor

matthewloring commented May 26, 2017

As long as it gets in to node 8 I'm happy either way :)

@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax May 26, 2017

Member

the goal is that there is no difference between calling .disable() and never having called require('async_hooks'), but that is not a trivial task and is likely over-optimistic

It shouldn’t be so terribly hard either. Maybe I can take a look after the current bunch of async_wrap PRs are through.

As long as it gets in to node 8 I'm happy either way :)

@matthewloring Yeah, me too. Maybe we should ask @nodejs/collaborators whether they think it’s a good idea to fast-track this? At this point you and @AndreasMadsen seem to be “the” most relevant reviewers for async_hooks by far… (speaking of which, would you mind giving #13142 a look? 😬)

Member

addaleax commented May 26, 2017

the goal is that there is no difference between calling .disable() and never having called require('async_hooks'), but that is not a trivial task and is likely over-optimistic

It shouldn’t be so terribly hard either. Maybe I can take a look after the current bunch of async_wrap PRs are through.

As long as it gets in to node 8 I'm happy either way :)

@matthewloring Yeah, me too. Maybe we should ask @nodejs/collaborators whether they think it’s a good idea to fast-track this? At this point you and @AndreasMadsen seem to be “the” most relevant reviewers for async_hooks by far… (speaking of which, would you mind giving #13142 a look? 😬)

@AndreasMadsen AndreasMadsen referenced this pull request May 26, 2017

Closed

[async_hooks] tracking issue #29

23 of 27 tasks complete

matthewloring and others added some commits May 25, 2017

async_wrap,src: wrap promises directly
Promises do not have any internal fields by default. V8 recently added
the capability of configuring the number of internal fields on promises.
This change adds an internal field to promises allowing promises to be
wrapped directly by the PromiseWrap object. In addition to cleaner code
this avoids an extra object allocation per promise and speeds up promise
creation with async_hooks enabled by ~2x.
async_hooks: fix Promises with later enabled hooks
Assign a `PromiseWrap` instance to Promises that do not have one
yet when the PromiseHook is being called.

Fixes: #13237

@addaleax addaleax referenced this pull request May 27, 2017

Closed

async_wrap,src: wrap promises directly #13224

3 of 4 tasks complete
@addaleax

This comment has been minimized.

Show comment
Hide comment
Member

addaleax commented May 27, 2017

@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax May 28, 2017

Member

Landed in 849f223, 9087700

Member

addaleax commented May 28, 2017

Landed in 849f223, 9087700

@addaleax addaleax closed this May 28, 2017

@addaleax addaleax deleted the addaleax:async-hooks-late-promise branch May 28, 2017

addaleax added a commit that referenced this pull request May 28, 2017

async_wrap,src: wrap promises directly
Promises do not have any internal fields by default. V8 recently added
the capability of configuring the number of internal fields on promises.
This change adds an internal field to promises allowing promises to be
wrapped directly by the PromiseWrap object. In addition to cleaner code
this avoids an extra object allocation per promise and speeds up promise
creation with async_hooks enabled by ~2x.

PR-URL: #13242
Ref: #13224
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

addaleax added a commit that referenced this pull request May 28, 2017

async_wrap: fix Promises with later enabled hooks
Assign a `PromiseWrap` instance to Promises that do not have one
yet when the PromiseHook is being called.

Fixes: #13237
PR-URL: #13242
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Matthew Loring <mattloring@google.com>

jasnell added a commit that referenced this pull request May 28, 2017

async_wrap,src: wrap promises directly
Promises do not have any internal fields by default. V8 recently added
the capability of configuring the number of internal fields on promises.
This change adds an internal field to promises allowing promises to be
wrapped directly by the PromiseWrap object. In addition to cleaner code
this avoids an extra object allocation per promise and speeds up promise
creation with async_hooks enabled by ~2x.

PR-URL: #13242
Ref: #13224
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

jasnell added a commit that referenced this pull request May 28, 2017

async_wrap: fix Promises with later enabled hooks
Assign a `PromiseWrap` instance to Promises that do not have one
yet when the PromiseHook is being called.

Fixes: #13237
PR-URL: #13242
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Matthew Loring <mattloring@google.com>

@jasnell jasnell referenced this pull request May 28, 2017

Closed

8.0.0 Release Proposal #12220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment