Last active
November 24, 2020 02:55
-
-
Save bugcy013/335183b8e38d76afcc62f4191660e8d8 to your computer and use it in GitHub Desktop.
Java profiling # https://cloud.google.com/profiler/docs/profiling-java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent.tar.gz | tar xzv | |
| NOTICES | |
| profiler_java_agent.so | |
| libdataflow_profiler.jar | |
| $ cat Test.java | |
| public class Test { | |
| private static void foo() { | |
| while (true) {} | |
| } | |
| public static void main(String[] argv) { | |
| foo(); | |
| } | |
| } | |
| $ javac Test.java | |
| $ java -agentpath:./profiler_java_agent.so=-logtostderr,-cprof_profile_filename=$PWD/profile_,-cprof_interval_sec=5,-cprof_duration_sec=10 Test | |
| I0402 20:39:35.742357 140989 entry.cc:207] Profiler agent loaded | |
| I0402 20:39:35.742499 140989 entry.cc:103] Prepare JVMTI | |
| I0402 20:39:35.788872 140989 entry.cc:67] On VM init | |
| I0402 20:39:35.789932 141005 throttler_timed.cc:61] Will save profiles to the local filesystem | |
| I0402 20:39:35.789958 141005 throttler_timed.cc:75] sampling duration: cpu=10s, wall=10s | |
| I0402 20:39:35.789969 141005 throttler_timed.cc:77] sampling interval: 5s | |
| I0402 20:39:35.789978 141005 throttler_timed.cc:78] sampling delay: 0s | |
| I0402 20:39:45.893823 141005 proto.cc:231] Collected a profile: total count=400, weight=40000000000 | |
| I0402 20:39:45.894408 141005 uploader_file.h:24] Saving profile to /usr/local/google/home/aalexand/projects/cprof-java-agent-collect-profile-to-file-example/profile_wall_1522726785.pb.gz | |
| I0402 20:39:55.996594 141005 proto.cc:231] Collected a profile: total count=1000, weight=10000000000 | |
| I0402 20:39:55.996989 141005 uploader_file.h:24] Saving profile to /usr/local/google/home/aalexand/projects/cprof-java-agent-collect-profile-to-file-example/profile_cpu_1522726795.pb.gz | |
| I0402 20:40:06.099144 141005 proto.cc:231] Collected a profile: total count=400, weight=40000000000 | |
| I0402 20:40:06.099649 141005 uploader_file.h:24] Saving profile to /usr/local/google/home/aalexand/projects/cprof-java-agent-collect-profile-to-file-example/profile_wall_1522726806.pb.gz | |
| ^CI0402 20:40:07.836849 141075 entry.cc:96] On VM death | |
| I0402 20:40:16.201818 141005 proto.cc:231] Collected a profile: total count=1000, weight=10000000000 | |
| I0402 20:40:16.202256 141005 uploader_file.h:24] Saving profile to /usr/local/google/home/aalexand/projects/cprof-java-agent-collect-profile-to-file-example/profile_cpu_1522726816.pb.gz | |
| I0402 20:40:16.202409 141005 worker.cc:116] Exiting the profiling loop | |
| $ pprof -top profile_cpu_1522726816.pb.gz | |
| File: java | |
| Build ID: b8b4c6983f53365a453bf2958f19802be87f51fb | |
| Type: cpu | |
| Duration: 10s, Total samples = 10s ( 100%) | |
| Showing nodes accounting for 9.98s, 99.80% of 10s total | |
| Dropped 2 nodes (cum <= 0.05s) | |
| flat flat% sum% cum cum% | |
| 9.98s 99.80% 99.80% 9.98s 99.80% Test.foo() | |
| 0 0% 99.80% 9.98s 99.80% JavaCalls::call_helper | |
| 0 0% 99.80% 9.98s 99.80% JavaMain | |
| 0 0% 99.80% 9.98s 99.80% Test.main | |
| 0 0% 99.80% 9.98s 99.80% WeakPreserveExceptionMark::~WeakPreserveExceptionMark (inline) | |
| 0 0% 99.80% 9.98s 99.80% __clone | |
| 0 0% 99.80% 9.98s 99.80% jni_CallStaticVoidMethod | |
| 0 0% 99.80% 9.98s 99.80% jni_invoke_static | |
| 0 0% 99.80% 9.98s 99.80% methodHandle::~methodHandle (inline) | |
| 0 0% 99.80% 9.98s 99.80% start_thread | |
| ~ ➜ go get -u github.com/google/pprof | |
| ~ ➜ go get github.com/gopalmor/gcvis | |
| ~ ➜ go tool pprof -http=":" -nodecount=9999999 profile_cpu_1606183305.pb.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment