-
Notifications
You must be signed in to change notification settings - Fork 294
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
Add V8 cross-thread profiling patches #2227
Add V8 cross-thread profiling patches #2227
Conversation
V8's profiler does not expect isolates to be locked from different threads. Pull request #710 moved inspector protocol handling to a separate thread, meaning profiling was started and stopped on the inspector thread, not the Worker's request connection thread. If I remember right, the result of this is that the profiler ends up sampling the inspector thread, which doesn't normally run JavaScript, and causes a bunch of "(program)" placeholder spans to show up in the profile. We previously discovered this issue with our internal runtime, which has always been heavily multi-threaded, and patched around the problem. This commit copies the two relevant patches from our internal repo. Fixes #1754.
This seems a bit surprising -- the inspector protocol seems explicitly designed to run from a different thread, in order to support breakpoint debugging (which suspends the execution thread?). (But hey if it works, ship it.) |
I guess our patches are Linux-specific: Mac:
Windows failed for a separate, probably spuriuos reason about an unexpected clang version, which I think @jasnell mentioned in chat. Presumably it won't appreciate
|
It looks like it suspends execution by calling this workerd/src/workerd/io/worker.c++ Lines 406 to 411 in 6a57e25
|
Could we perhaps actually deliver the profiler start/stop messages over to the isolate thread, rather than trying to start the profiler cross-thread? |
This is done in #2497. |
V8's profiler does not expect isolates to be locked from different threads. Pull request #710 moved inspector protocol handling to a separate thread, meaning profiling was started and stopped on the inspector thread, not the Worker's request connection thread. If I remember right, the result of this is that the profiler ends up sampling the inspector thread, which doesn't normally run JavaScript, and causes a bunch of "(program)" placeholder spans to show up in the profile.
We previously discovered this issue with our internal runtime, which has always been heavily multi-threaded, and patched around the problem. This commit copies the two relevant patches from our internal repo.
Fixes #1754.