jvm-profiling-tools / honest-profiler

A sampling JVM profiler without the safepoint sample bias
https://github.com/RichardWarburton/honest-profiler/wiki
MIT License
1.25k stars 146 forks source link

Add thread name logging using JVMTI data #73

Open nitsanw opened 9 years ago

nitsanw commented 9 years ago

This can help annotate the thread ids.

RichardWarburton commented 9 years ago

JavaThread::thread_from_jni_environment(env_id)) is the method to call.

nitsanw commented 8 years ago

Consider the following course of action: Handle ThreadStart/End by agent On ThreadStart: use a lock free map to map thread* and thread's jvmtiEnv_, notify logwriter via queue to log jthread info using GetThreadInfo (requires jthread and jvmtiEnv) On ThreadEnd: remove thread* from map, notify log_writer via queue to log thread end On PROF signal: use the map to get jvmtiEnv*, this would help resolve issues on JVMs where GetEnv is not async safe. In log writer: emit thread start/end entries with threadId to name mapping

This seems like a more correct use of the JVMTI API to acquire the env and thread info. This requires the inclusion of a lockfree c++ map in Honest-Profiler