Node: Error.captureStackTrace() performance regression in v7.x

Created on 13 Feb 2017  路  7Comments  路  Source: nodejs/node

  • 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.

V8 Engine performance

Most helpful comment

@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.

All 7 comments

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.

Does this performance regression actually affect anything in production?

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

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

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

@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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

filipesilvaa picture filipesilvaa  路  3Comments

srl295 picture srl295  路  3Comments

dfahlander picture dfahlander  路  3Comments

Icemic picture Icemic  路  3Comments

sandeepks1 picture sandeepks1  路  3Comments