Paper: Feature Request: chunk loading debugger

Created on 30 May 2017  路  7Comments  路  Source: PaperMC/Paper

I would like to request a config option for debugging what plugin is trigger chunk loads. Specifically ones without players nearby. There are a lot of methods the load chunks: https://www.spigotmc.org/threads/when-are-chunks-loaded.58342/ and some plugins might benefit to be re-coded using "World.isChunkLoaded(x, z)" instead of other methods. This would help track down what might be causing unnecessary chunk loads and therefore more lag on servers

Most helpful comment

this is easily detectable in Timings anyways. Just look for plugins that have syncChunkLoad in their tree branches

All 7 comments

I don't feel that there is really any sane way to handle this in terms of grabbing what plugin actually tried to load a chunk, the likely amount of modifications to the server that would be required to even consider actually supporting this, as well as "could we actually get the plugin that called the method without some hackery that really isn't suited for this project", especially considering (as you identified) that plugins don't necessarily cause a chunk load just because they call getChunkAt or ask for a block, the calls would likely have to be modified fairly deep to even consider providing more info than "A chunk asked for this block!", which doesn't really provide any info

later edit because brain: There are likely was that we could attempt to hook this somewhat, e.g. blatantly checking if a chunk is loaded before passing the method on, the accuracy of this is somewhat questionable as there is no guarantee of hooking all methods relevant, as well as still not solving the question of working out who is actually calling what without throwing stack traces everywhere.

damn okay, well if its not feasible just close this

@PhanaticD The problem is that a plugin may trigger an action that is common for vanilla code, and that code will load the chunk. Worse, one plugin may force another plugin to load the chunk. There's no possible formal description for an act of "triggering chunk load".

Something along the lines of iterating over Thread.currentThread().getStackTrace() would be the only reliable way of doing this I could think of. Unfortunately, walking up the stack is relatively slow in current Java versions, and is the cause of much of the overhead in throwing/catching exceptions. Hopefully this will change in the future with the StackWalking API, but for now, I think the performance may be prohibitive.

Actually, I've run some basic benchmarks, and tests seem to indicate it takes about 5 microseconds on average. It may actually be worth adding a configurable option to enable this since the overhead's doesn't seem that bad, and it could be worth it to fix the plugins causing the even slower chunk loads.

this is easily detectable in Timings anyways. Just look for plugins that have syncChunkLoad in their tree branches

Per my last comment few months ago - closing as its already possible w/ Timings.

If you want an ingame command, PR's welcome.

Was this page helpful?
0 / 5 - 0 ratings