Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Chunk management improvement #256

Open
gentlegiantJGC opened this issue May 19, 2022 · 0 comments
Open

[Feature Request] Chunk management improvement #256

gentlegiantJGC opened this issue May 19, 2022 · 0 comments

Comments

@gentlegiantJGC
Copy link
Member

gentlegiantJGC commented May 19, 2022

Feature Request

The Problem

The way we store chunks is not the optimal solution.
We have a dictionary of chunks in RAM which needs to be manually cleared to minimise memory usage.
Chunks that do not exist and chunks that error during loading are both handled as None in the storage leading to the chunk being fully loaded each time and throwing the error each time.

Feature Description

Switch to a weakref dictionary so that chunks are automatically unloaded if unreferenced.
Add a dictionary in the world to store references to chunks that have changed so that they are not automatically unloaded.
Perhaps store a small buffer of chunks so that frequently accessed chunks do not get unloaded immediately. collections.deque
Switch chunk storage to distinguish between null chunks, error chunks and valid chunks.

This would move the management of the change state out of the chunk and into the level so #257 would need to be implemented to make the old changed method work however I think it would be best if it was depreciated and replaced with level.put_chunk.

Here is a prototype including this
https://gist.github.com/gentlegiantJGC/d0f0b6d34db696b5e5d41d166a0033e0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant