Go Back   RunUO - Ultima Online Emulation > RunUO > Core Modifications > Serialization

Serialization This forum is for modifications to the serialization code of RunUO

Reply
 
Thread Tools Display Modes
Old 07-16-2005, 12:32 PM   #1 (permalink)
Forum Expert
 
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
Default deserialization optimization

I am an old runuo guy, it has been almost two year that I havent looked runuo scripts.
today, I had a chance to overlook some core scripts..

While loading the world, there is an issue with hashtables..

A hashtable's size is never the same as the count of objects in itself.
Approximately, the max number of objects would be the half of the size..

(I checked MSDN for more info, the most efficient ratio is 0.72 which is default)

Consider the following situation:
-lets say you created a hashtable with the initial capacity 100.
-insert 72 items
-if you insert one more item, what will happen?

If you try to insert one more item, before it's hashed and located, the following occurs:
-hashtable is expanded (almost doubled)
-each item in hashtable is rehashed and relocated..

So, obviously this is an important overhead..

To resolve the problem, the initial capacity of the hashtables should be double of the item/mobile count, so that loading factor would be 0.5

The less loading factor is , the more faster loading will be..(less collision, faster lookup)
0.5 is fine almost anytime. Also it gives some flexibility for runtime.

It is possible to choose different loading factors for items and mobiles. The number of mobiles could be considered as more stable than the number of items, so you can choose a loading factor like 0.6 . It is really a trade-off between speed and memory, decision is up to you..

the more info about hashtables

Anyway, the current implementation should be changed whatever loading factor you choose..

I hope RunUO team consider my suggestion
noobie is offline   Reply With Quote
Old 07-16-2005, 01:15 PM   #2 (permalink)
Forum Expert
 
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
Default

that would be probably generics. you dont need to downcast objects anymore.
however, that doesnt mean hashtables will not be used. I guess he is planning to change it to generic hashtable. (thats just a guess) You will still need to make needed change for deserialization..

I do not know much what is coming with 2.0, only a few headlines..but chaning it from hastables to something else entirely different might take some serious time..
noobie is offline   Reply With Quote
Old 07-16-2005, 02:26 PM   #3 (permalink)
Forum Expert
 
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
Default

hmzzz, Dictionary is nothing but the strongly-typed version of hashtable. However, usage of initial capacity seems to be changed. But since most of the generics is almost the same except strongly-typed issue, the internal implementation would be same. (there will be a loading factor internally)

Dictionary is expanded when more items will be loaded. Maybe it wont happen in the loading stage since item count is same as the given parameter, but it will happen in runtime ( i guess it is worse )

anyway, I think it is more appropriate to assign some higher value to initial capacity for runtime issues, even if it is a Dictionary class..

btw, there are some blogs, you might wanna look around:
from one of the my favourite guys:
Brad Abrams
and another two as a reply to his blog:
Justin Rogers
another Justin Rogers

I guess it wont be a real problem to change it from HashTable to Dictionary..

this was not a big issue, since it only effects loading stage but not runtime. but i just wanted you-guys to be aware of it
noobie is offline   Reply With Quote
Old 07-16-2005, 10:38 PM   #4 (permalink)
Forum Expert
 
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
Default

i am lost.

why is Phantom's all messages are deleted in my various threads??

the funny thing is only the messages that I didnt quote are deleted.lol
noobie is offline   Reply With Quote
Old 07-16-2005, 10:51 PM   #5 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Quote:
Originally Posted by noobie
i am lost.

why is Phantom's all messages are deleted in my various threads??

the funny thing is only the messages that I didnt quote are deleted.lol
I removed them the reason for doing so is not important.
Phantom is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5