-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
feat: add linear chunk format. #494
Conversation
…ment and use exception to know if file exist
…improved usability
… and adjust file truncation logic
Can you use dynamic var instead of consts? Because plugins can save some stuff with this format. |
I guess there is no problem? but exactly about what constants are you talking? (some code ref or file/line_number would be great). |
Mhh just tried to test but for some reason got it panicked saying me this |
with what software do you generate the save? (it is just thr last part i required, the real test hahaha, so this is perfect hehe) |
I used linear's own convert script |
I add the # if you choose "Linear" the compression algorithm
# is ignored and ZStd will be used.
[chunk]
file_format = "Anvil" # or "Linear" Also, i add some extra checks about the files to ensure is compatible (or otherwise get better info at least for debug). @Snowiiii if do you wanna try and give me some feedback about the new message you receive perfect, if not dont worry i will try tomorrow some tests by my self with the mc converter. |
Okey guys, some good/bad news. @Snowiiii i have to admit i dont yet try with the Pumpkin reads a lot in parallel, with anvil this is not a problem but with linear many chunks share file and its compress so you need time to read and write, this tend to create race bugs.
For all of this there is some available fixes ideas but i want/need your thoughts.
Any idea or proposition is welcome 😄. pd 1: pd 2: |
… in LinearFile and tmp filenames on write
As for now the LinearFormat look working well ( still not tested the official implementation ). But just for now it has perf issues caused by the de-allocation and write of chunks. As talked before Linear format will benefit from a some type of As an alternative i think maybe we can have some background loop managing the writes and reads in some type of queue.
Anyways this is an early idea, first i want to lookup the Anvil format code to ensure how easy or hard would be fix this from the core and not from the format impl.( basically, why are we doing so much IO ops). pd: For now i put some annoying |
The mca2linear converter was tested with the implementation (it had some bugs but now everything is okey). The last issues is about performance (tend to kick the player when the server gets saturated from IO operation) but i want to fix this issues in the next PRs (improving the chunk management and improving the |
pumpkin-world/src/chunk/mod.rs
Outdated
|
||
pub const CHUNK_AREA: usize = 16 * 16; | ||
pub const SUBCHUNK_VOLUME: usize = CHUNK_AREA * 16; | ||
pub const SUBCHUNKS_COUNT: usize = WORLD_HEIGHT / 16; | ||
pub const CHUNK_VOLUME: usize = CHUNK_AREA * WORLD_HEIGHT; | ||
|
||
// Manejador global para múltiples archivos | ||
static FILE_LOCK_MANAGER: LazyLock<FileLocksManager> = LazyLock::new(FileLocksManager::default); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, but maybe we can use the File locking crate which we also use to lock the session.lock
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will check that lib and commit the changes or ask to clarify any doubt that i could have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was reading about the lib and its says:
- Is based on a POSIX spec. (that require the other program/process use the same spec if not it can be ignorable)
- The windows version require open the file with write permission.
- Apparently the POSIX spec suffer from write starvation contrary to Tokio RWLock or DashMap.
Could happen that the writter never get the lock what in this case include accumulate thousands of threads trying to write that chunk and overheading the system.
I am happy if we want to make our own implementation with RWLock and make it global for all the crates or system. Or also make only inside the level struct.
( Its just the thing i made, may be with few improves, but is just a hash table so this dont require neither a lot of develop/LoCs nor complex stuff )
Both cases in my opinion preferable than the POSIX solution.
Overall I like your code and you did a great Job of using abstraction and not cluttering anything :D. I also really like that you write good comments and documentation for almost everything. I see some unwraps which may can be replaced but besides of that Great Work @Mili-ssm 👍 |
…currency and simplify read/write guard management
Everything looks Awesome! Thank you so much for your Hard work @Mili-ssm. I like your Code style 👍. Would love to see more from You 😄 Thank you ❤️ |
Description
Introduce a new linear chunk format and integrate zstd compression as a dependency. This enhances the compression capabilities of the project.
Just now Linear format is not integrated on any part of the project but we have the needed APIs (sames as Anvil format) to start using it.
Testing
It has its owns unit test (same as the Anvil format)
Load a linear format world to ensure the spec is well implemented
Checklist
Related: #118