From 66a8afab99efb7ac7669961eb2e67e2244d494e5 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 19 Dec 2018 14:07:01 +0000 Subject: Count current tick using an int instead of LongAdder Assuming 20tps, there's enough space in an int to store a tick count spanning a number of years :) --- spark-common/src/main/java/me/lucko/spark/common/command/Command.java | 4 ++-- .../java/me/lucko/spark/common/command/modules/MonitoringModule.java | 2 +- spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java | 2 +- spark-common/src/main/java/me/lucko/spark/sampler/TickCounter.java | 2 +- .../java/me/lucko/spark/sampler/aggregator/TickedDataAggregator.java | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'spark-common/src') diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/Command.java b/spark-common/src/main/java/me/lucko/spark/common/command/Command.java index a28320b..fb440b1 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/Command.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/Command.java @@ -63,8 +63,8 @@ public class Command { } public static final class Builder { - private ImmutableList.Builder aliases = ImmutableList.builder(); - private ImmutableList.Builder arguments = ImmutableList.builder(); + private final ImmutableList.Builder aliases = ImmutableList.builder(); + private final ImmutableList.Builder arguments = ImmutableList.builder(); private Executor executor = null; private TabCompleter tabCompleter = null; diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java index cf43c18..608d6b4 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java @@ -86,7 +86,7 @@ public class MonitoringModule implements CommandModule { @Override protected void sendMessage(String message) { - platform.sendPrefixedMessage(message); + this.platform.sendPrefixedMessage(message); } } } diff --git a/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java b/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java index f3eb441..abb6148 100644 --- a/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java +++ b/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java @@ -37,7 +37,7 @@ public abstract class TickMonitor implements Runnable, AutoCloseable { // data private volatile double lastTickTime = 0; private State state = null; - private DoubleSummaryStatistics averageTickTime = new DoubleSummaryStatistics(); + private final DoubleSummaryStatistics averageTickTime = new DoubleSummaryStatistics(); private double avg; public TickMonitor(TickCounter tickCounter, int percentageChangeThreshold, boolean monitorGc) { diff --git a/spark-common/src/main/java/me/lucko/spark/sampler/TickCounter.java b/spark-common/src/main/java/me/lucko/spark/sampler/TickCounter.java index d6b754b..059e420 100644 --- a/spark-common/src/main/java/me/lucko/spark/sampler/TickCounter.java +++ b/spark-common/src/main/java/me/lucko/spark/sampler/TickCounter.java @@ -41,7 +41,7 @@ public interface TickCounter extends AutoCloseable { * * @return the current tick */ - long getCurrentTick(); + int getCurrentTick(); /** * Adds a task to be called each time the tick increments diff --git a/spark-common/src/main/java/me/lucko/spark/sampler/aggregator/TickedDataAggregator.java b/spark-common/src/main/java/me/lucko/spark/sampler/aggregator/TickedDataAggregator.java index dc241a9..2c68b02 100644 --- a/spark-common/src/main/java/me/lucko/spark/sampler/aggregator/TickedDataAggregator.java +++ b/spark-common/src/main/java/me/lucko/spark/sampler/aggregator/TickedDataAggregator.java @@ -65,7 +65,7 @@ public class TickedDataAggregator implements DataAggregator { private final Object mutex = new Object(); // state - private long currentTick = -1; + private int currentTick = -1; private TickList currentData = new TickList(0); public TickedDataAggregator(ExecutorService workerPool, TickCounter tickCounter, ThreadGrouper threadGrouper, int interval, boolean includeLineNumbers, int tickLengthThreshold) { @@ -82,7 +82,7 @@ public class TickedDataAggregator implements DataAggregator { @Override public void insertData(String threadName, StackTraceElement[] stack) { synchronized (this.mutex) { - long tick = this.tickCounter.getCurrentTick(); + int tick = this.tickCounter.getCurrentTick(); if (this.currentTick != tick) { pushCurrentTick(); this.currentTick = tick; -- cgit