Right, I've still got a lot more data to go through, but instead of enjoying the sunny weather or doing uni work, I decided to share what I've spent all day doing. I'm doing more than just this, but at least this is complete enough I can waffle about it for a bit...
Some experimentsI've done some tests in 3 locations on the server, in 3 different versions. Namely, I've tested the area immediately surrounding
/warp Qualia, as well as both Octo and Cyphur's farms (as Octo seems to be the one everyone's complaining about, and Cyohur admitted to having a large farm). I tested each of these for 30 minutes, on a clone of VC running Paper 1.14.4, Paper 1.15.2, and Vanilla 1.16 (20w15a). I'd take the 1.16 test with a very large pinch of salt, considering it's not running any of the plugins we use, and so the results aren't directly transferrable. I just included it for a comparison.
What is lag?Before I start, I'd just like to describe what lag actually is. Minecraft has 3 main types of lag: server lag, client lag, and connection lag.
- The easiest one to understand is client lag, which is simply your computer's ability to process and render everything the server tells it. If it can't do that at the frame rate you want, you'll get a lower FPS.
- Connection lag is what it sounds like, it's lag caused by your connection to the server. If you have slow internet, or like me you're located on the other side of the world to the server and have a low ping, then you'll have some connection lag. This is mostly noticeable by things having a slight delay in them
- Server lag is probably the most difficult to understand, as it can look a lot like connection lag from a player's point of view. Basically, the server has a metric called "Ticks per Second" (TPS), which is a measure of how the game is running. Minecraft is designed to run with 20 ticks in every second, meaning it's got to try and process every single change between one tick and the next, every 50 ms (0.05 s). That means every entity, every block, every chunk, every player, every item, every inventory, everything that has changed since the server last looked at it, it's got to see what's changed, check with each plugin if they want to do something about it, and then move on to the next item. If each tick's checks takes longer than 50 ms, it starts to eat into the next tick's time, which means the server runs slightly slower. If each tick took 100 ms, the server would be running at 10 TPS, meaning the game would be running at half the usually speed. This doesn't mean you're lagging, your client could still be getting 500 FPS and run as smooth as silk, but the server itself will be struggling to keep up with what's going on. Now, every so often, your client will ping the server, to make sure it's still alive, and if the server doesn't respond in time, you'll get what's called a "timeout", which will disconnect you. This isn't actually the server's fault, it's just that it didn't manage to get around to replying to your ping in time, because it was too busy doing everything else in its queue.
What affects TPS?The TPS can be affected by a lot of things, as every single line of code in the server takes a little bit of time to run, so simply banning or disabling things isn't a good solution. I'm not saying they won't work, but it's a horribly inefficient way of dealing with problems. For example, say hoppers are a problem. Sure, if you ban farms then the lag might go down, but that's only because less hoppers are being processed. However, even though it looks like farms were the problem, you would never know because too many things were banned at once. On a semi-related note, I made some changes to hoppers to significantly reduce their processing time, which looking at my status logger does seem to have helped a little bit with the lag. There's still some major changes I could make, but then it would start to have a potentially noticeable effect on gameplay, which I try to avoid at all costs with my changes. MY approach to fixing things like this is if you notice something's changed, I've done it wrong. Anyway, as I was saying, TPS is affected by millions of tiny things, and it's a long process to try and solve, so arguing over whether major changes should be made will cause us to miss the actual underlying problems.
That being said, I've noticed a lot of
childish arguments discussion about if farms should be banned, which brings me back to the point I'm trying to make in this post. I did some simple tests, and here are the results.
1. QualiaAs a baseline, I performed each of the tests at the Qualia warp point, to get a picture of how a typical area should perform. Some processing involved here will be the items in all of the showcases, and those cool little floating text things we've got dotted around Qualia.
This is the graph of the TPS and average time between ticks in all three versions (red is 1.14, green is 1.15, blue is 1.16), but this is the general summary:
Version | Mean TPS | Median TPS | Standard Deviation |
1.14 | 19.80 | 20.30 | 2.27 |
1.15 | 19.92 | 19.51 | 2.01 |
1.16 | 19.98 | 19.89 | 2.77 |
As you can see, there is very little difference between the versions, and the TPS is pretty much what it should be. Please ignore the trail off on the 1.16 chart, I messed up the test towards the end, it's not representative of the actual performance, and is simply a statistical error.
2. Octo's FarmHere, the major things for the server to process is the redstone and pistons involved in the farms, every entity that is in the farm, each of the item drops it creates, and all the hoppers and chests that are required to store all the drops. Again,
this is the graph of how it performed in different versions, and this is how it breaks down:
Version | Mean TPS | Median TPS | Standard Deviation |
1.14 | 19.52 | 19.97 | 4.29 |
1.15 | 20.03 | 20.59 | 2.97 |
1.16 | 20.06 | 20.24 | 3.44 |
There's a few things to take away from this specific experiment.
- Firstly, it appears that the farm itself
does not lower the TPS of the server, but it
does make it fluctuate more. This is to be expected. As much as I complain about Minecraft's coding, I will admit that it does try and recover from TPS drops where it can, and if possible, it'll try and run the server slightly faster some times, in order to ensure the overall average TPS is as close to 20 as possible. This is why the TPS is sometimes above 20, and why it averages out to almost 20 despite the fluctuations.
- Secondly, it appears that there is little difference between the three versions, aside from a slightly lower amplitude of oscillations in the TPS in later versions. Considering I only did these tests once, and only for 30 minutes (which already took around 6 hours), I'd take these with a pinch of salt, as you should with any experiment with no repeats. For example, if I were to only sample between 600 and 800 seconds, it would appear that 1.14 is significantly worse than the other versions, whereas if I were to sample between 0 and 200 seconds, 1.14 looks the best.
- Thirdly, it appears that Octo's farm isn't causing nearly as much lag as you all claim it to. I will admit, these tests aren't perfect, and it doesn't 100% directly correlate to what's going on on the server, but it looks like there isn't too much impact.
3. Cyphur's FarmI picked this as a third test to ensure I've got multiple data points for farms, rather than just the single one. As Cyphur admitted in a different thread that they have a large farm, I took that as an invitation to test it. Much like Octo's farm, there are a lot of things to process here, mainly entities and water flows, but this farm also includes nether portals, which will involve moving entities between worlds, which may be a source of strain on the server by requiring more chunks to be loaded and unloaded. As with before,
here is the chart, and here are the results:
Version | Mean TPS | Median TPS | Standard Deviation |
1.14 | 19.48 | 20.06 | 6.35 |
1.15 | 20.03 | 20.00 | 2.37 |
1.16 | 20.16 | 20.06 | 2.29 |
Again, there's some key points to take away from this:
- The TPS drop is relatively low, but it does fluctuate. In fact, it fluctuates the most out of all three tests on 1.14.
- This experiment is a very good example of how the average TPS can be 20, but the instantaneous TPS can vary wildly. You can see it drops down to 12 at some points, and rises to 24 at others, all of which will have a noticeable effect in gameplay in the form of lag spikes.
- In this specific instance, it appears that the fluctuations are less noticeable in newer versions of the game. This could be due to a wide variety of reasons, such as certain bugs being fixed, or optimisations in areas of the code improving performance in certain areas.
- Based on these results, it looks like chunk loading/unloading contributes to TPS fluctuations, which would correlate with the poor performance of chunks in 1.14.
Conclusions- Farms don't appear to cause a prolonged TPS drop from my tests on a clone of the server, but they do cause the TPS to fluctuate more than normal.
- TPS is affected by a variety of things, not just farms in general (eg: hoppers vs water vs chunk loading/unloading vs redstone)
- 1.15 does appear to have a marginally better performance, but not drastically. While in test 3 the performance does seem to be improved quite a bit, this same order of magnitude of improvement isn't really seen in the other two tests. Don't get me wrong, there is an improvement in test 2, but I'd expect there to be a similar trend among all three tests if performance were improved across the board.
- I personally do not see any clear evidence in here that flat-out banning farms or restricting their use to low player numbers should be enforced server-wide. Yes, it causes performance to fluctuate, but it doesn't appear to cause the significant prolonged drops we're seeing on VillageCraft. If individual farm owners want to optionally do that, then it's up to them, but I don't agree with enforcing a ban based on this evidence.
- While performance may be slightly improved in 1.15, that's not the only thing we should consider when deciding to update. We also need to consider the effort that would be needed to actually upgrade, in making sure all the plugins are ready, as well as the requirement for everyone to update to a new version of Minecraft, possibly only for a few weeks. I'll continue to think about this in the upcoming days/weeks
A bit on the testsI performed these tests on a simple clone of VillageCraft. What do I mean by that? I mean I'm running every single plugin with exactly the same configuration and options as we are on VillageCraft, as well as running the same software and server-wide options. However, I am not running the full world. Instead, I am loading a 3-region square centred around the relevant points in the relevant worlds (1536x1536 blocks). This was done for two reasons, firstly, most of the world would be unloaded anyway, so there wasn't too much benefit in including it; and secondly, our worlds are probably way over 200 GB right now, and while I do enjoy data hoarding, and as much as it would please me to have that full clone, I do not have anywhere near enough patience to download it all over my slow internet connection. All the tests were performed with the same Java parameters as we use on VillageCraft, and the 1.14 and 1.15 tests were performed with the same amount of physical RAM as we have on VillageCraft. Due to an oddity with how Vanilla allocates RAM compared to Paper, combined with the fact I only have 8 GB of RAM, I had to run the 1.16 test on a lower memory. That being said, it did still perform well, so if run on exactly the same configuration I imagine the performance would be even better. This lower RAM is probably the reason for the occasional lag spikes, where I suspect some GC was being performed. While I did try and match all those settings, there are some other things I didn't match, partly because I couldn't be bothered, but mainly because I actually couldn't match them. I can't match the server's hardware (CPU, etc), which will likely have quite a large impact on the results, but also VillageCraft runs on Linux, on server-grade equipment, whereas I'm running this on macOS on a 7-year-old desktop computer. That too could have a potential effect. Finally, due to the way I'm collecting this data, there are some occasional spikes in TPS which claim to reach in the order of 10
4. These are clearly outliers in the data, created by the fact I'm using a very simplistic method to calculate TPS at every tick. To overcome this, I've filtered the TPS (but not time since last tick), to remove any obviously wrong values. If I were doing this properly, I'd use a low-pass filter with a very low cut-off frequency, but I didn't really feel like coding that, and this data is too different to the low-pass filters I've used before to be able to copy-and-paste that. So, I used the cheap method of (if the TPS is over a certain limit, just set it to be the same as the previous value), which seems to work nicely. It does annoy me though, but I've already spent long enough on this.
TL;DR: Farms don't seem to cause prolonged TPS lag, but they do cause fluctuations, which may be slightly visible in-game depending on what else is going on. TPS lag comes from millions of different sources, and finding out what's actually causing the lag and solving that problem is much harder than you think, and banning major things like farms won't actually solve the problem, but rather hide it until it shows itself some other way. Finally, on a personal note, I'd appreciate it if you all stopped arguing over this and speculating as to what you think is causing the lag, and just let me actually try and solve it using the data I have. If you've got any comments or things you've noticed about the lag, I'd love to hear from you about it. PM me on here, or on Discord (@Luis). I'm all ears.
As always, I'm continually working on the back-end of the server, making changes every few days based on the data I have available, to try and solve the lag. There's a good deal of things that I'm doing to fix it that won't really show up in-game, but trust me, I'm doing stuff about it. I've still got a bunch more things I'm investigating, and will continue to tweak things as I go