Background Saving (For those that dislike Worldsave pauses)
Hi Again, heh.
A new release of the original Background Worldsave core modification.
Please note...THIS IS STILL EXPERIMENTAL AND IT IS A CORE MODIFICATION.
For those that missed the original post, This modification saves the world in the background so your players are not interupted at all while playing (Even with the deep copy, it still does not pause).
Now thats out of the way. This one works slightly differently than the old one after battling with it all day.
When the save rolls over, it uses the Hashtable/ArrayList CopyTo method, and makes a copy of the keys and values into separate single dimensional arrays. Then it merges the two new arrays backtogether into a new Hashtable/ArrayList..
* New Findings *
CopyTo() is not a deep copy, after finally finding a reliable source out of many sources that were incorrect. So please be aware this is still a shallow copy. A deep copy requires quite a bit more work to get going (Reflection, IClonable, or Serialization), and I wont be attempting this at least for another 5 weeks. (Or I might wait until the next RunUO).
* End Findings *
The RAM jumps about 30-40MB when a save occurs, then the GarbageCollect plummets it back down when it finishes.
However, as a side effect of the deep copy, the world now takes around 0.3 - 0.5 of a second more to save. But being a background save, you dont notice it.
This was tested on a World of 150,000 Mobiles, 28,000 Items, and 1 Client.
* Further Testing *
Further testing with 30 clients has shown the RAM usage increases by about 10MB normally and on a save. And the save time does not increase from the typical 2.3 - 3.0 save times with the above world.
* End Further Testing *
The Vendor Restock, and Item Decay has been moved outside of the thread, into when the save actually finishes, and before the GarbageCollect occurs.
To install, Replace your World.cs file with mine, compile, and run.
Also do not forget to update your Autosave.cs file in your scripts, so that when a save occurs, if it is already saving, it will not try to back the files up.
Or find and replace the code that is shown below.
If you do not add the above code to your scripts, you are looking at your save and one of your backups being wiped. You have been warned.
Hi Again, heh.
A new release of the original Background Worldsave core modification.
Please note...THIS IS STILL EXPERIMENTAL AND IT IS A CORE MODIFICATION.
For those that missed the original post, This modification saves the world in the background so your players are not interupted at all while playing (Even with the deep copy, it still does not pause).
Now thats out of the way. This one works slightly differently than the old one after battling with it all day.
When the save rolls over, it uses the Hashtable/ArrayList CopyTo method, and makes a copy of the keys and values into separate single dimensional arrays. Then it merges the two new arrays backtogether into a new Hashtable/ArrayList..
* New Findings *
CopyTo() is not a deep copy, after finally finding a reliable source out of many sources that were incorrect. So please be aware this is still a shallow copy. A deep copy requires quite a bit more work to get going (Reflection, IClonable, or Serialization), and I wont be attempting this at least for another 5 weeks. (Or I might wait until the next RunUO).
* End Findings *
The RAM jumps about 30-40MB when a save occurs, then the GarbageCollect plummets it back down when it finishes.
However, as a side effect of the deep copy, the world now takes around 0.3 - 0.5 of a second more to save. But being a background save, you dont notice it.
This was tested on a World of 150,000 Mobiles, 28,000 Items, and 1 Client.
* Further Testing *
Further testing with 30 clients has shown the RAM usage increases by about 10MB normally and on a save. And the save time does not increase from the typical 2.3 - 3.0 save times with the above world.
* End Further Testing *
The Vendor Restock, and Item Decay has been moved outside of the thread, into when the save actually finishes, and before the GarbageCollect occurs.
To install, Replace your World.cs file with mine, compile, and run.
Also do not forget to update your Autosave.cs file in your scripts, so that when a save occurs, if it is already saving, it will not try to back the files up.
Or find and replace the code that is shown below.
Code:
public static void Save()
{
// Modified Piece
if ( AutoRestart.Restarting || World.Saving )
return;
// End Modified Piece
try
{
Backup();
}
catch{}
World.Save();
}
If you do not add the above code to your scripts, you are looking at your save and one of your backups being wiped. You have been warned.