Description
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.