From 8379f2b07bc38c24733c4f1d537ea7c2ee03d91b Mon Sep 17 00:00:00 2001 From: lucko Date: Thu, 18 Jul 2024 22:03:36 +0100 Subject: Add spark-paper module (#422) --- .../common/sampler/async/AsyncProfilerAccess.java | 24 ++++++++++++++++++--- .../spark-native/linux/aarch64/libasyncProfiler.so | Bin 0 -> 343408 bytes .../linux/amd64-musl/libasyncProfiler.so | Bin 0 -> 317560 bytes .../spark-native/linux/amd64/libasyncProfiler.so | Bin 0 -> 361312 bytes .../spark-native/macos/libasyncProfiler.so | Bin 0 -> 724576 bytes .../spark/linux/aarch64/libasyncProfiler.so | Bin 343408 -> 0 bytes .../spark/linux/amd64-musl/libasyncProfiler.so | Bin 317560 -> 0 bytes .../spark/linux/amd64/libasyncProfiler.so | Bin 361312 -> 0 bytes .../main/resources/spark/macos/libasyncProfiler.so | Bin 724576 -> 0 bytes 9 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 spark-common/src/main/resources/spark-native/linux/aarch64/libasyncProfiler.so create mode 100755 spark-common/src/main/resources/spark-native/linux/amd64-musl/libasyncProfiler.so create mode 100755 spark-common/src/main/resources/spark-native/linux/amd64/libasyncProfiler.so create mode 100755 spark-common/src/main/resources/spark-native/macos/libasyncProfiler.so delete mode 100755 spark-common/src/main/resources/spark/linux/aarch64/libasyncProfiler.so delete mode 100755 spark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.so delete mode 100755 spark-common/src/main/resources/spark/linux/amd64/libasyncProfiler.so delete mode 100755 spark-common/src/main/resources/spark/macos/libasyncProfiler.so (limited to 'spark-common/src') diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java index 192275b..7dcb131 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java +++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java @@ -114,13 +114,19 @@ public class AsyncProfilerAccess { if (this.setupException instanceof UnsupportedSystemException) { platform.getPlugin().log(Level.INFO, "The async-profiler engine is not supported for your os/arch (" + this.setupException.getMessage() + "), so the built-in Java engine will be used instead."); + } else if (this.setupException instanceof UnsupportedJvmException) { + platform.getPlugin().log(Level.INFO, "The async-profiler engine is not supported for your JVM (" + + this.setupException.getMessage() + "), so the built-in Java engine will be used instead."); } else if (this.setupException instanceof NativeLoadingException && this.setupException.getCause().getMessage().contains("libstdc++")) { platform.getPlugin().log(Level.WARNING, "Unable to initialise the async-profiler engine because libstdc++ is not installed."); platform.getPlugin().log(Level.WARNING, "Please see here for more information: https://spark.lucko.me/docs/misc/Using-async-profiler#install-libstdc"); } else { - platform.getPlugin().log(Level.WARNING, "Unable to initialise the async-profiler engine: " + this.setupException.getMessage()); + String error = this.setupException.getMessage(); + if (this.setupException.getCause() != null) { + error += " (" + this.setupException.getCause().getMessage() + ")"; + } + platform.getPlugin().log(Level.WARNING, "Unable to initialise the async-profiler engine: " + error); platform.getPlugin().log(Level.WARNING, "Please see here for more information: https://spark.lucko.me/docs/misc/Using-async-profiler"); - this.setupException.printStackTrace(); } } @@ -140,6 +146,12 @@ public class AsyncProfilerAccess { // check compatibility String os = System.getProperty("os.name").toLowerCase(Locale.ROOT).replace(" ", ""); String arch = System.getProperty("os.arch").toLowerCase(Locale.ROOT); + String jvm = System.getProperty("java.vm.name"); + + // openj9 not supported by async-profiler at the moment + if (jvm.contains("OpenJ9")) { + throw new UnsupportedJvmException(jvm); + } if (os.equals("linux") && arch.equals("amd64") && isLinuxMusl()) { arch = "amd64-musl"; @@ -159,7 +171,7 @@ public class AsyncProfilerAccess { } // extract the profiler binary from the spark jar file - String resource = "spark/" + libPath + "/libasyncProfiler.so"; + String resource = "spark-native/" + libPath + "/libasyncProfiler.so"; URL profilerResource = AsyncProfilerAccess.class.getClassLoader().getResource(resource); if (profilerResource == null) { throw new IllegalStateException("Could not find " + resource + " in spark jar file"); @@ -224,6 +236,12 @@ public class AsyncProfilerAccess { } } + private static final class UnsupportedJvmException extends UnsupportedOperationException { + public UnsupportedJvmException(String jvm) { + super(jvm); + } + } + private static final class NativeLoadingException extends RuntimeException { public NativeLoadingException(Throwable cause) { super("A runtime error occurred whilst loading the native library", cause); diff --git a/spark-common/src/main/resources/spark-native/linux/aarch64/libasyncProfiler.so b/spark-common/src/main/resources/spark-native/linux/aarch64/libasyncProfiler.so new file mode 100755 index 0000000..800cf91 Binary files /dev/null and b/spark-common/src/main/resources/spark-native/linux/aarch64/libasyncProfiler.so differ diff --git a/spark-common/src/main/resources/spark-native/linux/amd64-musl/libasyncProfiler.so b/spark-common/src/main/resources/spark-native/linux/amd64-musl/libasyncProfiler.so new file mode 100755 index 0000000..3c81d1c Binary files /dev/null and b/spark-common/src/main/resources/spark-native/linux/amd64-musl/libasyncProfiler.so differ diff --git a/spark-common/src/main/resources/spark-native/linux/amd64/libasyncProfiler.so b/spark-common/src/main/resources/spark-native/linux/amd64/libasyncProfiler.so new file mode 100755 index 0000000..5af5071 Binary files /dev/null and b/spark-common/src/main/resources/spark-native/linux/amd64/libasyncProfiler.so differ diff --git a/spark-common/src/main/resources/spark-native/macos/libasyncProfiler.so b/spark-common/src/main/resources/spark-native/macos/libasyncProfiler.so new file mode 100755 index 0000000..4930c67 Binary files /dev/null and b/spark-common/src/main/resources/spark-native/macos/libasyncProfiler.so differ diff --git a/spark-common/src/main/resources/spark/linux/aarch64/libasyncProfiler.so b/spark-common/src/main/resources/spark/linux/aarch64/libasyncProfiler.so deleted file mode 100755 index 800cf91..0000000 Binary files a/spark-common/src/main/resources/spark/linux/aarch64/libasyncProfiler.so and /dev/null differ diff --git a/spark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.so b/spark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.so deleted file mode 100755 index 3c81d1c..0000000 Binary files a/spark-common/src/main/resources/spark/linux/amd64-musl/libasyncProfiler.so and /dev/null differ diff --git a/spark-common/src/main/resources/spark/linux/amd64/libasyncProfiler.so b/spark-common/src/main/resources/spark/linux/amd64/libasyncProfiler.so deleted file mode 100755 index 5af5071..0000000 Binary files a/spark-common/src/main/resources/spark/linux/amd64/libasyncProfiler.so and /dev/null differ diff --git a/spark-common/src/main/resources/spark/macos/libasyncProfiler.so b/spark-common/src/main/resources/spark/macos/libasyncProfiler.so deleted file mode 100755 index 4930c67..0000000 Binary files a/spark-common/src/main/resources/spark/macos/libasyncProfiler.so and /dev/null differ -- cgit