Sometimes, especially in wall-clock mode, profiler produces too many samples that user is not interested in, e.g. idle threads of a thread pool doing nothing but waiting. (#69)
It will be nice to have an option to exclude these threads from profiling.
Hello
I would appreciate an option to filter stacks by specified class/method name (to output flamegraph already filtered by interesting method). It is possible to do so currently, by asking async-profiler to output collapsed stacks and then grepping those stacks and making a flamegraph "manually". But it would be nice to do simply ./profile.sh --filter=com.company.MyClass.myMethod -d 50 -f graph.svg 123.
Added -I and -X options to specify the method name pattern to include or to exclude from the result output.
E.g. to output only stack traces containing with the method com.company.MyClass.myMethod:
profiler.sh -I com/company/MyClass.myMethod ...
To exclude stack traces containing JLI_Launch frame:
profiler.sh -X JLI_Launch ...
-I and -X patterns may occur multiple times. It's also possible to use star-patterns, e.g.
profiler.sh -X 'GCTask*' -X 'WatcherThread*' -X 'VMThread::run()' ...
It's not necessary to rerun profiler in order to change filter. Once profile is collected, it's possible to dump it multiple times with different filters:
profiler.sh stop -f out1.svg -I <filter1> <pid>
profiler.sh stop -f out2.svg -I <filter2> <pid>
profiler.sh stop -f out3.svg -I <filter3> <pid>
Are frames also filtered when using the JFR output? I didn't have luck excluding frames from the JDK with exclude=java/* using the AsyncProfiler#execute Java API.
@felixbarny No, method filters don't have effect on JFR output, as JFR writes samples on the go, while method filters are applied in post-processing phase.
Currently there are two types of filtres: thread filter (controlled by Java API) and method filter. The former takes effect immediately during the profiling phase, and the latter is processed after the profiling stops. Filtering classes and methods is rather expensive and can hardly be done inside a signal handler, so there are no plans to apply method filters on the go.
Most helpful comment
Hello
I would appreciate an option to filter stacks by specified class/method name (to output flamegraph already filtered by interesting method). It is possible to do so currently, by asking async-profiler to output collapsed stacks and then grepping those stacks and making a flamegraph "manually". But it would be nice to do simply
./profile.sh --filter=com.company.MyClass.myMethod -d 50 -f graph.svg 123.