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

Open region file represented with []byte #130

Closed
maxsupermanhd opened this issue Nov 23, 2021 · 8 comments
Closed

Open region file represented with []byte #130

maxsupermanhd opened this issue Nov 23, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@maxsupermanhd
Copy link
Contributor

Hi, I am making http accept for regions and I want to parse it on the fly, is it possible?

@Tnze
Copy link
Owner

Tnze commented Nov 23, 2021

Theoretically, yes. The current API, no.
Can you explain why you want to do this? Is this a performance bottleneck? Parsing data on the fly will make memory occupied larger, because parsing does not access data in a completely linear order.

@Tnze Tnze added the enhancement New feature or request label Nov 23, 2021
@maxsupermanhd
Copy link
Contributor Author

maxsupermanhd commented Nov 23, 2021

I am working on server that stores chunks, basically a live world backupper and map. Clients submit chunk/region data to it and it stores raw byte arrays of them in database (takes very little space apparently compared to files on disk, 250mb to 1.7mb). I already made server manager, dimension manager and chunk storage. Already implemented map rendering by just literally ripping out example that you have and slapped monkey-primitive scaling to it and cut out threading because leaflet already threads it just by requesting a lot of tiles (5-8) at the same time.
I decided to implement region structure submit too because it is more optimal to do so if I have loads of chunks, it helps avoid rate limiting if present and theoretically faster because less http request/resonse mess. Single upload - 32*32 chunks dropped to database (takes up like 15 seconds to fully process region in single thread).
Currently I made it work via temp file: dropping http body to file and them feeding it to region reader and cleaning up when done.
This is what I currently have already: (rendered on the fly - no caching yet lol) image
(yes it is watercubed obsidian monument from simplyvanilla.net)

@Tnze
Copy link
Owner

Tnze commented Nov 24, 2021

Sounds like a incremental backup system.

I don't quite understand. But it seems that the unit you read and process should be a single Chunk, that is, 16*16 Blocks. When store them into the database, render the map and cache it. In this way, when requested by leaflet, you only need to simply return the generated image.

@maxsupermanhd
Copy link
Contributor Author

It actually is an incremental backup system for chunks. You understood everything correctly, data "unit" is a Chunk. In order to optimize Chunk submitting to the system I thought about sending over whole region file and parsing and breaking it up on server to compensate on traffic usage.

@Tnze
Copy link
Owner

Tnze commented Nov 25, 2021

And this is the reason why you want to parse mca files on the fly.

I decided to implement region structure submit too because it is more optimal to do so if I have loads of chunks, it helps avoid rate limiting if present and theoretically faster because less http request/resonse mess.

But block changes area usually are limited to the size of Chunk, aren't they? Submit the hole Region could increase the IO pressure.

Considering the first submitting, the http mess that you say could happen. You could packet chunks together in your own ways to avoid that mess. In this protocol, the coordinates of blocks are represented separately, so region cannot be used -- it can only store adjacent blocks.

@Tnze
Copy link
Owner

Tnze commented Nov 25, 2021

And parse regions on the fly will be support. I am working on it.

@maxsupermanhd
Copy link
Contributor Author

Also speaking of chunks and loading, there is no support for uncompressed nbt int chunk load method.

@Tnze
Copy link
Owner

Tnze commented Nov 25, 2021

Commit 684d257 support parsing regions in memory. You may need to find an implement of io.ReadWriteSeeker, which doesn't exist in standard library as I know.

The loading and parsing of Chunks are still semi-finished products. The reason as you can see, due to frequent changes between versions, it is not easy to maintain. It also related to #110.

@Tnze Tnze closed this as completed Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants