jvm-profiling-tools / ap-loader Goto Github PK
View Code? Open in Web Editor NEWPackages async-profiler with binaries for all platforms in a single JAR
License: Apache License 2.0
Packages async-profiler with binaries for all platforms in a single JAR
License: Apache License 2.0
This library uses Mozilla Public License 2.0. There are very subtle definitions on when you have to disclose your source and it's hard to use ap-loader due to this.
Would it be possible to replace this library with something like Files.createTempDirectory?
At the moment we have jbang aliases for jvm-profling-tools/ap-loader
with a jbang-catalog.
Means that you need to do jbang <alias>@jvm-profiling-tools/ap-loader
for everything.
If there was a jvm-profling-tools/jbang-catalog repo we could shorten this to just: jbang <alias>@jvm-profiling-tools
shorter and easier to remember imo.
wdyt?
Starting at async-profiler version 2.10 (currently a pre-release), the profiler.sh is replaced with the asprof binary. ap-loader should hide this from the user as the major options from the profiler.sh are all present in asprof, except --lib
which does not make any sense with ap-loader.
Usage hints for converter indicate FlameGraph can be used
java -jar ap-loader-all.jar converter
Usage: java -cp ap-loader.jar one.converter.<Converter> [options] <input> <output>
Available converters:
FlameGraph input.collapsed output.html
jfr2flame input.jfr output.html
jfr2nflx input.jfr output.nflx
jfr2pprof input.jfr output.pprof
however when I run it, I get an error
java -jar ap-loader-all.jar converter FlameGraph input.collapsed collapsed.html
Error: Could not find or load main class FlameGraph
Caused by: java.lang.ClassNotFoundException: FlameGraph
Support https://github.com/async-profiler/async-profiler/releases/tag/v3.0.
Includes #11.
Getting this error with the latest release
~ # java -jar ap-loader-linux-x64.jar profiler -d 60 1
Exception in thread "main" java.lang.IllegalStateException: Async-profiler does not work with the given libc
at one.profiler.AsyncProfilerLoader.getLibrarySuffix(AsyncProfilerLoader.java:147)
at one.profiler.AsyncProfilerLoader.getAsyncProfilerFileName(AsyncProfilerLoader.java:227)
at one.profiler.AsyncProfilerLoader.isSupported(AsyncProfilerLoader.java:269)
at one.profiler.AsyncProfilerLoader.checkCommandAvailability(AsyncProfilerLoader.java:645)
at one.profiler.AsyncProfilerLoader.main(AsyncProfilerLoader.java:666)
I see that a fix has been committed but the release has not been updated maybe?
Used the README example and alloc and lock events are recorded but CPU is not
java -jar ap-loader-all.jar profiler -e alloc,cpu,lock -d 60 -f all.jfr 79686
[WARN] Unknown argument: cpu
Profiling for 60 seconds
Done
ap-loader-all.jar version
3.0
jbang --javaagent=ap-loader@jvm-profiling-tools/ap-loader=start,event=cpu,file=profile.html jmh_example.java
When running the jbang example I've got html tree view instead of a flamegraph
Call tree view, total samples: 82
[0] 51.22% 42 self: 0.00% 0
start_thread
[0] 21.95% 18 self: 0.00% 0
red/hat/puzzles/loom/jmh_example.main
[0] 19.51% 16 self: 0.00% 0
org/openjdk/jmh/runner/link/BinaryLinkServer$Handler.run
[0] 3.66% 3 self: 0.00% 0
[unknown]
[0] 2.44% 2 self: 0.00% 0
__GI___pthread_cond_broadcast
[0] 1.22% 1 self: 0.00% 0
red/hat/puzzles/loom/jmh_example.<clinit>
Is this expected? If so, what is the option to get the flamegraph
I've been trying to use ap-loader-* artifacts from maven but afaics the released jar's from github release page and the maven central jars are NOT the same.
Resulting in this error using the maven jars:
run: /Users/manderse/.jbang/cache/jdks/19/bin/java '-javaagent:/Users/manderse/.m2/repository/me/bechberger/ap-loader-macos/2.9-4/ap-loader-macos-2.9-4.jar=start,event=cpu,file=profile.html' --enable-preview --add-opens java.base/java.lang=ALL-UNNAMED -classpath /Users/manderse/.jbang/cache/jars/VirtualThreadReflectionBenchmark.java.7d632a1c2e33734f11f5a17bf40fd430f897bd02269d088fa6ed26853056da8b.jar:/Users/manderse/.m2/repository/org/openjdk/jmh/jmh-generator-annprocess/1.36/jmh-generator-annprocess-1.36.jar:/Users/manderse/.m2/repository/org/openjdk/jmh/jmh-core/1.36/jmh-core-1.36.jar:/Users/manderse/.m2/repository/net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar:/Users/manderse/.m2/repository/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar org.openjdk.jmh.Main
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:491)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:503)
Caused by: java.lang.NoClassDefFoundError: dev/dirs/ProjectDirectories
at one.profiler.AsyncProfilerLoader.getExtractionDirectory(AsyncProfilerLoader.java:128)
at one.profiler.AsyncProfilerLoader.getAsyncProfilerPath(AsyncProfilerLoader.java:345)
at one.profiler.AsyncProfilerLoader.attach(AsyncProfilerLoader.java:613)
at one.profiler.AsyncProfilerLoader.agentmain(AsyncProfilerLoader.java:625)
at one.profiler.AsyncProfilerLoader.premain(AsyncProfilerLoader.java:586)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 3 more
Caused by: java.lang.ClassNotFoundException: dev.dirs.ProjectDirectories
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 9 more
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed
Using the downloaded jar works fine so I tried to compare them and notice that the released jars has dev/dirs
embedded but the ones in maven central does not.
There is also native image config missing and the manifest.mf is slightly different:
Is there a reason for this difference?
Hi there,
when referencing ap-loader
from a Maven POM
<properties>
<ap-loader.version>2.9-2-all</ap-loader.version>
</properties>
[...]
<dependency>
<groupId>me.bechberger</groupId>
<artifactId>ap-loader</artifactId>
<version>${ap-loader.version}</version>
</dependency>
and afterwards running mvn -U versions:update-properties
to update all dependencies to their current version, the -macos
variant is chosen over the -all
variant:
- <ap-loader.version>2.9-2-all</ap-loader.version>
+ <ap-loader.version>2.9-2-macos</ap-loader.version>
This is due to the way Maven interprets qualifiers in versions using alphabetical sorting (cf. https://www.mojohaus.org/versions/versions-maven-plugin/version-rules.html).
One possible solution would be to pull the variant into the artifact name so that the qualifier only contains the ap-loader
version, such as:
<dependency>
<groupId>me.bechberger</groupId>
<artifactId>ap-loader-all</artifactId>
<version>2.9-2</version>
</dependency>
Thanks,
Thilo
P.S.: Using the classifier could also be an option
Async-profiler didn't have a release for a while, so maybe we should create sub-releases of ap-loader.
ap-loader is awesome and I realized I can do this:
jbang me.bechberger:ap-loader-all:LATEST
Allowing you to use ap-loader directly with no extra downloads (assuming you already have jbang)
without jbang it would be:
curl -Ls https://sh.jbang.dev | bash -s - me.bechberger:ap-loader-all:LATEST
In that spirit I was wondering if you would be up for adding a jvm-profiling-tools/jbang-catalog github repo or adding a jbang-catalog.json to this repo ?
it would allow to do:
jbang ap-loader@jvm-profiling-tools
as a shorthand.
if inside this repo it would be jbang ap-loader@jvm-profiling-tools/ap-loader
I can make PR's for both approaches but would need jbang-catalog repo to exist first if going for that option.
Can also just make update to the readme using the GAV approach (jbang me.bechberger:ap-loader-all:LATEST
)
WDYT?
When trying to import ap-loader into gradle project
implementation("me.bechberger:ap-loader:2.9-all")
I'm getting
Execution failed for task ':project:compileKotlin'.
> Error while evaluating property 'filteredArgumentsMap' of task ':project:compileKotlin'.
> Could not resolve all files for configuration ':project:compileClasspath'.
> Could not resolve me.bechberger:ap-loader:2.9-all.
Required by:
project :project
> Could not resolve me.bechberger:ap-loader:2.9-all.
> inconsistent module metadata found. Descriptor: me.bechberger:ap-loader:2.8.3-all-SNAPSHOT Errors: bad version: expected='2.9-all' found='2.8.3-all-SNAPSHOT'
which seems to be because the pom has version 2.8.3-all-SNAPSHOT
https://repo1.maven.org/maven2/me/bechberger/ap-loader/2.9-all/ap-loader-2.9-all.pom
Dear ap-loader expert,
As we know, https://github.com/GoogleContainerTools/distroless doesn't contains shells, our ap-loader is a wrapper of async profiler which will execute the async profiler shell scripts (https://github.com/jvm-profiling-tools/ap-loader/blob/main/src/main/java/one/profiler/AsyncProfilerLoader.java#L598).
Is it possible to use jattach directly to support https://github.com/GoogleContainerTools/distroless?
Thanks,
Roy
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.