aternosorg / thanos

PHP library to automatically detect and remove unused chunks from Minecraft worlds.
https://packagist.org/packages/aternos/thanos
MIT License
221 stars 20 forks source link

Is there a way to delete in place? #14

Closed ChillerDragon closed 1 year ago

ChillerDragon commented 1 year ago

I did not test the tool yet tbh. But so far from checking the readme it looks like this tool goes over the whole world and copies the chunks that we want to keep. It would be nice if this could in place delete all chunks one by one. So it could be run in steps or while the game server is running. Am I missing something?

My current use case is that my 2TB world drive reached 100% usage. Going over the whole thing and copying out another world is not an option. And also in the future I would like to keep it running as a cronjob.

KurtThiemann commented 1 year ago

Running this tool on a server that is currently running is probably a bad idea. Deleting stuff in regions that are currently loaded by the server would likely cause issues, and I don’t think there is any great way of determining whether a region is currently loaded.

The reason thanos does not remove chunks in place is that this would require to load whole region files into ram. This probably would not be an issue in your case (region files only get to around 10MiB), but it becomes important when running a lot of thanos instances in parallel.

You could make something like this work by immediately replacing the input region file with the output region file as soon as it is written. I might be able to write a small example script for this later today.

Somebody also created a nodejs version of thanos some time ago, which can do stuff in place if I remember correctly. Note that the JS version is slower than the PHP version, which might be relevant considering your world’s size. I am unfortunately somehow completely unable to find that repo right now.

Before making any changes to your world using any of these methods, please make a backup.

ChillerDragon commented 1 year ago

Before making any changes to your world using any of these methods, please make a backup.

Got no disk space for that :trollface:

ChillerDragon commented 1 year ago

I assume you mean this?

https://github.com/Saiv46/node-thanos

This project is unmaintained, so it WILL DEFINENTLY CORRUPT YOUR WORLDS.

yikes

KurtThiemann commented 1 year ago

Well in that case you probably don’t want to use the node version

ChillerDragon commented 1 year ago

@KurtThiemann sorry for the comment spam ._.

The reason thanos does not remove chunks in place is that this would require to load whole region files into ram. This probably would not be an issue in your case (region files only get to around 10MiB), but it becomes important when running a lot of thanos instances in parallel.

Is this how you guys use thanos? What thanos was made for? Run a lot of instances in parallel? Why? I do not see it working for the same world file. Or do you have multiple worlds plus limited ram?

You could make something like this work by immediately replacing the input region file with the output region file as soon as it is written. I might be able to write a small example script for this later today.

would save my life :heart: no pressure tho :D

Running this tool on a server that is currently running is probably a bad idea. Deleting stuff in regions that are currently loaded by the server would likely cause issues, and I don’t think there is any great way of determining whether a region is currently loaded.

Thanks for the warning. I guess I could still schedule a maintenance downtime via cronjob and run this a few hours during night. A key feature that I still would need here is that it does not have to finish going over the whole world to delete something otherwise I am forced to do super long downtimes. Ideal would be custom offsets and partial snaps.

KurtThiemann commented 1 year ago

Is this how you guys use thanos? What thanos was made for? Run a lot of instances in parallel? Why? I do not see it working for the same world file. Or do you have multiple worlds plus limited ram?

This is what thanos is used for on Aternos: https://support.aternos.org/hc/en-us/articles/360055516791-World-option-Optimize Since there are many servers on Aternos, multiple instances of thanos will run on the same machine.

The main reason why we created thanos as a standalone program is that it needs to work with many different Minecraft versions and mod loaders, and servers on Aternos are stopped regularly anyway. The best long-term solution in your case would probably be a custom plugin that just prevents chunks from being saved if they have not been modified.

KurtThiemann commented 1 year ago

I might be able to write a small example script for this later today.

https://github.com/KurtThiemann/thanos-in-place

I know I am repeating myself, but please somehow make a backup.