Async-profiler: Update ReadMe.md with Example about "How to use this profile on remote JVM"

Created on 2 Jun 2016  路  13Comments  路  Source: jvm-profiling-tools/async-profiler

Steps I follow:
1) download
2) compile
3) Write Wrap class which call throw JNI start and stop profiler method.
4) Run java application
5) invoke wrap class methods
6) See in output stream summary of profilling

How can I do this for remote jvm?

Most helpful comment

@egor-ryashin Could you please open a separate issue?

All 13 comments

You can dynamically inject agent library into the running JVM using HotSpot Attach API.
For instance, you can do this with my jattach utility:

jattach PID load /path/to/libasyncProfiler.so true start
jattach PID load /path/to/libasyncProfiler.so true stop

@apangin I've followed this and it just prints

Connected to remote JVM
Response Code = -1

This means the command was recognized, but the library could not be loaded.
Make sure you specify the absolute path to the library, and the file has proper permissions.

I'm trying to attach and dump summary info:
$ ./jattach $PID load /tmp/libasyncProfiler.so true start 1 10 Connected to remote JVM Response code = 0 0 $ ./jattach $PID load /tmp/libasyncProfiler.so true dumpRawTraces Connected to remote JVM Response code = 0 0 $ ./jattach $PID load /tmp/libasyncProfiler.so true stop Connected to remote JVM Response code = 0 0 $ ./jattach $PID load /tmp/libasyncProfiler.so true dumpRawTraces Connected to remote JVM Response code = 0 0
but I can't get any methods info. What am I doing wrong?

Note that profiling stats are printed on stdout of Java process (not on the console of jattach).

Alternatively you may dump raw traces to the specified file:

./jattach $PID load /tmp/libasyncProfiler.so true dumpRawTraces:/path/to/profile.txt

Thanks. With dumpRawTraces method it's working fine. But with other methods - summary, dumpMethods and others it doesn't work - no file created.

Hi again! Could you please get any advice how to get summary/dumpMethods info in file?

This is not supported right now, but will get fixed soon.

@tartemov you can use Brendan Gregg scripts to fold stacks and make svg

1) clone https://github.com/brendangregg/FlameGraph

2) FlameGraph/stackcollapse-ljp.awk mytrace.txt > mytrace.folded

3) FlameGraph/flamegraph.pl mytrace.folded > mytrace.svg

I cannot attach to some JVM processes.
I made profiler.sh output more info:

    collect)
        $JATTACH $PID load $PROFILER true start,file=$FILE$INTERVAL$FRAMEBUF #> /dev/null
        if [ $? -ne 0 ]; then
            exit 1
        fi

Got this:

~/async-profiler $ sudo -u xncore ./profiler.sh -d 10 3515
Connected to remote JVM
Response code = -1

Is there a way to debug it further?

@egor-ryashin Could you please open a separate issue?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yaoliao picture yaoliao  路  5Comments

nobeh picture nobeh  路  5Comments

egwepas picture egwepas  路  7Comments

apangin picture apangin  路  5Comments

aminebag picture aminebag  路  6Comments