-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fast path for --no-deprecation
#90
Comments
Hi, I'll be working on this. I will be posting a draft PR with my progress |
@H4ad about the |
@Ceres6 I initially thought the same, but You can still listen for events emitted by With So stopping emitting will likely be a breaking change. What I recommend is to create a PR related to Also, try researching whether anyone has already proposed changing the behavior of |
@H4ad As far as I can see there are no other issues proposing the change. It is weird as per documentation both flags should have the same behaviour (i.e. silence warnings). If that behaviour is not printing to console or not emitting could be discussed. I think this should at least be documented if they are going to have a different behaviour. Anyway I do agree it is probably for the best to keep that in separate PRs. I have a couple options in mind so I will try them with existing benchmarks and then maybe create some. Probably it's worth to compare also without the flag to check we are not sacrificing performance there in order to gain for the other (although I suspect a couple if statements won't affect too much) |
I'm not sure it's relevant to spend any time optimising deprecated features 🤔 if folks want performance, they should use not-deprecated APIs, I don't really get who'd be benefitting from an optimised |
@aduh95 In parts I agree with you, but I see this problem as an entry level to do optimizations in node, you don't need to change C++ code or have a deep understanding of node to be able to help. And as for people benefiting directly, if this change improves module loading or any other part by a few percentages, then adding a new flag might be worth someone's effort. |
@aduh95 as I see it that you are not optimizing for performance doesn't mean that you want a system as performant as possible. Besides there are a number of reasons for using deprecated APIs such as having a legacy system with thousands of calls to those APIs that you cannot invest the time needed to refactor |
Maybe some pre-work before investing time in optimizing this code path would be to implement trace events or perf hooks for deprecation warning calls. Or even just taking a flamegraph of production systems to identify if those are incurring any significant overhead. That way, improving the code path for Having that data, especially in a production system, would also be helpful to advocate for landing such changes whenever someone opens a PR for it. Otherwise, it might be a hard sell if the changes incur significant increase in complexity code for insignificant performance gains in real systems. |
About the fast path
In the code of
process.emitWarning
, deprecations are ignored when--no-deprecation
flag is passed (reference).Instead of creating the warning object and then discarding when the flag is true, we could just check earlier and just skip the rest of the method when
type
isDeprecationWarning
.There are some places that could benefit from this tiny change.
Going further with improvements
What if we add guards to those places to avoid any computation at all when
--no-deprecation
is true?I did some experiments with
esm internal resolve
and by putting an if guard forprocess.noDeprecation
on line 106, and the results is not that bad:I think the results could be even better, this benchmark is a little bit flaky as you can see by theaccuracy
.What about --no-warnings?
Well, at first I thought we could do the same for
--no-warnings
, add an if statement and avoid callingprocess.emitWarning
, but NodeJS just unsubscribe the listener when--no-warnings
is set , but they won't stop the event from being emitted, also, there are MANY places whereprocess.on('warning
is used, so I don't think we could do anything here.Conclusion
So, in the end, we have two questions:
noDeprecation
before the object creation?The text was updated successfully, but these errors were encountered: