Commit Graph

3 Commits

Author SHA1 Message Date
Aikar
23ee0a8a88
Fix issue with 0,0 chunks causing crash 2020-04-09 23:02:17 -04:00
Aikar
3b3e38fd01
Fix issue with loading chunk during ticking chunks issue
Also speed up performance of copying pending/updating to visible by
directly copying the internal array data instead of putAll
2020-04-09 20:45:46 -04:00
Aikar
ab74bb4514
Speed up processing of chunk loads and generation
Credit to Spotted for the idea

A lot of the new chunk system requires constant back and forth the main thread
to handle priority scheduling and ensuring conflicting tasks do not run at the
same time.

The issue is, these queues are only checked at either:

A) Sync Chunk Loads
B) End of Tick while sleeping

This results in generating chunks sitting waiting for a full tick to
complete before it will even start the next unit of work to do.

Additionally, this also delays loading of chunks until this same timing.

We will now periodically poll the chunk task queues throughout the tick,
looking for work to do.
We do this in a fair method that considers all worlds, not just the one being
ticked, so that each world can get 1 task procesed each before the next pass.

We also cap the throughput of these task processes to 1 per world per 0.1ms or
200 max per tick, to ensure that high volume of tasks do not overload the current
tick time.

In a view distance of 15, chunk loading performance was visually faster on the client.

Flying at high speed in spectator mode was able to keep up with chunk loading (as long as they are already generated)
2020-04-09 02:25:18 -04:00