hashtable -> btree
this is probably a bad idea but i am gonna throw it out anyway
one of the problems with runuo is it uses much ram. i thought some what could be done about it and came out with an idea.
it stores mobiles/items in hashtables which waste about 4/10 of the memory it uses. (allocates memory for 10, but only stores 6 : 7 is the maximum it can store however thats not something you can interfere. lets assume 6 is average)
so, if a server has 1millon items, it allocates memory for about 1.6million items where 600K is wasted.
if we use some kind of btree implemented with Array/Lists (arrays might work better), we could lower the "waste ratio". It should has 2^x number of branches where x might be 8 or 9 (8 could be applied for almost any server)
for 8 -> the number of branch=256
wasted memory is about 65K
max number of items is 16,5 millions
for 9->the number of branch=512
wasted memory is about 250K
max number of items is 130 millions
you can use different branch numbers for mobiles and items. (could be 7 for mobiles)
here are some advantages and disadvantages of the system:
advantages:
a) accessing a item/mobile from its serial will cause no efficiency problem. it could be even more faster in this system, if hashing an integer is more expensive than a few shifting. (this is why branch number is power of 2)
b)need less memory.
disadvantages:
a)this system will require a re-serialization system : first item/mobile in the server has to have the Serial value 0x...01
b)re-serialization system should be auto invoked by the system if any item/mobile is created with the max serial. (or you can schedule something for it)
c)converting existing system needs some work. implementing IEnumarable interface and index property probably will make easier to port the system.
any comment on the system? I am not saying it is perfect, obviously it has some issues about back compatibility.
a) it sucks
b) interesting
c) worth to try
d) excellent
this is probably a bad idea but i am gonna throw it out anyway
one of the problems with runuo is it uses much ram. i thought some what could be done about it and came out with an idea.
it stores mobiles/items in hashtables which waste about 4/10 of the memory it uses. (allocates memory for 10, but only stores 6 : 7 is the maximum it can store however thats not something you can interfere. lets assume 6 is average)
so, if a server has 1millon items, it allocates memory for about 1.6million items where 600K is wasted.
if we use some kind of btree implemented with Array/Lists (arrays might work better), we could lower the "waste ratio". It should has 2^x number of branches where x might be 8 or 9 (8 could be applied for almost any server)
for 8 -> the number of branch=256
wasted memory is about 65K
max number of items is 16,5 millions
for 9->the number of branch=512
wasted memory is about 250K
max number of items is 130 millions
you can use different branch numbers for mobiles and items. (could be 7 for mobiles)
here are some advantages and disadvantages of the system:
advantages:
a) accessing a item/mobile from its serial will cause no efficiency problem. it could be even more faster in this system, if hashing an integer is more expensive than a few shifting. (this is why branch number is power of 2)
b)need less memory.
disadvantages:
a)this system will require a re-serialization system : first item/mobile in the server has to have the Serial value 0x...01
b)re-serialization system should be auto invoked by the system if any item/mobile is created with the max serial. (or you can schedule something for it)
c)converting existing system needs some work. implementing IEnumarable interface and index property probably will make easier to port the system.
any comment on the system? I am not saying it is perfect, obviously it has some issues about back compatibility.
a) it sucks
b) interesting
c) worth to try
d) excellent