-
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
Expensive isTraceHTTPEnable
#81
Comments
@nodejs/performance @nodejs/http |
I don't know if I'd consider it that expensive. But yea, that could be faster. |
This can be cached/hoisted easily in jsland (by patching the Good finding @ronag! |
FWIW, the function is not really part of |
That's probably not sound in general. For example, an embedder can enable the W.r.t. V8's fast API: isTraceCategoryEnabled() and trace() are already V8 builtins. There's probably not much room for improvement there. What should work is expose the uint8_t pointer from function isTraceHTTPEnabled() {
return array[0] > 0; // where |array| is that Uint8Array
} |
I tried code search but I didn't find any use inside built-ins so maybe not a use -case for that. |
Problem
I was doing some performance analysis on my lib and I found the following trace:
The method isTraceHTTPEnable is consuming 58ms to check if the trace is enabled when I process 100k requests with total time of ~7s.
To check if tracing is enabled, this method calls a method inside
internalBinding('trace_events')
to return a boolean, so this slowdown is likely caused by data being passed from the C++ layer to JavaScript.Reproduction
You can reproduce this CPU Profile and learn how to visualize in this repo.
Solutions
The first solution I thought of was to use v8 Fast APIs, I don't know much about that, but from what I've read in the docs, since the return value is just a boolean, I think it's eligible to be used.
I also thought about caching these values but that won't work since the user can enable and disable tracing whenever he wants, as per the documentation
If you think is possible to use v8 Fast APIs, I can try to work on a PR.
The text was updated successfully, but these errors were encountered: