369 Commits

Author SHA1 Message Date
Aaron Suen
1d4d467662 Fix wrong mod description 2024-10-20 11:56:58 -04:00
Aaron Suen
68eb61b873 Remove stub settingtypes.txt files
These were intended to make it possible to access these settings
in the MT settings UI.  However, apparently it's not possible to
have nil as a default, and MT throws warnings in this scenario.
Remove these settings until that's properly supported.
2024-10-20 11:50:28 -04:00
Aaron Suen
e0b62ae63f Remove stray print statement 2024-10-10 10:07:40 -04:00
Aaron Suen
d4081a4d71 Fix missing default log level 2024-09-30 08:12:15 -04:00
Aaron Suen
e30d8a69d5 Make lagometer config fully dynamic
Reload config automatically and honor any changes immediately.
2024-09-30 06:19:56 -04:00
Aaron Suen
1872d97167 Allow lagometer log level adjustment 2024-09-30 05:51:43 -04:00
Aaron Suen
97e34c522e Fix accidental total doubling 2024-09-22 10:22:38 -04:00
Aaron Suen
2f6901c881 Publish to log, refactors and corrections
- Fix: don't trim off one extra sample (size instead of size+1) of
  sample buffer.
- Restructure to fix scope proliferation of variables.
- Support publishing to JSON and MT log on custom intervals,
  enable publishing to log by default.
2024-09-22 09:52:17 -04:00
Aaron Suen
1cd37933cd Show full hash version if available 2024-09-21 23:47:41 -04:00
Aaron Suen
cec95761d1 Clean up and unify offlinepos expiry
There was a redundant expiration check that was hitting the auth
database rather intensely every 5 seconds ... reduce that to check
only one player name per globalstep to spread it out.
2024-09-21 00:41:04 -04:00
Aaron Suen
82f277c1ab Add command to analyze lua entities 2024-09-18 07:48:40 -04:00
Aaron Suen
587c85411b Rename and document entity step statistic 2024-09-16 06:36:11 -04:00
Aaron Suen
fa38b7f4d4 Show count of entities that actually step 2024-09-16 00:16:41 -04:00
Aaron Suen
5e2378f278 Missing newline 2024-09-13 07:50:11 -04:00
Aaron Suen
9d23422d44 Update documentation 2024-09-13 07:28:06 -04:00
Aaron Suen
81b3bc1a6b Add mtbs statistic, remove useless n statistic
- The number of total steps is not very useful, and is redundant
  with the average across steps when uptime is >= report_period
- Add "mean time between steps" statistic, which is averaged
  across time over the reporting period instead of across the
  count of steps.  It more accurately represents the subjective
  impact of rare large outliers on the overall experience.
- Rename "mean" to "avg" since it's shorter, and we now have two
  statistics named "mean".
2024-09-13 07:13:31 -04:00
Aaron Suen
cf819b357d Set Z indexes for all HUDs 2024-09-13 07:00:26 -04:00
Aaron Suen
c678e56633 Update lagometer immediately on changing privs 2024-09-12 08:30:20 -04:00
Aaron Suen
15fbc75583 Multiple lagometer modes
- It's now possible to toggle the histogram separately, so it can
  show 3 effective modes: off, basic, and full.
- There's now a separate priv to give users access to only the
  summary lines.
- User preferences are tracked independently of privilegs so that
  they can be adjusted even when limited by privs, and modes can
  be restored automatically when privs are changed.
- User preferences are applied immediately when changing modes,
  rather than waiting for the next interval.
2024-09-12 08:24:32 -04:00
Aaron Suen
ad467a239a Fix quantile calculation again
The first number should always be only the very first, lowest
sample, and the top the very last, largest.  There are only 4
different "intervals" between the numbers.

This calculation is finally verified to get the top and bottom
numbers correct.  It should logically follow that the inner
numbers are some form of correct, though whether they are biased
on where they land between samples is possible, but probably
irrelevant.
2024-09-12 07:56:47 -04:00
Aaron Suen
d6ba171de5 Change how lagometer collects and reports statistics
Before, we were accumulating time into "buckets" during globalstep
to limit the maximum amount of data we were handling, and make the
job of building the histogram a lot easier.

This unfortunately caused some issues with the new statistics like
mean (which can't see into the topmost bucket that captures
everything oversized) and quantiles (that are similarly capped, and
limited to bucket granularity)

Instead now, just do the simpler thing of capturing each globalstep
dtime as a distinct sample in an unordered list.  Each reporting
interval, we shift the list to prune off old samples, and then
compute statistics the "hard way", including sorting to produce the
quantiles.  This is a bit cheaper on the globalstep side but a bit
more expensive on the reporting side, but should still take only
about 1 millisecond or so on real-world systems.

The statistics produced, especially mean and quantiles, are much
more accurate, and a bit more precise.
2024-09-12 07:13:46 -04:00
Aaron Suen
413bea3396 Add a small separation between histogram and summary lines
Also add a warning in documentation about the summary statistics
being approximage, in case somebody tries to do the actual math
and finds it doesn't quite match up.
2024-09-11 07:39:48 -04:00
Aaron Suen
255a25df45 Cleanup, remove debug logging 2024-09-11 07:26:48 -04:00
Aaron Suen
6de95c0967 Add mean and quantile statistics, document 2024-09-11 07:22:51 -04:00
Aaron Suen
d24cecdb0e Fix vignettes covering other HUDs 2024-09-06 08:51:14 -04:00
Aaron Suen
637ee58eb4 Defensive strict key counting
The documentation says something about "indexed by ID", and we
shouldn't assume that IDs will remain sequential/compact, so we
should technically count the keys rather than assuming that the
"array part length" indicator will always be correct.
2024-09-06 08:41:37 -04:00
Aaron Suen
8405950549 Add connection and entity count 2024-09-06 08:30:35 -04:00
Aaron Suen
d651dbc86a Add a simple lua mod 2024-09-05 19:54:48 -04:00
Aaron Suen
3b6ae83250 Configurable lagometer padding, match namehud
This moves the HUD away from a "status line" area at the very
bottom of the screen that mods may use for other purposes.
2024-08-28 05:19:51 -04:00
Aaron Suen
068dd46ec1 Fix race between player purge and reregister
If a player quits before agreeing to the terms, and gets added to
the purge queue, but then reauths immediately, they can get
re-purged before they finish emerging, causing an assert fail on
trying to record their last login time.

If a player re-registers, immediately remove them from the purge
retry queue, so their login time can safely be recorded.

Also, if the server shuts down with incomplete players in the
"lobby", then add them all to the purge queue too.
2024-08-27 07:16:09 -04:00
Aaron Suen
96537348d3 Announce up again if we announced going down 2024-08-26 07:36:43 -04:00
Aaron Suen
689ca57052 Use disconnect, not kick 2024-08-26 11:06:51 -04:00
Aaron Suen
c7dbd1c84d Prettier format markdown 2024-08-26 00:32:26 -04:00
Aaron Suen
e050b0b536 Bump player last access upon successful auth
Even if the player fails to finish emerging, as long as they
managed to log in, keep their account alive.
2024-08-24 21:28:28 -04:00
Aaron Suen
0892d19ded Kick-then-delete doesn't actually work
After we kick a player, then an async process of shutting down that
player's connection is initiated, and their player data is flushed
to the database AFTER that.  If we remove the player data at the
same time as kicking, it's not actually removed, but the auth IS
removed, so we have a bunch of player data left behind that we
don't realize, and there's no mod-API way to enumerate them.

For now, just disallow this use case.  The time between calling
/kick and /destroy_player should be sufficient to avoid the race
condition, at least, for now.
2024-08-24 21:25:36 -04:00
Aaron Suen
d161b83a90 Increase GC intervals
We're already kicking off GC on startup, and it shouldn't be able
to get way out of hand within an hour, so we don't need to scan
quite so intensely.
2024-08-24 14:32:10 -04:00
Aaron Suen
35d3b98190 Include MT version in lagometer JSON 2024-08-24 12:54:08 -04:00
Aaron Suen
f825b2e6cd Garbage collect removed players from mod_storage
There are a number of mods in the pack that store metadata about
players "inside out", in mod_storage instead of player:get_meta,
because player meta is not accessible when the player is not online
and that's necessary for some mods.  Player meta is also tied to
the "player character" and not to the auth account, so inside out
storage is necessary when we want data to survive resetting the
player character while keeping the account.

Unfortunately, this prevents MT from automatically cleaning up
the metadata when a player is destroyed, which can happen for
various reasons outside the control of the mod.  This can cause
keys to accumulate in the mod storage database, which may hurt
performance over time.

To keep things tidy, periodically scan the mod storage keys for
each such mod (add a scan cycle, or integrate with an existing
one) and automatically clean up old mod storage keys.

szutil_xplevel was already doing this on startup and command;
convert it to do periodic scans like the other mods.
2024-08-24 12:18:52 -04:00
Aaron Suen
1c455a4303 Cache MT version info
We don't have to fetch this each publish cycle, as it won't be
changing during runtime anyway.
2024-08-24 11:22:01 -04:00
Aaron Suen
ef9fc2e0a1 Lagometer improvements
- Rearchitect so that we generate a list of lines as a separate
  process from displaying them, so that we can add new things
  beyond just the bucket graphs.
- Display cached lagometer to players as soon as they join instead
  of having to wait for the 2 second "cold start" before seeing
  anything.
- Add a status line to the bottom of the lagometer with live
  display of things that would be in /status.
- Add the status line things to the JSON dump too.
2024-08-24 11:19:47 -04:00
Aaron Suen
ba84178768 Image filters and optimization 2024-08-22 06:54:20 -04:00
Aaron Suen
543f5cfd5f Announce empty server on restart if needed
When an MT server shuts down, it doesn't always kick the players
and announce their departure before the shutdown process runs,
so it's possible for players to be "connected" at the time the
server actually stops running mod code.  This means that there is
no opportunity to announce that the server is now empty once it's
actually shut down.

Here we assume that in most cases, the server will be brought
back up immediately, and better late than never.  If there were any
players online at the time the server was shut down, announce the
server status (i.e. that it's now empty) upon the next startup.

This should mitigate the issue where a a player joins the server,
then the server is shutdown silently, and then the same player
joins again, making chat logs nonsensical.  At least this way
you will see that the player is no longer connected at some point
before they reconnect.
2024-08-20 07:46:38 -04:00
Aaron Suen
c0e717fe27 Publish lagometer JSON file
If the szutil_lagometer_publish_json setting is enabled, write a
JSON file to the world path with lagometer data every publish
cycle, so that external systems can access it.

Also fix formatting issues in the lagometer format string.
2024-08-20 07:00:39 -04:00
Aaron Suen
1ccad0ca3c Cleanup 2024-08-17 22:37:42 -04:00
Aaron Suen
8c2d3f32ae Fix szutil_motdagree purge feature
It seems like auth was being purged, but not player data.
I found 2 possible issues:

- The "cache" table was having keys removed while it was being
  iterated, which could cause skipped pairs.
- I noticed a delay in player data being written to the database,
  so I wonder if write-behind player data was being inserted
  after the deletion was attempted.

The net effect was that player auth data was apparently being
purged reliably, but player character data was being left behind
and cluttering up the database.

To try to fix this, fix the table mutation/iteration conflict,
and schedule multiple deletion retries (for about 15 seconds) to
ensure we really get it.
2024-08-17 22:29:56 -04:00
Aaron Suen
575b3e48ad 5.9.0 hud_elem_type field compatibility 2024-08-15 07:32:55 -04:00
Aaron Suen
ac6fbe3ffe Fix teleport tracking upper bound check 2024-07-27 23:26:11 -04:00
Aaron Suen
5a8700f1e3 Convert CDB screenshot to webp 2024-07-27 13:23:09 -04:00
Aaron Suen
5009244783 Add a chat command to write to the log 2024-07-27 10:23:28 -04:00
Aaron Suen
3260c78125 Log players agreeing to terms 2024-07-27 09:55:16 -04:00