console,internal/errors: improve error perf#13743
console,internal/errors: improve error perf#13743BridgeAR wants to merge 2 commits intonodejs:masterfrom
Conversation
lib/console.js
Outdated
There was a problem hiding this comment.
Perhaps we can keep the more descriptive variable name here (err)?
There was a problem hiding this comment.
I think it's not really a typical error anymore but I do not have any strong feelings.
TimothyGu
left a comment
There was a problem hiding this comment.
Code changes LGTM. Commit message-wise, I'd prefer if it addresses what is changed rather than what are the results of the changes.
Using a object instead of an Error is sufficient as the Error itself won't be used but only the stack trace that would otherwise be created twice. This improves the overall .trace() performance.
Newer v8 versions exclude the constructor from the stack trace so the recalculation of the trace can be avoided.
932788a to
e16faad
Compare
|
I changed the commit messages. |
| constructor(key, ...args) { | ||
| super(message(key, args)); | ||
| this[kCode] = key; | ||
| Error.captureStackTrace(this, NodeError); |
There was a problem hiding this comment.
I'm -1 on removing this line. The fact that NodeError is being used in here should not be visible to the end user. This intentionally removes that frame from the stack trace to provide that transparency.
There was a problem hiding this comment.
The frame is not visible because newer v8 versions remove the constructor frame by default.
That's the reason why I removed the Error.captureStackTrace call. Do you maybe know a better description for the commit message to make it clearer?
There was a problem hiding this comment.
I checked all other occurrences as well and they are always needed besides here.
There was a problem hiding this comment.
oh nice... I knew that change was coming but I wasn't expecting it until 6.x for some reason. :-) ... that's a happy surprise. I withdraw the objection then!
Using a object instead of an Error is sufficient as the Error itself won't be used but only the stack trace that would otherwise be created twice. This improves the overall .trace() performance. PR-URL: #13743 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Newer v8 versions exclude the constructor from the stack trace so the recalculation of the trace can be avoided. PR-URL: #13743 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
|
Quick sanity of |
Using a object instead of an Error is sufficient as the Error itself won't be used but only the stack trace that would otherwise be created twice. This improves the overall .trace() performance. PR-URL: #13743 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Newer v8 versions exclude the constructor from the stack trace so the recalculation of the trace can be avoided. PR-URL: #13743 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Using a object instead of an Error is sufficient as the Error itself won't be used but only the stack trace that would otherwise be created twice. This improves the overall .trace() performance. PR-URL: #13743 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Newer v8 versions exclude the constructor from the stack trace so the recalculation of the trace can be avoided. PR-URL: #13743 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Using a object instead of an Error is sufficient as the Error itself won't be used but only the stack trace that would otherwise be created twice. This improves the overall .trace() performance. PR-URL: #13743 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Newer v8 versions exclude the constructor from the stack trace so the recalculation of the trace can be avoided. PR-URL: #13743 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Using a object instead of an Error is sufficient as the Error itself won't be used but only the stack trace that would otherwise be created twice. This improves the overall .trace() performance. PR-URL: #13743 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Newer v8 versions exclude the constructor from the stack trace so the recalculation of the trace can be avoided. PR-URL: #13743 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
This increases the performance for
console.traceand creating a new NodeError by factor 2-3.Newer v8 versions exclude the constructor from the stack trace
so the recalculation of the trace can be avoided.
Using a object instead of an Error is sufficient for console.trace as the Error
itself won't be used but only the stack trace that would
otherwise be created twice.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
console, internal/errors