Paper: Asynchronous way for plugins to create worlds

Created on 3 Jul 2019  路  6Comments  路  Source: PaperMC/Paper

Is your feature request related to a problem? Please describe.
I've noticed that there's lack of a way to create a new world asynchronously. While async chunks is implemented, calling Bukkit.createWorld still generates a lot of the world and spends a lot of time generating it.

Describe the solution you'd like
Exposing a method of async world generation would help solve this issue, could be exposed through PaperLib.

Describe alternatives you've considered
Using a ChunkGenerator that generates empty chunks still takes 2s (!!) on the main thread to generate. This makes generating worlds on the fly almost impossible.

Additional context
I'm willing to develop this feature if it's likely to be maintained upstream.

Most helpful comment

You can speed up world creation by calling World#keepSpawnInMemory(false) inside a listener of WorldInitEvent. In this way, I've confirmed that Paper skipped generating the chunks around spawn area.

All 6 comments

If you're in the discord, come to the #paper-dev channel and talk about this if you want to contribute PR(s).

Did you test this in 1.14? Async chunk loading in broken in 1.14 and IIRC world generation is already multithreaded.

There is a misconception with this. With the three default worlds (overworld nether and end) they all generate fine on multiple threads once loaded. However if you look at the log you see it only creates one at a time.

Bukkit.createWorld does the same process done at startup to create a world however it is similar where it takes up the entire server main thread to create the world (mainly to generate and load spawn chunks). He is talking about a create World method that runs seoerately from main thread as not to hang server.

I have just discovered keepSpawnInMemory when working on this. Seems to personally solve most of my issues, although there are two things I think that would be great to improve on this:

  1. Expose some way to skip generating the world initially with createWorld (or a paperspigot specific method/library)
  2. It does still take 35ms (on a 8700k) to generate a world which is most of a tick, personally I think there's some areas of improvement that I'll be looking at.

You can speed up world creation by calling World#keepSpawnInMemory(false) inside a listener of WorldInitEvent. In this way, I've confirmed that Paper skipped generating the chunks around spawn area.

Closing as suggestions are provided and async world creation is not going to happen.

Was this page helpful?
0 / 5 - 0 ratings