Skip to content

Commit

Permalink
Bump async-profiler to 3.0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-p committed Nov 28, 2024
1 parent e1df3dd commit fd79e5d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 77 deletions.
27 changes: 17 additions & 10 deletions async-profiler-context/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repositories {
mavenCentral()
}

def asyncProfilerVersion = "3.0.0.0"
def asyncProfilerVersion = project.properties['async_profiler_version']
def pyroscopeVersion = project.properties['pyroscope_version']
dependencies {
api files("$buildDir/async-profiler/async-profiler.jar")
Expand Down Expand Up @@ -64,18 +64,18 @@ shadowJar {
archiveClassifier.set('')
}

task relocateShadowJar(type: ConfigureShadowRelocation) {
tasks.register('relocateShadowJar', ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = "io.pyroscope"
}
tasks.shadowJar.dependsOn tasks.relocateShadowJar

task asyncProfilerLib {
tasks.register('asyncProfilerLib') {
def useLocalArtifacts = project.findProperty('useLocalAsyncProfilerArtifacts') == 'true'

def suffixes = [
['linux-arm64', 'tar.gz'],
['linux-x64', 'tar.gz'],
['linux-musl-x64', 'tar.gz'],
['linux-musl-arm64', 'tar.gz'],
['macos', 'zip']
]

Expand All @@ -87,11 +87,18 @@ task asyncProfilerLib {

doLast {
suffixes.forEach { suffix, ext ->
def repo = "https://github.com/grafana/async-profiler"
download {
src "$repo/releases/download/v${asyncProfilerVersion}/async-profiler-${asyncProfilerVersion}-${suffix}.${ext}"
dest new File(asyncProfilerDir, "async-profiler-${asyncProfilerVersion}-${suffix}.${ext}")
overwrite true
if (!useLocalArtifacts) {
def repo = "https://github.com/grafana/async-profiler"
download {
src "$repo/releases/download/v${asyncProfilerVersion}/async-profiler-${asyncProfilerVersion}-${suffix}.${ext}"
dest new File(asyncProfilerDir, "async-profiler-${asyncProfilerVersion}-${suffix}.${ext}")
overwrite true
}
} else {
copy {
from file("../async-profiler-${asyncProfilerVersion}-${suffix}.${ext}")
into asyncProfilerDir
}
}

// Extract the native library files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,10 @@ private static String libraryFileName() {
case "Linux":
switch (archProperty) {
case "amd64":
if (isMusl()) {
arch = "musl-x64";
} else {
arch = "x64";
}
arch = "x64";
break;

case "aarch64":
if (isMusl()) {
arch = "musl-arm64";
} else {
arch = "arm64";
}
arch = "arm64";
break;

default:
Expand Down Expand Up @@ -135,60 +126,4 @@ private static String targetLibraryFileName(final String libraryFileName) throws

return libraryFileName.substring(0, libraryFileName.length() - 3) + "-" + checksum + ".so";
}

private static boolean isMusl() {
// allow user to force musl/glibc it in case next checks fails
String env = System.getenv("PYROSCOPE_MUSL");
if (env == null) {
env = System.getProperty("pyroscope.musl");
}
if (env != null) {
return Boolean.parseBoolean(env);
}
// check ldd on currently running jvm
// $ ldd /usr/lib/jvm/java-11-openjdk/bin/java
// /lib/ld-musl-x86_64.so.1 (0x7f337ca6c000)
// libjli.so => /usr/lib/jvm/java-11-openjdk/bin/../lib/jli/libjli.so (0x7f337ca55000)
// libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f337ca6c000)
File javaExecutable = new File(System.getProperty("java.home") + "/bin/java");
if (javaExecutable.exists()) {
for (String l : runProcess("ldd", javaExecutable.getAbsolutePath())) {
if (l.contains("ld-musl-") || l.contains("libc.musl-")) {
return true;
}
}
return false;
}
// $ ldd --version
// musl libc (x86_64)
for (String l : runProcess("ldd", "--version")) {
if (l.contains("musl")) {
return true;
}
}
return false;
}

private static List<String> runProcess(String... cmd) {
List<String> lines = new ArrayList<>();
try {
Process pr = new ProcessBuilder(Arrays.<String>asList(cmd))
.redirectErrorStream(true) // ldd --version prints to stderr
.start();
BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
lines.add(line);
}
try {
pr.waitFor();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
pr.destroy();
} catch (IOException e) {
e.printStackTrace();
}
return lines;
}
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pyroscope_version=0.14.1
async_profiler_version=3.0.0.1
useLocalAsyncProfilerArtifacts=false

0 comments on commit fd79e5d

Please sign in to comment.