Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance: StructurePicker task consumes LOT of cpu time because it calls SyncChunkLoad #161

Open
BigScary opened this issue Feb 15, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@BigScary
Copy link

Timings Report:

https://timings.aikar.co/dev/?id=4c90887539aa420fa5dd3f9040d8e3a9

Above you can see the plugin taking 20-25% of all server CPU time. That's versus .5% to 1% for other plugins.

More specifically this bit:

image

Probable cause:

Probably you're not calling chunk.load(), but you're doing something like world.getblockat() which causes a chunk to be loaded, and the server main thread stops doing everything else while that chunk loads up from disk.

Suggestion:

If you call the paper API's async method instead, you can say like "load this in the background, and when it's done, then run this other code that needs the chunk". Using that API does NOT mean your plugin will only work on Paper servers, it will continue to work same as it does today on spigot and craftbukkit but Paper servers will go super duper fast again.

https://jd.papermc.io/paper/1.19/org/bukkit/World.html#getChunkAtAsync(org.bukkit.Location)
https://papermc.io/using-the-api

Alternately, you might find that you don't really need to load a chunk at all for whatever it is you're doing in StructurePicker, or you might find a way to run this StructurePicker task less frequently for less overall impact.

@BigScary BigScary added the bug Something isn't working label Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant