-
Notifications
You must be signed in to change notification settings - Fork 7.3k
src: expose libuv handle/req id on process object #8090
Conversation
I think for now we should postpone landing this PR until after the meeting on friday, though most of us had already converged on something similar to this concept |
I understand that @othiym23 pointed out that management of IDs is problematic if there is no close event notification so I've added that (for handles) in commit af669a5. Does it make sense to do the same thing for requests? They have a clearly delineated life cycle (they "close" when the callback is made) so it didn't seem that useful to me. |
@bnoordhuis Let's wait until after #8110 lands. The JS that's being removed (including the JS that wasn't merged in from my update) assigned a unique id in JS (see https://github.com/trevnorris/node/blob/remove-al-js/src/async-wrap-inl.h#L87). Though it would only assign a unique ID to the Do you still want a unique id to be assigned to every instance, despite whether it's being traced or not? |
@bnoordhuis I've added a commit that still assigns a new unique id to every The performance for retrieving the value is minimal on the JS side (sub 20ns), and is less expensive than setting an object property in C++. |
With this proposed ability to track callbacks, it would also be very useful/helpful to have a method to list and inspect all of the callbacks currently scheduled for execution (i.e. to iterate through them). |
@mjsalinger Do |
Assign numeric identifiers to libuv handle and request wrappers and expose them to JS land as process._uvContextId[0]. Provides an ersatz "thread-local" state for tracking execution across asynchronous calls. Future optimization: reuse identifiers so they keep fitting in a SMI?
Called whenever a libuv handle is closed. The callback receives a single argument, the id of the handle that was closed.
af669a5
to
048125b
Compare
@bnoordhuis ... any further thoughts on this? is it still necessary? |
We can revisit this, it's useful, but I'll close it for now. |
Assign numeric identifiers to libuv handle and request wrappers and
expose them to JS land as process._uvContextId[0]. Provides an ersatz
"thread-local" state for tracking execution across asynchronous calls.
Future optimization: reuse identifiers so they keep fitting in a SMI?
R=@trevnorris?
This PR is a conversation starter. The goal is to have a cheap way of tracking the flow of execution across callbacks for instrumentation purposes.