Brainstorm: Reduce save times
Posted: Thu Jun 16, 2011 10:02 pm
This topic is meant as a discussion for those with some knowledge of RunUO and/or software design. Though anyone can input.
What I know:
1. All items/mobiles are serialized and saved as a binary world save.
2. Save times seem to take 10 sec.
3. The world has lots of items that sit in containers and never get touched or moved.
4. The server is restarted every day (I think).
My thought is to do the following is to create a system where unchanged items are not repeatedly saved. If only modified items are saved, then world saves would be far smaller...
- At server startup: All containers in the world are flagged as 'untouched'. The world save is loaded from an untouched database.
- During the server operation, any time a container is opened, moved, or otherwise changed, it is flagged as touched. This includes player backpacks, banks, boxes in houses, etc.
- Each time the world saves, all 'touched' items are saved to a separate temporary save file. Untouched items are not saved, as they have not changed.
- Each day before the server is taken down, the untouched database and the touched database are compared, merged, and saved off as a new untouched database for the next days operation. This process can be slow, as it will only happen once and only happen once players are booted.
- There would also need to be a restore functionality to relaunch the server using both the untouched database and the touched database, just in case there is a server crash. This would be, I imagine, similar to the above merge and save code and would basically be loading all untouched data, then loading touched data (being sure to overwrite any untouched that it encounters).
Obviously, this sounds easy on paper. Implementing it would be another story. I am sure there is some factor I completely missed as well...but thats why its a brain storm -_-
What I know:
1. All items/mobiles are serialized and saved as a binary world save.
2. Save times seem to take 10 sec.
3. The world has lots of items that sit in containers and never get touched or moved.
4. The server is restarted every day (I think).
My thought is to do the following is to create a system where unchanged items are not repeatedly saved. If only modified items are saved, then world saves would be far smaller...
- At server startup: All containers in the world are flagged as 'untouched'. The world save is loaded from an untouched database.
- During the server operation, any time a container is opened, moved, or otherwise changed, it is flagged as touched. This includes player backpacks, banks, boxes in houses, etc.
- Each time the world saves, all 'touched' items are saved to a separate temporary save file. Untouched items are not saved, as they have not changed.
- Each day before the server is taken down, the untouched database and the touched database are compared, merged, and saved off as a new untouched database for the next days operation. This process can be slow, as it will only happen once and only happen once players are booted.
- There would also need to be a restore functionality to relaunch the server using both the untouched database and the touched database, just in case there is a server crash. This would be, I imagine, similar to the above merge and save code and would basically be loading all untouched data, then loading touched data (being sure to overwrite any untouched that it encounters).
Obviously, this sounds easy on paper. Implementing it would be another story. I am sure there is some factor I completely missed as well...but thats why its a brain storm -_-