-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Feature Request] Time per tick (NOT TPS) #39
Comments
Something that makes this even harder is that this API was introduced in 1.15 - it does not exist in 1.13 or 1.14 versions of Paper. It does look like the raw data was available back in 1.13: src/main/java/net/minecraft/server/MinecraftServer.java: public final long[] d = new long[100]; In 1.15 (Paper), it's declared as: public final long[] f = new long[100]; public long[] getTickTimes() { return f; } // Paper - OBFHELPER Currently this project is compiled against 1.15 Spigot API, but also runs fine on both my 1.13 server and my 1.15 server, because it just uses the API. I just recently found this project and it's awesome. I see a few different options, and I'd like to know how @sladkoff wants to proceed: Option 1 - Use reflection to check if CraftServer has a getTickTimes() API (i.e. is Paper 1.15+). If so, use it, otherwise don't provide this metric. This would mean this feature will only be available on Paper, but would likely not require any maintenance (it'll likely work for all future versions of Paper too). It won't work on earlier versions. Option 2 - Use reflection to drill down into the main Minecraft server class, and look for a long array. If it's there, use it as the last tick times. This would likely work for both spigot and paper, but might randomly break for new versions later. It's also a bit more work than option 1. Option 3 - Build a proper version adapter, which checks the minecraft server version and then applies the appropriate reflection (i.e. Server.f, server.d, etc.). This would probably be a pain to maintain, but it'd be a little bit cleaner code and less prone to errors. I'd propose either 1 or 2. Any other ideas? I might be interested in helping with this. |
@Combustible I think we can always start out with option 1. I'd be fine with it if it's only available to Paper at first - I may be biased 😄 This could later be extended to something similar to option 2 or 3. You already summed up the pros and cons perfectly and I'd probably also go with 2. I'm all for cleaner code as in 3 but I don't really see a good way to maintain such a thing without full-blown integration tests against the respective server implementations. |
Added a pull request for option 2 - Was worth the small amount of extra effort since I still have a 1.13 server I want to use this on. |
Something I just noticed, it looks like 1.16 is adding an MBean which will expose https://minecraft.gamepedia.com/Server.properties#Minecraft_server_properties
|
Thanks to @Combustible for #41 |
Describe the solution you'd like
Obtain a metric for time per tick.
Describe alternatives you've considered
This is not the same as ticks per second. As TPS has an upper bound of 20, it does not give you enough resolution to monitor the performance in detail. In fact, by using TPS, you can only detect performance issues once TPS starts to drop, and by then it's impacting your clients. The intent of measuring time per tick is to detect when server performance is approaching the threshold upon which it will impact your clients.
Additional context
The caveat is obtaining this metric. If using Paper, then obtaining it is actually easy as Paper exposes these metrics: https://papermc.io/javadocs/paper/1.15/org/bukkit/Server.html#getTickTimes--
...which they use for the
/mspt
command:However if using spigot, then it's not quite so simple. I found this post https://www.spigotmc.org/threads/get-ms-tick-of-server.428642/, so maybe some reflection could be used to pull the data. Certainly not pretty.
The text was updated successfully, but these errors were encountered: