Make sure /tps includes global region in total util percent

While we expect the util from the global region to be around 0.0,
it doesn't mean it always will be. So, include it.
This commit is contained in:
Spottedleaf 2023-03-07 12:51:23 -08:00
parent 2802e2b360
commit 71a4219ab6
2 changed files with 9 additions and 6 deletions

View File

@ -8600,12 +8600,13 @@ index 0000000000000000000000000000000000000000..390bda127be9be5349c1c442ca01df6b
+}
diff --git a/src/main/java/io/papermc/paper/threadedregions/commands/CommandServerHealth.java b/src/main/java/io/papermc/paper/threadedregions/commands/CommandServerHealth.java
new file mode 100644
index 0000000000000000000000000000000000000000..4889ebf6e3eb5901eeac49900c541d2359d71316
index 0000000000000000000000000000000000000000..85348ddd7568ea68bfdb5092ded14886359c0c01
--- /dev/null
+++ b/src/main/java/io/papermc/paper/threadedregions/commands/CommandServerHealth.java
@@ -0,0 +1,330 @@
@@ -0,0 +1,332 @@
+package io.papermc.paper.threadedregions.commands;
+
+import io.papermc.paper.threadedregions.RegionisedServer;
+import io.papermc.paper.threadedregions.ThreadedRegioniser;
+import io.papermc.paper.threadedregions.TickData;
+import io.papermc.paper.threadedregions.TickRegionScheduler;
@ -8740,19 +8741,18 @@ index 0000000000000000000000000000000000000000..4889ebf6e3eb5901eeac49900c541d23
+ world.regioniser.computeForAllRegions(regions::add);
+ }
+
+ final long currTime = System.nanoTime();
+
+ final double minTps;
+ final double medianTps;
+ final double maxTps;
+ long totalTime = 0;
+ double totalUtil = 0.0;
+
+ final DoubleArrayList tpsByRegion = new DoubleArrayList();
+ final List<TickData.TickReportData> reportsByRegion = new ArrayList<>();
+
+ final int maxThreadCount = TickRegions.getScheduler().getTotalThreadCount();
+
+ final long currTime = System.nanoTime();
+ final TickData.TickReportData globalTickReport = RegionisedServer.getGlobalTickData().getTickReport15s(currTime);
+
+ for (final ThreadedRegioniser.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region : regions) {
+ final TickData.TickReportData report = region.getData().getRegionSchedulingHandle().getTickReport15s(currTime);
+ tpsByRegion.add(report == null ? 20.0 : report.tpsData().segmentAll().average());
@ -8760,6 +8760,8 @@ index 0000000000000000000000000000000000000000..4889ebf6e3eb5901eeac49900c541d23
+ totalUtil += (report == null ? 0.0 : report.utilisation());
+ }
+
+ totalUtil += globalTickReport.utilisation();
+
+ tpsByRegion.sort(null);
+ if (!tpsByRegion.isEmpty()) {
+ minTps = tpsByRegion.getDouble(0);

View File

@ -1,6 +1,7 @@
Get done before testing:
- Mob#getTarget?
- regioniser->regionaliser
- make plugin add ticket mt-safe
Pre-Test: List of things not fully tested
- Task queue