Table of Contents

Class PerformanceMonitor

Namespace
McServerLauncher.Services
Assembly
McServerLauncher.dll

Decides from several signals whether a server is coping, and says which one convinced it.

public sealed class PerformanceMonitor
Inheritance
PerformanceMonitor
Inherited Members

Remarks

Pure and without a clock: every call says what time it is, so a test can run an hour in a few lines. It only ever reports something sustained — the whole point is to warn before players complain, not to flash red for the spike every server has while it loads a chunk.

  • No judgement for Grace after the server says it is ready, nor while a backup runs and for AfterBackup after it: both are lag the owner asked for.
  • Ticks: TPS under 18 or MSPT over 50 is Saturated, TPS under 19.5 or MSPT over 40 is Tight. It takes two bad readings in a row from spark (which already averages a minute) and three from the others; two good ones clear it.
  • "Can't keep up!": three or more in five minutes is Saturated, one or two Tight. A delay over a minute is a clock jump (the PC waking from sleep), not lag.
  • CPU: 90 % for two minutes is Saturated, 75 % for three is Tight. Measured in time, not in samples, because a window in the tray samples every 20 s.
  • Memory: judged from the GC log by MemoryPressure (the heap nearly full after collections, the collector taking over a tenth of the time, a full collection), and on its own only Tight. The process's memory cannot say this: a healthy Java process looks full.
  • Out of memory is Saturated at once.

Fields

AfterBackup

How long after a backup ends nothing is judged.

public static readonly TimeSpan AfterBackup

Field Value

TimeSpan

Grace

How long after "Done" nothing is judged.

public static readonly TimeSpan Grace

Field Value

TimeSpan

Methods

AddCpu(DateTime, double)

One reading of the processor, 0–100 across all cores.

public void AddCpu(DateTime now, double percent)

Parameters

now DateTime
percent double

AddGc(DateTime, GcEvent)

One collection from the GC log. See MemoryPressure for what counts.

public void AddGc(DateTime now, GcEvent e)

Parameters

now DateTime
e GcEvent

AddLagWarning(DateTime, TimeSpan)

The server warned that it is behind by behind.

public void AddLagWarning(DateTime now, TimeSpan behind)

Parameters

now DateTime
behind TimeSpan

AddTickReading(DateTime, TickSource, double?, double?)

A reading from the server itself. Either figure may be missing.

public void AddTickReading(DateTime now, TickSource source, double? tps, double? mspt)

Parameters

now DateTime
source TickSource
tps double?
mspt double?

BackupEnded(DateTime)

A backup ended; lag that follows is still the backup's.

public void BackupEnded(DateTime now)

Parameters

now DateTime

BackupStarted()

A backup began.

public void BackupStarted()

Evaluate(DateTime)

The verdict at now.

public PerformanceStatus Evaluate(DateTime now)

Parameters

now DateTime

Returns

PerformanceStatus

IsJudging(DateTime)

False while the server is settling, stopped or being backed up.

public bool IsJudging(DateTime now)

Parameters

now DateTime

Returns

bool

OutOfMemory()

The server ran out of memory.

public void OutOfMemory()

Ready(DateTime, long)

The server finished starting. Resets everything the last run left.

public void Ready(DateTime now, long ceilingMb = 0)

Parameters

now DateTime

When.

ceilingMb long

The heap ceiling it runs with, for judging how full the heap is. 0 when unknown.

Stopped()

The server stopped. It is not judged until the next Ready(DateTime, long).

public void Stopped()