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

Error.captureStackTrace() performance regression in v7.x #11343

Closed
mrtbld opened this issue Feb 13, 2017 · 7 comments
Closed

Error.captureStackTrace() performance regression in v7.x #11343

mrtbld opened this issue Feb 13, 2017 · 7 comments
Labels
performance Issues and PRs related to the performance of Node.js. v8 engine Issues and PRs related to the V8 dependency.

Comments

@mrtbld
Copy link

mrtbld commented Feb 13, 2017

  • Version: v7.5.0
  • Platform: Fedora release 23 (Twenty Three) Linux 4.8.13-100.fc23.x86_64
  • Subsystem: errors, v8

Error.captureStackTrace() is about 10 times slower in v7.5.0 than in v6.9.5.

$ nvm use v6.9.5
Now using node v6.9.5 (npm v3.10.10)
$ node -e 'console.time(); for (var i = 10000; i--;) Error.captureStackTrace({}); console.timeEnd()'
undefined: 20.596ms

$ nvm use v7.0.0
Now using node v7.0.0 (npm v3.10.8)
$ node -e 'console.time(); for (var i = 10000; i--;) Error.captureStackTrace({}); console.timeEnd()'
undefined: 143.613ms

$ nvm use v7.5.0
Now using node v7.5.0 (npm v4.1.2)
$ node -e 'console.time(); for (var i = 10000; i--;) Error.captureStackTrace({}); console.timeEnd()'
undefined: 201.507ms

$ grep 'model name' /proc/cpuinfo | head -1
model name: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz

In particular this impacts bluebird in NODE_ENV=development i.e. when longStackTraces are active.

@addaleax addaleax added performance Issues and PRs related to the performance of Node.js. v8 engine Issues and PRs related to the V8 dependency. labels Feb 13, 2017
@bnoordhuis
Copy link
Member

Known V8 issue: https://bugs.chromium.org/p/v8/issues/detail?id=5962

Not much we can do except perhaps back-port the fix once it materializes.

@hashseed
Copy link
Member

Does this performance regression actually affect anything in production?

@vmarchaud
Copy link
Contributor

@hashseed Module that instrument production code use it to retrieve userspace callsite (opbeat for example)

@hashseed
Copy link
Member

I see. Is it possible to subclass Error to achieve the same?

@Trott
Copy link
Member

Trott commented Jul 26, 2017

Closing because v7.x is EOL. Please comment or re-open if this should remain open. Thanks!

@Trott Trott closed this as completed Jul 26, 2017
@alangpierce
Copy link

@Trott this is still an issue on node 8. This microbenchmark takes about 3 seconds on node 8.2.1 and about 370ms on node 6.11.1:

for (let i = 0; i < 100000; i++) {
  Error.captureStackTrace({});
}

That said, the issue was recently fixed in V8: https://bugs.chromium.org/p/v8/issues/detail?id=5962

So this will be fixed whenever node pulls in the fix.

@Trott Trott reopened this Jul 27, 2017
targos added a commit to targos/node that referenced this issue Sep 13, 2017
Original commit message:

    [error] Lazy stack trace formatting for Error.captureStackTrace

    This reinstates the old behavior of Error.captureStackTrace prior to
    4feafee9d9.  Like the builtin Error constructors, captureStackTrace now formats
    the stack trace lazily once it is accessed.

    Bug: v8:5962
    Change-Id: I03821b73d26b7b40809a1fea98f9c820bfa05d6b
    Reviewed-on: https://chromium-review.googlesource.com/574530
    Reviewed-by: Camillo Bruni <cbruni@chromium.org>
    Commit-Queue: Jakob Gruber <jgruber@chromium.org>
    Cr-Commit-Position: refs/heads/master@{nodejs#46727}

Fixes: nodejs#13048
Fixes: nodejs#11343
@BridgeAR
Copy link
Member

This is fixed on master. As soon as v8 6.1 is merged and released (very soon) it is going to be fine again.

I am therefore closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Issues and PRs related to the performance of Node.js. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

8 participants