benchmark: add benchmark utility for Error instance#61180
benchmark: add benchmark utility for Error instance#61180mertcanaltin wants to merge 9 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
RafaelGSS
left a comment
There was a problem hiding this comment.
I'm not confident about how useful this benchmark is
benchmark/util/is-native-error.js
Outdated
|
|
||
| bench.start(); | ||
| for (let iteration = 0; iteration < n; iteration++) { | ||
| func(arg); |
There was a problem hiding this comment.
This is likely being optimized.
There was a problem hiding this comment.
Hi, I tried to fix this by using more arguments and variable arguments. 5fcf423
Any recommendations? |
benchmark/util/is-native-error.js
Outdated
|
|
||
| const func = { native: util, js: types }[version].isNativeError; | ||
|
|
||
| const testArgs = [args[argument], args[argument], args[argument]]; |
There was a problem hiding this comment.
Any reason for this? If I'm reading correctly, the elements are all equals.
There was a problem hiding this comment.
I wanted to provide more arguments.
There was a problem hiding this comment.
With
const testArg = testArgs[iteration % 3];
func(testArg)below, I'm still not sure I understand.
There was a problem hiding this comment.
You're right, it could be misleading for them all to be the same I changed them with different arguments.
9de3f6f
now "%3" alternative I use testArgs.length
There was a problem hiding this comment.
After the latest changes, I got a test failure because the benchmark was running with three configurations instead of the expected one or two. I’ve updated the code so each run uses only a single argument, matching the test infrastructure’s requirements. FYİ @RafaelGSS
| const util = common.binding('util'); | ||
| const types = require('internal/util/types'); | ||
|
|
||
| const func = { native: util, js: types }[version].isNativeError; |
There was a problem hiding this comment.
it is deprecated but still supported - we should still not regress on stable releases and this change ensures that @RafaelGSS
There was a problem hiding this comment.
But, what's the point of this benchmark? I mean, if we see util/isNativeError is slower, what it means afterall? Which API will be directly impacted besides the deprecated API?
There was a problem hiding this comment.
This comparison ensures that existing users will not experience performance drops or unexpected slowdowns until the API is completely removed. It also aims to provide a reference for future changes or alternatives.
RafaelGSS
left a comment
There was a problem hiding this comment.
I'm -1 on this for the reasons I mentioned in #61180 (comment).
We are trying to make the whole benchmark suite faster with more meaningful results and it's not clear to me what outcome we expect from this benchmark - keep in mind this is a deprecated API.
|
Isn't the answer 'modularity' ? E.g., have a set of core benchmarks that are tracked... E.g., core functionality that one does not want to get slower... And then other sets of benchmarks that are selectively run. |
@lemire That would only work if we had sufficient patterns to identify which 'module' to run based on each change. Currently, we don't have any mechanism that identifies: if someone changes the file/function/column X, which benchmark suite I would need to run to guarantee no regression. We can only run the full set. |
|
Thank you all for your comments. @lemire, would you like to comment here? #61180 (comment) |
|
@RafaelGSS I understand your concern about adding benchmarks for deprecated APIs. However, this benchmark isn't solely about isNativeError itself. helps us: If you still think this doesn't justify the benchmark, I'm open to closing this PR and revisiting it when the logger API implementation is more concrete. What do you think? |
Why would we use the
If that's necessary for #60469, I suggest including this commit in that PR instead - and make it meaningful. |
Thanks for your comments, @RafaelGSS I'll move this to the PR where the logger API is and make it meaningful by comparing different error detection approaches. |
added benchmark code for isNativeError function
for: #60468 (comment)