From 3b0564cc4b259f49a15aa6cdb2c4b8e35f5e26e0 Mon Sep 17 00:00:00 2001 From: Luck Date: Mon, 14 Nov 2022 19:54:58 +0000 Subject: Suppress profiler logs when running in background --- .../src/main/java/me/lucko/spark/common/SparkPlatform.java | 1 - .../me/lucko/spark/common/sampler/async/AsyncProfilerJob.java | 8 +++++++- .../java/me/lucko/spark/common/sampler/async/AsyncSampler.java | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'spark-common') diff --git a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java index 5461ed4..105b167 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java +++ b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java @@ -187,7 +187,6 @@ public class SparkPlatform { this.plugin.log(Level.INFO, "Starting background profiler..."); try { startBackgroundProfiler(); - this.plugin.log(Level.INFO, "... done!"); } catch (Exception e) { e.printStackTrace(); } diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerJob.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerJob.java index 7b123a7..8991e94 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerJob.java +++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerJob.java @@ -83,6 +83,8 @@ public class AsyncProfilerJob { private ThreadDumper threadDumper; /** The profiling window */ private int window; + /** If the profiler should run in quiet mode */ + private boolean quiet; /** The file used by async-profiler to output data */ private Path outputFile; @@ -116,11 +118,12 @@ public class AsyncProfilerJob { } // Initialise the job - public void init(SparkPlatform platform, int interval, ThreadDumper threadDumper, int window) { + public void init(SparkPlatform platform, int interval, ThreadDumper threadDumper, int window, boolean quiet) { this.platform = platform; this.interval = interval; this.threadDumper = threadDumper; this.window = window; + this.quiet = quiet; } /** @@ -139,6 +142,9 @@ public class AsyncProfilerJob { // construct a command to send to async-profiler String command = "start,event=" + this.access.getProfilingEvent() + ",interval=" + this.interval + "us,threads,jfr,file=" + this.outputFile.toString(); + if (this.quiet) { + command += ",loglevel=NONE"; + } if (this.threadDumper instanceof ThreadDumper.Specific) { command += ",filter"; } diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java index d6cfd4f..f2e7191 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java +++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncSampler.java @@ -79,7 +79,7 @@ public class AsyncSampler extends AbstractSampler { int window = ProfilingWindowUtils.windowNow(); AsyncProfilerJob job = this.profilerAccess.startNewProfilerJob(); - job.init(this.platform, this.interval, this.threadDumper, window); + job.init(this.platform, this.interval, this.threadDumper, window, this.background); job.start(); this.currentJob = job; @@ -116,7 +116,7 @@ public class AsyncSampler extends AbstractSampler { // start a new job int window = previousJob.getWindow() + 1; AsyncProfilerJob newJob = this.profilerAccess.startNewProfilerJob(); - newJob.init(this.platform, this.interval, this.threadDumper, window); + newJob.init(this.platform, this.interval, this.threadDumper, window, this.background); newJob.start(); this.currentJob = newJob; -- cgit