PryPurity / WorldBorder

Bukkit plugin for maintaining borders for your worlds to limit their sizes, as well as generating missing chunks or trimming excess chunks.
https://www.spigotmc.org/resources/worldborder-1-15.80466/
BSD 2-Clause "Simplified" License
57 stars 15 forks source link

Use PaperLib's isChunkGenerated to prevent loading chunks already generated #45

Closed dkim19375 closed 2 years ago

dkim19375 commented 2 years ago

This method supports both Paper and Spigot 1.13+, and the project already uses PaperLib, so this isn't a large change.

Testing:

Percentage: 5% Current spigot release: 11:42 (mins:secs) PR: 2:07 553% speed increase :O Memory is also decreased from nearly the JVM limit to a low amount (in my case 6GB -> 2GB with 8GB limit) This is only while testing already-generated chunks, read the information below for more details

However, I've only tested this against existing chunks, and PaperLib's method is actually about 2-4x slower than the one used currently (since the current one is just a cache afaik), so this may not be the best for new chunks. (PaperLib: 1800ns, Current: ~500ns, varies quite a bit, but mostly 2-4x slower)

But seeing the results above, I still think that this should be implemented, although probably with a config option (since this PR would just decrease the performance if the server is up without any restarts - but if the server restarts often or isn't being hosted 24/7, then this would bring a large performance increase along with a lot less memory usage)

dkim19375 commented 2 years ago

Idea (and will probably add to this PR soon): If the chunks report never generated for 10 seconds, stop using this method and check every second or so to see if there is a loaded chunk, if so, repeat This means that a config option won't be required