AP-Loader: A New Way to Use and Embed async-profilerNovember 22, 2022
Using async-profiler can be quite a hassle.
First, you have to download the right archive from GitHub for your OS and architecture, then you have to unpack it and place it somewhere.
Or you get it from your OS distribution, hoping that it is the current version.
It gets worse if you want to embed it into your library, agent, or application. Library developers cannot just use a Maven dependency but have to create wrapper code and build scripts that deal with packaging the binaries themselves. Or, worse, they depend on a preinstalled version which they do not control.
I started the AP-Loader project to fix all this!
- Want to run async-profiler? Just grab the latest loader JAR from GitHub, and run
java -jar ap-loader-all.jar profilerregardless of your OS or architecture
- Want to use the async-profiler as a Java Agent? You can use the loader JAR as javaagent and it behaves like the native async-profiler agent
- Want to use jattach?
java -jar ap-loader-all.jar jattachis your friend
- Wondering what version of async-profiler you're using?
java -jar ap-loader-all.jar versionhas you covered
- Want to use the converter to convert between formats? Just use
java -jar ap-loader-all.jar converter
- Want to use async-profiler in your library? Just add a dependency to the
me.bechberger.ap-loader:-all-SNAPSHOTfrom the Sonatype OSS repository and use
- Want to use the converter too? All the converter classes are included in the JAR, look no further than the
- Just want all this for one platform only? I build and package versions for all platforms. There can be multiple platform versions on the classpath
- But what about the JAR size? It's just under 800KB, so no worries
This project uses the original binaries from async-profiler's GitHub releases page and tests the resulting project using the original tests from async-profiler, so you can expect it to behave as async-profiler does.
The idea for this project came up in a discussion with the creator of async-profiler, Andrei Pangin.
I use this project daily to profile my applications, so might you too?
I'm open to suggestions, bug reports and happy help to integrate ap-loader into your open-source library.
If I enticed you: Go over to GitHub to get more detailed information on this project.
This project is part of my work in the SapMachine team at SAP, making profiling easier for everyone. I built it to integrate async-profiler into more applications and libraries, like my upcoming profiler UI. This article first appeared on my personal blog mostlynerdless.de.