Skip to content

errors: improve error creation performance#46648

Closed
BridgeAR wants to merge 15 commits into
nodejs:mainfrom
BridgeAR:improve-error-performance
Closed

errors: improve error creation performance#46648
BridgeAR wants to merge 15 commits into
nodejs:mainfrom
BridgeAR:improve-error-performance

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

This is a first step to significantly faster NodeErorrs. The code itself should also be cleaned up in a following PR but it already became bigger as I worked upon different parts related to errors in Node.js.

This does change stack traces for users in few cases: originally we added extra stack frames to compensate for stack frames we want to hide. The mechanism as it was implemented had a high cost on all Node.js errors in case they were created in a deeply nested function. Stack frames that are removed are now not going to be compensated for anymore. I am going to think about other ways to do this later on again.

Refs: nodejs/performance#40

                                                                        confidence improvement accuracy (*)   (**)   (***)
error/hidestackframes.js nested=0 n=10000 type='direct-call-noerr'                      0.52 %       ±5.47% ±7.30%  ±9.56%
error/hidestackframes.js nested=0 n=10000 type='direct-call-throw'             ***     81.31 %       ±7.21% ±9.66% ±12.72%
error/hidestackframes.js nested=0 n=10000 type='hide-stackframes-noerr'                 2.66 %       ±6.63% ±8.83% ±11.49%
error/hidestackframes.js nested=0 n=10000 type='hide-stackframes-throw'        ***     79.61 %       ±6.63% ±8.87% ±11.66%
error/hidestackframes.js nested=1 n=10000 type='direct-call-noerr'                      0.21 %       ±3.57% ±4.76%  ±6.19%
error/hidestackframes.js nested=1 n=10000 type='direct-call-throw'             ***     90.10 %       ±5.93% ±7.93% ±10.40%
error/hidestackframes.js nested=1 n=10000 type='hide-stackframes-noerr'                -2.34 %       ±4.07% ±5.42%  ±7.06%
error/hidestackframes.js nested=1 n=10000 type='hide-stackframes-throw'        ***     85.71 %       ±6.18% ±8.23% ±10.73%
error/node-error.js type='node' n=100000                                       ***    166.64 %       ±7.01% ±9.39% ±12.35%
error/node-error.js type='regular' n=100000                                            -2.29 %       ±2.98% ±3.97%  ±5.16%

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js. stalled Issues and PRs that are stalled.

Projects

None yet

Development

Successfully merging this pull request may close these issues.