-
Notifications
You must be signed in to change notification settings - Fork 21
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
Worker threads #9
Comments
Can you please include a repro if you can? |
Sure:
This is the profile: In comparison this is how profile looks when profiling the fibonnaci calculation itself, without using worker_threads: Flamecharts generated from the cpuprofiles (using http://github.com/brendangregg/FlameGraph): |
I thought, well, if that doesn't work, I will just run the profiler inside the worker, right? But when I try to run the profile inside the worker, it exits with error |
Not sure if it is related in any way, but there was once this nodejs/node#24016 |
I think it maybe v8 profiler can't work in work threads because isolate is designed not to be thread-safe. But when the work thread feature gets into Stability 2 (now is Stability 1: Experimental), the kernel may have a solution with it :) |
@carera I have a repo that shows what is compatible with worker threads and what is not in terms of profiling. Bear in mind that it is still work in progress: https://github.com/slonka/pprof-nodejs-and-worker-threads/ |
@carera it should be in |
Hi all, so the workers feature is now flagged |
@carera since we can take heap snapshot from parent thread in this OR, I think the implementation for cpu profiling will come soon. |
@hyj1991 I'm interested in profiling worker threads, and was wondering if there any updates to the state of affairs. I had a look through the Node repo and couldn't find any issues/prs to add an equivalent CPU profiling API akin to the heap snapshot one, as it seems they're trying to cover that functionality off with the inspector module. Do you think it would be possible for us to build worker thread profiling on top of the inspector profiling machinery it already has, or do we need something different added to Node? I'm willing to help out implementing this but I'd need a bit of guidance. |
Disclaimer: I did not work on profiling in node.js since sep 2019. @Widdershin here is a working example of profiling inside worker threads using inspector module: https://github.com/slonka/nodejs-production-ready-profiling/blob/master/node-inspector.js |
That's a great reference, thanks @slonka. Just curious, did you run into any issues with the inspector module at any point? My biggest reluctance is that stability banner. |
I vaguely remember talking to some Node.js devs and them saying that it's the preferred method but I can see that the stability did not change: https://nodejs.org/api/inspector.html#inspector_inspector . I would open up an issue and ask them what's the recommended way to profile inside worker threads with an ability to start/stop on demand. |
For what it's worth, |
Ah, I see the problem now. Seems like we need to be context aware! schroffl/node-lzo#11 I'm going to have a go at making |
I managed to make |
Refs:
I will patch it to |
this was done? |
Landed in 8eea608, you can use |
Hi,
thanks for the lib,
next
allows us to profile node12 apps!One question - I noticed job processed on worker_threads is not shown in the profiles. Do you know a way how to work around this?
The text was updated successfully, but these errors were encountered: