-
Notifications
You must be signed in to change notification settings - Fork 1
GH-45 Backport Paper 1.13.2 Async Chunk Generation (and Loading) (Resolves #45) #86
Conversation
After testing a bit in production, everything seems to work fine |
Can be reproduced some times by creating a world with Multiverse-Core (/mv create worldname normal) |
This patch should fix this - that exception just can't appear in any other situation. Also from my small investigation Multiverse-Core don't do anything with BiomeDecorator or something. |
So @LewUwU are you using Titanium or just this patch? If second option check the result when you use patch mentioned above |
Just this patch, i fixed it by allowing concurrently access to the BiomeDecorator but your option should fix some unknown bugs |
Okay, so if everything will work I will merge this PR in a few days |
After viewing some Spark profilers with this patch, there's only lag spikes in Chunk#loadNearby (up to 1k ms), i will see what can be done to optimise that method |
After looking a little in code there is no much calculations - probably chunks are loaded synchronously, but I have to make sure |
AFAIK there's chunk population in that method (Also we should change the isChunkLoaded to getChunkIfLoaded) |
Oh, yeah. And why getChunkIfLoaded? I don't get the reason why 🤔 |
isChunkLoaded -> getChunkAt can be replaced by getChunkIfLoaded |
Right, I did that and everything looks fine - but despite that it's still have to be optimized even more |
I have no idea how we could optimise this even more - we would probably have to optimise decorating (so generating trees etc.) or find a way to do that asynchronously |
The generators should be recoded to support async gen too, some biomes decoration got buggy after being generated (water lily in the air and etc) |
I know it should, but it wouldn't be easy. However, after looking deeper in the spark, it looks like sometimes even 50% are used by ore generation. So maybe there, I'll try to optimize that. Oh and after testing I can't reproduce that flying lilypads 🤔 |
I'll try to add some micro optimizations, but currently I don't have any more ideas how to optimize chunks decoration. So I'll merge this PR and optimize terrain decoration in the future. Currently we probably didn't save much performance, but maybe a little by offloading terrain generation to async threads... At the beginning I have to revert this patch (this part with dirty blocks) - where I replaced array with map from fastutil... Later I have to think about a way to set blocks in bulk (to do some calls once, not every block set) |
So I optimized chunk decoration (probably only a little, but it's still something). Now we have to pray that everything still works (mostly ore generation). And like I said, I will merge this branch soon. We actually made terrain generation more efficient - before the server couldn't have stable 20 TPS when terrain generation was done synchronously. Optimizing chunk decoration would be great, but unfortunately I don't have much time to think how to actually do that. In best scenario I would somehow do that asynchronously, but we have to think realistically. |
To the moon! 🌕✨ |
#45
Finally after lots of tries I achieved Async Chunk Generation (1 thread per world) by backporting Paper 1.13.2 Async Chunk System (thanks for idea @LewUwU). When I will be sure everything works fine I will merge this to
dev
.Titanium with this patch can be obtained from Jenkins