aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src/main/java/me/lucko/spark/common/sampler
diff options
context:
space:
mode:
authorvaperion <vaperion@riseup.net>2022-12-31 15:47:56 +0100
committerlucko <git@lucko.me>2022-12-31 18:31:07 +0000
commitd6d2e31169af5966e244585582a4ccea317cecb3 (patch)
tree376f5609816badc16741f95f7bb6054b723d61ab /spark-common/src/main/java/me/lucko/spark/common/sampler
parent690d09f58d125fcde22a031335d0a1d6af37b954 (diff)
downloadspark-d6d2e31169af5966e244585582a4ccea317cecb3.tar.gz
spark-d6d2e31169af5966e244585582a4ccea317cecb3.tar.bz2
spark-d6d2e31169af5966e244585582a4ccea317cecb3.zip
Make thread grouper configurable for the background sampler
Diffstat (limited to 'spark-common/src/main/java/me/lucko/spark/common/sampler')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/BackgroundSamplerManager.java16
1 files changed, 15 insertions, 1 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 7e3b6b4..82a4b47 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
@@ -31,6 +31,7 @@ public class BackgroundSamplerManager {
private static final String OPTION_ENABLED = "backgroundProfiler";
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 MARKER_FAILED = "_marker_background_profiler_failed";
@@ -101,10 +102,23 @@ public class BackgroundSamplerManager {
private void startSampler() {
boolean forceJavaEngine = this.configuration.getString(OPTION_ENGINE, "async").equals("java");
+ ThreadGrouper threadGrouper;
+ switch (this.configuration.getString(OPTION_THREAD_GROUPER, "byPool")) {
+ case "asOne":
+ threadGrouper = ThreadGrouper.AS_ONE;
+ break;
+ case "byName":
+ threadGrouper = ThreadGrouper.BY_NAME;
+ break;
+ default:
+ threadGrouper = ThreadGrouper.BY_POOL;
+ break;
+ }
+
Sampler sampler = new SamplerBuilder()
.background(true)
.threadDumper(this.platform.getPlugin().getDefaultThreadDumper())
- .threadGrouper(ThreadGrouper.BY_POOL)
+ .threadGrouper(threadGrouper)
.samplingInterval(this.configuration.getInteger(OPTION_INTERVAL, 10))
.forceJavaSampler(forceJavaEngine)
.start(this.platform);