Skip to content

Only consider chunks Loaded if at BORDER status#4320

Merged
aikar merged 2 commits into
masterfrom
loaded-chunks-improvement
Sep 19, 2020
Merged

Only consider chunks Loaded if at BORDER status#4320
aikar merged 2 commits into
masterfrom
loaded-chunks-improvement

Conversation

@aikar
Copy link
Copy Markdown
Member

@aikar aikar commented Sep 13, 2020


DOWNLOAD LINK: https://cdn.discordapp.com/attachments/748269415497465927/754945012080312370/loaded-chunks-r2.jar

While initial smoke test looks to be ok, this build presents a high risk of entity and tile entity lost if there is a bug that I did not see in my own testing.

It is super imperative that you have backups before testing this!


This greatly improves performance as it drastically reduces the amount
of Entities and Tile Entities that are "registered" into the world, as
purely "cached" chunks will no longer have their entities hanging out in the world.

Additionally this fixes our Entity Add To World and Entity Remove From World events

Those events have not been firing correctly since MC changed how chunks work here.

Now the server will only consider a chunk "loaded" if it's got a ticket putting
it at level 33 or lower, which matches the public Bukkit API.


Before this, there are a ton of chunks in memory in a 'cached' state, they aren't considered "loaded" in the api, they arent in any players view distance, are not force loaded.

When they are loaded and unloaded don't align with our expectation of "load/unload" events.

Leaving A LOT of extra entities in memory. meaning more entities to iterate for ticking (which will then be "skipped" because not in correct chunk") same with tile entities. also same issue applies for iterating chunks too, iterating far more than will end up being ticked resulting in a lot of checks to then skip it.

This change cuts it out so the iteration only operates on stuff in a loaded state now.

@aikar aikar added scope: performance version: 1.16 Game version 1.16 version: 1.15 Game version 1.15 labels Sep 13, 2020
@aikar aikar requested a review from a team as a code owner September 13, 2020 02:28
@aikar aikar self-assigned this Sep 13, 2020
@aikar
Copy link
Copy Markdown
Member Author

aikar commented Sep 14, 2020

Updated test build with fix for the only reported crash so far. This specific detail wasnt the important part of testing, so took this one change out for now to keep build stable so we can test the important stuff

https://cdn.discordapp.com/attachments/748269415497465927/754945012080312370/loaded-chunks-r2.jar

This greatly improves performance as it drastically reduces the amount
of Entities and Tile Entities that are "registered" into the world, as
purely "cached" chunks will no longer have their entities hanging out in the world.

Additionally this fixes our Entity Add To World and Entity Remove From World events

Those events have not been firing correctly since MC changed how chunks work here.

Now the server will only consider a chunk "loaded" if it's got a ticket putting
it at level 33 or lower, which matches the public Bukkit API.
Adds final to some methods to improve inlining ability
@aikar aikar force-pushed the loaded-chunks-improvement branch from a50fd75 to a183920 Compare September 19, 2020 16:44
@aikar aikar merged commit bd648df into master Sep 19, 2020
@aikar aikar deleted the loaded-chunks-improvement branch September 19, 2020 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: performance version: 1.15 Game version 1.15 version: 1.16 Game version 1.16

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants