-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
doc: warn about using util.inspect/util.format in prod #17791
Conversation
Two questions: Isn't Second, and I know this is an unpopular opinion, but can we remove These are non-blocking questions. I don't intend to demand an answer before this lands or anything. Just trying to offer some helpful suggestions. |
I think the |
LGTM but I would probably make the warning for |
I am confused by these comments. I recently optimized both functions in e.g. #14881 #14492 #15422 and when looking at the history, others optimized Right now there is likely little that can be done to further improve the performance of those functions. It should also not be much of a performance issue depending on the user input. If a huge array is inspected, it is indeed a lot of work. The problem in that case is that |
Yes, they've been optimized about as much as they can be but they are still something that should never be used in hot paths. That's not what they've been optimized for and not what they are intended for. I've seen this pop up in flame graphs as a significant bottleneck a number of times (as recently as this morning in fact, which is what prompted this PR now). |
Well, using it in a hot code path is not really smart (and I wonder what they did - but that is another story). But the wording oft this should be different out of my perspective. What about e.g. Please note that `util.format()` is a synchronous method that is mainly intended
as debugging tool. Depending on the values to format it could have a significant
performance overhead that would block the event loop. Use this function
therefore with care and never in a hot code path. |
doc/api/util.md
Outdated
@@ -250,6 +250,11 @@ without any formatting. | |||
util.format('%% %s'); // '%% %s' | |||
``` | |||
|
|||
It is immportant to note that `util.format()` is a synchronous method that is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/immportant/important
(also below)
@BridgeAR ... PTAL now :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but it needs to be rebased already.
Because of the potential performance bottlenecks that may be introduced by `util.inspect()` and `util.format()` in production hot path code. Based on real user feedback, it is not obvious that these are intended to be debugging tools.
6d3c6b8
to
680b659
Compare
Rebased :-) |
Because of the potential performance bottlenecks that may be introduced by `util.inspect()` and `util.format()` in production hot path code. Based on real user feedback, it is not obvious that these are intended to be debugging tools. PR-URL: #17791 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Landed in a4f44ac |
This does not land cleanly on v9.x, would someone be willing to manually backport? |
Because of the potential performance bottlenecks that may be introduced by `util.inspect()` and `util.format()` in production hot path code. Based on real user feedback, it is not obvious that these are intended to be debugging tools. PR-URL: #17791 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Trivial conflict. Landed in 742b304. |
Because of the potential performance bottlenecks that may be introduced
by
util.inspect()
andutil.format()
in production code.Based on real user feedback, it is not obvious that these are intended
to be debugging tools.
/cc @mcollina @lucamaraschi
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
doc