Comments (16)
This just bit me today. Please update the README to mention that -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints
is necessary if attaching to a running process.
from async-profiler.
@apangin , the README hadn't updated for -XX:+DebugNonSafepoints
yet :)
from async-profiler.
For Honest Profiler there is no need to add the option as the presence of the agent on JVM load will auto enable it (the agent is loaded with VM not attached to running process). For Async-Profiler the parameter is required if the agent is attaching to an already running process.
from async-profiler.
Thanks for the clarification.
from async-profiler.
@nitsanw is '-XX:+DebugNonSafepoints' required? Async Profiler has alread enabled JvmtiExport::should_post_compiled_method_load(), which should be good enough to make the jvm to record non-safepoints:
./src/share/vm/code/debugInfoRec.cpp-82-static inline bool compute_recording_non_safepoints() {
./src/share/vm/code/debugInfoRec.cpp-83- if (JvmtiExport::should_post_compiled_method_load()
./src/share/vm/code/debugInfoRec.cpp:84: && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
./src/share/vm/code/debugInfoRec.cpp-85- // The default value of this flag is taken to be true,
./src/share/vm/code/debugInfoRec.cpp-86- // if JVMTI is looking at nmethod codes.
./src/share/vm/code/debugInfoRec.cpp-87- // We anticipate that JVMTI may wish to participate in profiling.
./src/share/vm/code/debugInfoRec.cpp-88- return true;
./src/share/vm/code/debugInfoRec.cpp-89- }
./src/share/vm/code/debugInfoRec.cpp-90-
./src/share/vm/code/debugInfoRec.cpp-91- // If the flag is set manually, use it, whether true or false.
./src/share/vm/code/debugInfoRec.cpp-92- // Otherwise, if JVMTI is not in the picture, use the default setting.
./src/share/vm/code/debugInfoRec.cpp-93- // (This is true in debug, just for the exercise, false in product mode.)
./src/share/vm/code/debugInfoRec.cpp:94: return DebugNonSafepoints;
./src/share/vm/code/debugInfoRec.cpp-95-}
I think this is how Honest Profile works as well.
from async-profiler.
@lic9 The option is not needed if the agent is loaded at JVM startup (by using -agentpath
option), but it is desired (though not required) if the agent is attached at run time. CompiledMethodLoad
JVMTI event enables debug info, but only for methods compiled after the event is turned on.
from async-profiler.
@apangin Thanks for confirmation! That makes sense.
BTW, since Async Profiler does not have line number, '-XX:+DebugNonSafepoints' would only affect inlined method right? For example, method_A inlined method_B, and the hottest code is in method_B. Because method_B is inlined and the safepoint on method exit is omitted, Async Profiler will only show stack trace 'root/method_A' instead of 'root/method_A/method_B'.
from async-profiler.
@lic9 You're right: without DebugNonSafepoints
there is a high chance that simple inlined methods will not appear in the profile.
from async-profiler.
@apangin would that also bias the results? Skimming the code, it seems like async profiler will drop samples whose _asyncGetCallTrace() returns negative num_frames and could not pop off top frame. This could happen to all Java stacktraces that have no decipherable compiled frame (no associated PcDesc at the specific pc or nearby pc due to missing _recording_non_safepoints option). In other words, only pc at safepoint or before safepoint could be recorded. Is that correct? If so it is better to show them as unknown or unwalkable instead of dropping them? Thanks!
from async-profiler.
@lic9 The absense of DebugNonSafepoints
should not cause omission of samples. At least the enclosing Java frame can be recovered.
Even when something goes wrong, the samples with incomplete stack traces are counted and reported in summary.
from async-profiler.
@apangin I see. Those failed cases are recorded as 'Unknown (native/Java)' in plain text result but not shown on flamegraph. Thanks for the explanation!
But I think in that case, flamegraph is skewed. I built a jdk8 by making 'find_initial_Java_frame()' in src/share/vm/prims/forte.cpp always return false so no Java frame would be available from the async api. Flamegraph does not show anything about those unknown or unwalkable java stacks, and might mislead users to think that all time was spent in those native methods. Is it better to add those unknown/unwalkable counts to root and make a rectangle on top of it?
from async-profiler.
@lic9 Sounds reasonable. Can you please open a separate issue for this?
from async-profiler.
@apangin Sure I will open a new issue and create a patch. Thanks!
from async-profiler.
@calvin1978 Would you like to update it?
from async-profiler.
How about this?
#152
from async-profiler.
@jodzga Thank you! I've merged the proposed addition.
from async-profiler.
Related Issues (20)
- [ERROR] Could not set pthread hook HOT 5
- java.lang.NoSuchMethodError when calling jfr2flame with jdk 8 HOT 1
- `timeout` in native mode does not work HOT 2
- Segfault on start when native mode profiling HOT 3
- The Java wrapper is unable to collect data from Java_sun_nio_ch_IOUtil_makePipe HOT 2
- Crash inside ElfParser::ElfParser HOT 1
- Async Profiler and Java Flight Recorder are missing some methods at the bottom of the stack. HOT 16
- build failed. HOT 4
- Dear Andrei, when will we release 2.10? HOT 8
- Running jfr2flame on concatenated JFR files produces nonsense stacktraces HOT 4
- is https://github.com/async-profiler/async-profiler/issues/154 already fixed in latest async profiler? HOT 3
- Thread filter in wallclock HOT 3
- `unknown_Java` during profiling on M1 macbook HOT 3
- Target application crashes during profiling on M1 macbook HOT 5
- async-profiler can't find process by name when CPU is overloaded HOT 3
- Accurate CPU sampling without perf_events HOT 1
- [JDK22] `jfr2flame` errors out with `Invalid string encoding` when converting to flame graph HOT 3
- How can I get time in flamegraph? HOT 1
- is it possible to get class imported jar version? HOT 1
- Crash in WallClock::getThreadState HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from async-profiler.