Skip to content
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

benchmark: fix error on server close in AsyncLocalStorage benchmark #32503

Conversation

puzpuzpuz
Copy link
Member

@puzpuzpuz puzpuzpuz commented Mar 26, 2020

Fixes AsyncLocalStorage type from benchmark/async_hooks/async-resource-vs-destroy.js by adding undefined check for the store (CLS context). Before this fix it could fail when the server is closed (and ALS instance is disabled), which may lead to calls to getCLS() method of the benchmark in the following part of the request handling code:

   setTimeout(() => {
      // the server may be already closed when this (and the next one) callback is run
      readFile(__filename, () => {
        res.setHeader('content-type', 'application/json');
        res.end(JSON.stringify({ cls: getCLS() }));
      });
    }, 10);

Other types within the benchmark already had similar checks, so that's why they weren't failing.

  • Also removes redundant checks from executionAsyncResource type. Reason: the final implementation of executionAsyncResource() never returns null.
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added async_hooks Issues and PRs related to the async hooks subsystem. benchmark Issues and PRs related to the benchmark subsystem. labels Mar 26, 2020
@puzpuzpuz puzpuzpuz changed the title benchmark: fix error on server close in ALS benchmark benchmark: fix error on server close in AsyncLocalStorage benchmark Mar 26, 2020
@puzpuzpuz puzpuzpuz force-pushed the fix-async-resource-vs-destroy-benchmark branch from 7fda473 to 39374a2 Compare March 26, 2020 12:22
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mhdawson mhdawson added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 1, 2020
@mhdawson
Copy link
Member

mhdawson commented Apr 1, 2020

CI run: https://ci.nodejs.org/job/node-test-pull-request/30348/

@nodejs-github-bot
Copy link
Collaborator

@puzpuzpuz puzpuzpuz force-pushed the fix-async-resource-vs-destroy-benchmark branch from 39374a2 to 2239ecb Compare April 2, 2020 07:47
@puzpuzpuz
Copy link
Member Author

The test failure in test/node-api/test_buffer/test.js seems unrelated, but I did a rebase over the latest master, as it may be already fixed.

@nodejs-github-bot
Copy link
Collaborator

@mcollina
Copy link
Member

mcollina commented Apr 2, 2020

Landed in 7e664a5

@mcollina mcollina closed this Apr 2, 2020
mcollina pushed a commit that referenced this pull request Apr 2, 2020
PR-URL: #32503
Reviewed-By: Vladimir de Turckheim <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@puzpuzpuz puzpuzpuz deleted the fix-async-resource-vs-destroy-benchmark branch April 2, 2020 12:59
@puzpuzpuz
Copy link
Member Author

v12.x backport PR: #32318

BethGriggs pushed a commit that referenced this pull request Apr 7, 2020
PR-URL: #32503
Reviewed-By: Vladimir de Turckheim <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
targos pushed a commit that referenced this pull request Apr 12, 2020
PR-URL: #32503
Reviewed-By: Vladimir de Turckheim <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
puzpuzpuz added a commit to puzpuzpuz/node that referenced this pull request Apr 14, 2020
PR-URL: nodejs#32503
Reviewed-By: Vladimir de Turckheim <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@targos targos removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 25, 2020
targos pushed a commit to targos/node that referenced this pull request Apr 25, 2020
PR-URL: nodejs#32503
Reviewed-By: Vladimir de Turckheim <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
targos pushed a commit that referenced this pull request Apr 28, 2020
PR-URL: #32503
Reviewed-By: Vladimir de Turckheim <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async_hooks Issues and PRs related to the async hooks subsystem. benchmark Issues and PRs related to the benchmark subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AsyncLocalStorage benchmark broken
8 participants