Open Cyclonit opened 4 years ago
Problem: you in the same cases you get a lot of completable futures now, a single StageTracker would need hundrreds to thousands of listeners (for all the neighbors in a given radius). Since there are also thousands of cubes... you are back to the same issue.
Problem Currently, tens of thousands CompletableFutures are being created during terrain generation. Terrain generation is split up into several stages (i.e. terrain, lighting, features, ...) When a cube is generated, other cubes in its neighbourhood are required to be at certain stages during their respective generation, such that all of the information for the requested cube to be generated is present.
In Vanilla 1.15. chains of CompletableFuture are used to represent these dependencies. Due to CubicChunks introducing the 3rd dimension, these chains grow to contain tens of thousands of CompletableFutures, hog up memory and slow down the system.
Possible Solution It might be possible to replace the entire CompletableFuture system with a map keeping track of the stage of each cube. ("HashMap<CubePos, StageTracker>"). The "StageTracker" is a small object containing a reference to the Cube's current stage and allow subscribers to listen for the cube reaching a given stage.