-
Notifications
You must be signed in to change notification settings - Fork 812
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
Thread Names not updating with collapsed output #511
Comments
One Java thread has one name in async-profiler reports. |
Is there any way to get the thread name assigned to the sample when the sample is taken rather than when the profiling is completed? After reading a bit about this: #106 It looks like JFR was introduced to be able to keep the timestamps of individual samples. If I switch JFR will it also maintain the thread name from the point of the sample? Or is does it just maintain a reference to the thread and I will get whatever name happens to exist at the time that I collect the sample? |
In JFR format, thread names are obtained in the same way. |
Any ideas or hints on where to adjust things to try to maintain the thread name that existed at the point of sample? I believe I understand that it's impossible to eliminate races and it's clear that it would add to the overhead in terms of CPU and memory, but wondering what part of the code would need to be adjusted to be able to even support this? |
Current data model of the profiler implies at most one instance of a given thread (i.e. Java thread can't have more than one identifier). |
I was looking through the code a bit more to try to figure out where this would happen. It looks like the threadId is pushed onto the stack at And then read back out at I understand now that ThreadMap is the map of thread id to the name. So, it's clear that in the profiler you are just grabbing the thread id and then using that to get the name of the thread in the frameName code. The actual updating of the It seems like it should be possible to implement something that keeps track of the thread name at time of sample by
I'm not well versed in C nor in jvmti so not really sure how easy the above things are. The open questions in my mind are
Does this cover the architectural modifications you were talking about? Or is there something I'm missing? |
|
I have an Java application that uses an Executor to parallelize work. Before each chunk of work, the Runnable renames the worker thread based on the task that it is accomplishing and then resets the name at the end of its work. When I use async-profiler externally, it looks like it connects via MXBeans and takes thread dumps, which end up having the renamed thread names. This is very useful as I often want to focus in on one specific task. But when I run the profiler as an agent using the command and dumping collapsed output
The thread names all seem to be the original ThreadFactory-assigned thread names. I tried to look through the code and I think it's caching the thread names based on the OS thread id, so it's only getting the first name that it sees and then that's sticky forever after. I'm wondering if there is any sort of flag, configuration or other method of dumping that would preserve the JVM thread name at the point that the sample is taken and work when running as an agent.
The text was updated successfully, but these errors were encountered: