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