• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Number of Hashtables

Status
Not open for further replies.
Level 37
Joined
Mar 6, 2006
Messages
9,243
I recommend keeping the amount of hashtables down, since you can only have 256 or 255 hashtables in a map.

That is quite a high number so in most cases it doesn't matter.

without wanting to be boring, more like I know how many indexes I am using?

What do you mean by that, are you asking how do you know how many indees you are going to use? Usually one can estimate it depending on the nature of the system.
 
over the logic of the above statement, this right?

no idea what u mean by this. i believe maker means to use an indexing when using arrays. and 8191 is the most indexes you can use.

It would be easier for us to help improve ur system if u posted ur system as an indexing system w arrays might not be suited for that type of system. or you can explain what ur system does and we may be able to determine it from that.

you also shouldnt need that many hastables in a system if done correctly. There are circumstances that you do need more than 1 or 2 tho. it all depends on the system and how u store the data
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Hashtables start out only slightly slower than arrays but if used excessively (storing too much data) can degrade to horrible performance.

You should only ever need 1 hashtable for dynamic storage. The life cycle of the contained data should be relatively short so the hashtable size (how much it contains) is kept small.

For large quantities of permanent data you will want many hashtables. If they perform slightly slower no one really cares but the key point is to keep it away from dynamic data usage which can be recalled many times a second. An example would be a recipe system mapping item types to some data.

Anything storing a large amount of data should use its own hashtable if not many hashtables. This is to prevent it interfering with the performance of other systems and to raise its own performance by keeping internal hashtable size low. Such a system I heard do this was a custom pathing system to detect when a mazing TD player blocks with towers.

Hashtables suffer from O(1) to O(n) degradation as the size exceeds the size of the underlying bucket array. The degradation is not clear cut but in the end can really hammer performance if you create really large hashtables (a lot of data in them).

Arrays do not suffer from this performance degradation. Access to an array index is always O(1). The obvious handicap is that arrays have a finite index range while hashtables have no such input restriction due to how they operate.

In theory one could write custom hashtables backed by arrays that could perform better than the built in one due to larger bucket arrays (I doubt the built in ones have a size of 8,000 indices) but in reality JASS is too slow compared to the native hashtables. I did this before hashtables were added into WarCraft III as my alternative to the game cache solution and the finite handle size solution.
 
guys thanks for the participation of all, I still have some doubts about the performance of Hashtables. so I'll create other Thread, for have more information.

Dr Super Good, your answer started clarify some doubts, but it is difficult understand, because i not speak english and the tradutor, is not as effective.

Nestharus, thanks for reply the main question.
 
Status
Not open for further replies.
Top