aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src/main/java/me
diff options
context:
space:
mode:
authorvaperion <vaperion@riseup.net>2022-12-31 16:08:20 +0100
committerlucko <git@lucko.me>2022-12-31 18:31:07 +0000
commitcf41ef932545ea28567e6bf3c9bf6ce634d43976 (patch)
tree49a4deb8e180f9ef470336de4b1a17989cb7f67d /spark-common/src/main/java/me
parentbcea61e5b221fd0c0ee6c2bc17c53473dc54c4fd (diff)
downloadspark-cf41ef932545ea28567e6bf3c9bf6ce634d43976.tar.gz
spark-cf41ef932545ea28567e6bf3c9bf6ce634d43976.tar.bz2
spark-cf41ef932545ea28567e6bf3c9bf6ce634d43976.zip
Make thread dumper configurable for the background sampler
Diffstat (limited to 'spark-common/src/main/java/me')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/BackgroundSamplerManager.java35
1 files changed, 28 insertions, 7 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/BackgroundSamplerManager.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/BackgroundSamplerManager.java
index 82a4b47..ff1b3ac 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/BackgroundSamplerManager.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/BackgroundSamplerManager.java
@@ -24,7 +24,10 @@ import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.common.util.Configuration;
+import java.util.Arrays;
+import java.util.Set;
import java.util.logging.Level;
+import java.util.stream.Collectors;
public class BackgroundSamplerManager {
@@ -32,6 +35,7 @@ public class BackgroundSamplerManager {
private static final String OPTION_ENGINE = "backgroundProfilerEngine";
private static final String OPTION_INTERVAL = "backgroundProfilerInterval";
private static final String OPTION_THREAD_GROUPER = "backgroundProfilerThreadGrouper";
+ private static final String OPTION_THREAD_DUMPER = "backgroundProfilerThreadDumper";
private static final String MARKER_FAILED = "_marker_background_profiler_failed";
@@ -101,9 +105,11 @@ public class BackgroundSamplerManager {
private void startSampler() {
boolean forceJavaEngine = this.configuration.getString(OPTION_ENGINE, "async").equals("java");
+ String grouperName = this.configuration.getString(OPTION_THREAD_GROUPER, "byPool");
+ String dumperName = this.configuration.getString(OPTION_THREAD_DUMPER, "default");
ThreadGrouper threadGrouper;
- switch (this.configuration.getString(OPTION_THREAD_GROUPER, "byPool")) {
+ switch (grouperName) {
case "asOne":
threadGrouper = ThreadGrouper.AS_ONE;
break;
@@ -115,13 +121,28 @@ public class BackgroundSamplerManager {
break;
}
+ ThreadDumper threadDumper;
+ switch (dumperName) {
+ case "default":
+ threadDumper = this.platform.getPlugin().getDefaultThreadDumper();
+ break;
+ case "*":
+ case "all":
+ threadDumper = ThreadDumper.ALL;
+ break;
+ default:
+ Set<String> threadNames = Arrays.stream(dumperName.split(",")).collect(Collectors.toSet());
+ threadDumper = new ThreadDumper.Specific(threadNames);
+ break;
+ }
+
Sampler sampler = new SamplerBuilder()
- .background(true)
- .threadDumper(this.platform.getPlugin().getDefaultThreadDumper())
- .threadGrouper(threadGrouper)
- .samplingInterval(this.configuration.getInteger(OPTION_INTERVAL, 10))
- .forceJavaSampler(forceJavaEngine)
- .start(this.platform);
+ .background(true)
+ .threadDumper(threadDumper)
+ .threadGrouper(threadGrouper)
+ .samplingInterval(this.configuration.getInteger(OPTION_INTERVAL, 10))
+ .forceJavaSampler(forceJavaEngine)
+ .start(this.platform);
this.platform.getSamplerContainer().setActiveSampler(sampler);
}