Hash table sizes

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Zlaire

Hash table sizes

Post by Zlaire »

In Mediocre the hash table consists of one big integer array (int being a 32 bit number in Java).

One transposition table entry requires three slots (move, zobrist key, and flag/depth/eval/etc). But since I use depth/new replacement scheme one index needs 6 slots to hold them both.

So if I were to use 2^20 slots the array would be 2^20*6 slots and take 24mb of memory.

Looking right? (I use a plain int array to store the information rather then objects since creating objects is a major bottleneck in Java)

Now my question is I'm thinking pawn and eval hash would only require two slots per entry each, the eval and the zobrist key, but how many entries should I have compared to the main transposition table? And should I count all the tables when setting the size of the hash tables to say 128mb?
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: Hash table sizes

Post by Tord Romstad »

Zlaire wrote:Looking right? (I use a plain int array to store the information rather then objects since creating objects is a major bottleneck in Java)
I don't know Java, but as far as I can see you shouldn't have to create any objects except when initializing or resizing the hash table. During the search, you only update existing objects, which should be cheap.
Now my question is I'm thinking pawn and eval hash would only require two slots per entry each, the eval and the zobrist key,
In the pawn hash table, I think you should consider more than just two entries. At the very least, storing the location of the passed pawns for both sides is useful.
but how many entries should I have compared to the main transposition table
The pawn hash table can be quite small; the number of different pawn structures which occur in a search is very small compared to the total number of positions. For the evaluation hash table, it depends on how expensive your evaluation function is. If your evaluation is sufficiently simple, it is probably better not to have an evaluation hash table at all: It will just slow you down. You'll just have to experiment to find out what works best for you.
And should I count all the tables when setting the size of the hash tables to say 128mb?
Most people don't count them, I think.

Tord