-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Profiling using --prof inside worker_threads does not work #24016
Comments
@nodejs/workers |
Also, running
With a different line on every try. |
Maybe @bnoordhuis or somebody else in @nodejs/v8 could know how this would work? |
|
Thanks for the write-up, good bug report! I can reproduce on macos, still need to check other platforms. I used the reduced test case below: 'use strict';
const {Worker, isMainThread, parentPort} = require('worker_threads');
function work() {
const fib = n => n <= 1 ? 1 : fib(n-1) + fib(n-2);
for (let i = 0; i < 1e4; i++) {
process.x = fib(1 + i%24);
if (parentPort) parentPort.postMessage(process.x);
}
}
work(); // both threads
if (isMainThread) new Worker(__filename).on('message', console.log); When run with
I'll investigate this week. The low number of ticks (3) clearly suggests profiling somehow isn't working. |
Hi @bnoordhuis - I'm very interested in learning more about the internals of node / v8 so if you would be open to doing some "pair debugging" I'd love to see how you takle a problem like this. |
I did some quick debugging and discovered that @addaleax You probably have ideas on how easy it is to move isolate creation to the new thread. I'm guessing 'not that easy'? I suppose an alternative is to petition V8 to untangle isolate creation and starting the profiler; I'm fairly sure the call to @slonka My style of debugging isn't all that advanced, I just read the code and crack open gdb or add some printf statements. :-) |
@bnoordhuis - I just want to see how other people work and learn from them. I fully understand if you don't have time / don't want to :) |
I think it might be nice to move Isolate creation to the new thread anyway – in part so that we don’t spend the time for that while on the parent thread – but yes, it’s a bit more comfortable to do it this way. I’ll look into that as a first option. |
#26011 should resolve this – thanks for the debugging, @bnoordhuis! |
Refs: nodejs#24016 PR-URL: nodejs#26011 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Refs: #24016 PR-URL: #26011 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Fixes: #24016 PR-URL: #26011 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Generating flame graphs with worker_thread produces isolate files that do not contain useful information.
Using my example repo https://github.com/slonka/nodejs-prof-worker-threads-not-working i generated the following flame graphs for:
Single threaded version:
And worker threads version:
What makes me think that this is a bug inside
node
and not0x
is that isolate files and processed files (generated by runningnode --prof-process
) contain pretty much the same info that is on the flame graphs. I used flame graphs because they are easier to read for me.The text was updated successfully, but these errors were encountered: