RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Concept: Move Statics to own Bin-File

HSOdin

Wanderer
Concept: Move Statics to own Bin-File

Hello,

yesterday on my way home from work, I had a fancy idea about increasing the speed of worldsaves.

The main problems are the I/O-operations, they cost most of the time. So we could probably avoid unnecessary ones.

What could be for example unnecessary? Statics/LocalizedStatics.
On my shard e.g. there are very much Statics/LocalizedStatics and they normally don't change (they are not named Statics for no reason ;))

So my main idea was to put Statics to own binary files (maybe also differenced by Map) and to resave this files only if a GameMaster removes, adds or modifies one.

To increase the performance we could also create a new Dictionary in World.cs similar to m_Items where we save all the Statics, which should be now no longer in m_Items.
Single problem here: We have to check every reference of World.Items if it's still valid and we have to think about the Serial.cs how the Statics will get their Serial (maybe here we need also modifications in Item.cs!).

Then we could easily modify the Backup-Method (so that it doesn't remove the Statics-Files on Backup, if they don't change) and the WorldLoad/WorldSave-Method.

What do you think about this idea? Did I forget anything?

I'm looking forward to your feedback :)

Bye,
Odin
 

razzles

Wanderer
Freeze the items rather than make a complicated work-around that will still have to send item packets to players for each of these items.
 

Acronis

Sorceror
When you do [tile static it's just items. (static is a missleading term for these as actual statics are part of the client files)

You can either freeze then force people to patch, or to avoid the hassle of people having to download and swap files around try to avoid using statics for world building and use house plots instead.
 

HSOdin

Wanderer
yeah, that was exactly what I was writing about... I know that the class Static is a subclass of Item.

Here in Germany our players like quality, not quantity, so every building is custom.

Of course we freeze Statics, but we also have a quest staff which has a lot of temporary buildings.
 
thing is, by the time it checks through to see if any statics have changed, if could have writen the whole save routine for both of the seperate saves

so might as well just keep together
 

HSOdin

Wanderer
you don't need to check as many things... statics are simple items and many properties of the class Item are useless vor the Class Static...

How could you check if statics change? You could have a global Boolean which indicates, if they changed or not.

This boolean can be set to true in the Static Constructor (if an item is added) and you can also override the important properties like Delete(), Name, Hue etc.

But I guess performance isn't a really important fact for this community. (As I also saw in the threads about serialization to a SQL DB)
 
by the time you check if any static has changed (which means reading each and every one to see of the bool is true) you could have all ready wrote them also
plus, since statics are also items, as you go through all items, have to check to see if they are static and if so do not write them

so you are reading all static 2 or 3 times, once not to be put in with items, then 2nd time to see of any are modified (of cource can break out early on this once one is ture) and then possible 3rd time if there was one changed

and like i said, by the time you do all that, they could just be saved with all the rest of the items

if you want to save on save times, there is much better ways than this, unless you have tons and tons of statics instead of freezing them

internal items and mobiles need to be cleaned up on a regular basis
freezing of areas and patching to players (map static files zip up very nicely and are small patches)
proximity spawning instead of regular spawning so less mobs in the world
removal of shrink system and limit stabling to x number of critters per character
(mobs take up a lot more saving time and space than items to, specialy static items)
faster cpu :cool:

there might be better ways of doing the save files, but interating through things more than 1 time is not one of them
 

HSOdin

Wanderer
Who said, all the statics should be checked?

Read my last post... The idea is making it event triggered, not going through all statics (and even this is faster, because I/O operations in the RAM are much faster than on HDD).
 
still get read once each when it goes to save items in the world to ignor them, because they are still items

thing is - your method sounds great, but each time a gm adds somthing for an event then removes it
or they are decoing an area, etc your static will get saved anyways
so the static will be getting saved alot
it might shave off a half a second when gm's are not working, but that would be about it
better off freezing the statics where you can, will do more for saving on the save times

but i have 100,000's of items and and simular amount of mobs in my world and my saves average 3-4 seconds
and that includes adding in extras to the world save for
deleting decaying items (this is standard when saves occur, but more players, more items to delete)
marking everyplayer on to update login time (has to find all players and check if online, etc so goes through them all)
jailings
knives chat
and a few other things that i have happen on the save

that is with average of 40-50 players on each time

3-4 seconds with those extras and that amount of mobs, it a good time

back when i used proximity spawning, my saves where 2 seconds each, but mobs where down to 20-30k then, not almost 200k
so mobs take up a big number of it, a lot more than items do, specialy statics
of course i also freeze statics when i can
but i do have a bunch of race towns partialy built that are not static yet adding to the count

so cutting down on amount of mobs would do a lot more to save it than anything else
 

Jeff

Lord
You are basically wanting to make a difference save, thats fine and dandy, but chances are the amount of work that would go into this vs. the amount of time saves at save time is so insignificant that isn't not even worth the effort.
 

Acronis

Sorceror
I'm working on a realtime SQL save system. Basically when an item or anything else changes it is flagged appropriately (added, changed, or deleted) and put into a List. Then at given intervals this list is checked and "saved" to an array. Another thread runs and checks this array then performs the SQL queries, emptying this array. I have it so the normal thread and the actual save thread are synchronized properly so they don't conflict.

The incremental saves which do stop the game will only add up to NN items, so they only take .2 secs and are not noticable, then run again once the other thread is done, in a continuous cycle. The conversion from serialized files to mysql actually takes nearly a day, but it's because it's happening very slowly in the background with zero game interruption. Once you hit a certain point anything added to game is pretty much saved within the minute. Once I have this working 100% I will be testing to see how different operations work out, like adding new houses, etc. Need to ensure stuff saves properly and loads properly.

Though, for less work, it would be neat to look at making a new item type or use static and make it a different item type that has itemid, hue, light level, and maybe a few others that may be useful, then it would save using a different command invoked by GMs. So only when it's changed, would there be a save of that data.

In fact houses could also be separate, and only save when changed.

Save system changes are huge though, but can really improve performance of saves.
 

Acronis

Sorceror
Not sure yet if I will release it. There are quite a lot of edits and I just have not been keeping track. It's maybe 40% done at this point, and that's just mobiles and items. Guilds will be similar, and then accounts will be totally different as I will have a web based account system.
 
Top