average hit rate of pawn hash tables?

Discussion of chess software programming and technical issues.

Moderator: Ras

cyberfish

average hit rate of pawn hash tables?

Post by cyberfish »

Hi,
I just tried implementing a pawn hash table in my chess engine. I am using a 8MB table and the hit rate is ~87%. Does that number look right? I've heard somewhere else I don't remember that it should be way higher than that (~99% if I remembered correctly). Can someone please clarify?

Thank you
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: average hit rate of pawn hash tables?

Post by bob »

cyberfish wrote:Hi,
I just tried implementing a pawn hash table in my chess engine. I am using a 8MB table and the hit rate is ~87%. Does that number look right? I've heard somewhere else I don't remember that it should be way higher than that (~99% if I remembered correctly). Can someone please clarify?

Thank you
Crafty is always at 99%. Very few calls to EvaluatePawns() are actually done, but there must be some so 100% is impossible.
mjlef
Posts: 1494
Joined: Thu Mar 30, 2006 2:08 pm

Re: average hit rate of pawn hash tables?

Post by mjlef »

99% is typical for a pawns only hash. If you include king positions this drops (so your rate may indicated you include king positions).
cyberfish

Re: average hit rate of pawn hash tables?

Post by cyberfish »

Thanks for the replies. In my engine I am only hashing the pawns (of both sides). Is that how everyone's doing it?

Also, what replacement schemes should be used? I am doing always-replace with my pawn table right now.
gladius
Posts: 568
Joined: Tue Dec 12, 2006 10:10 am
Full name: Gary Linscott

Re: average hit rate of pawn hash tables?

Post by gladius »

I get about 94% for the starting position with an 8mb pawn hash. A few moves out of the opening though (once pieces have some mobility), and the hit rate is sitting above 99% consistently.

I only hash pawn positions, but that means that I still have to run my passed pawn evaluation code on every eval as the king position affects the scores. That is a very minor cost though, especially as passed pawns aren't around most of the time, and the pawn hash can store which pawns are passed.
cyberfish

Re: average hit rate of pawn hash tables?

Post by cyberfish »

hmm I see, I was only using the starting position =) turns out mine has a hit rate of ~99% in the midgame too.

Thanks for your help
User avatar
Zach Wegner
Posts: 1922
Joined: Thu Mar 09, 2006 12:51 am
Location: Earth

Re: average hit rate of pawn hash tables?

Post by Zach Wegner »

cyberfish wrote:Also, what replacement schemes should be used? I am doing always-replace with my pawn table right now.
Always replace is the only thing that makes any sense, really.
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: average hit rate of pawn hash tables?

Post by hgm »

Why do you think that would be better than, say, Least-Recent Used of 2 or 4 (or as many entries that fit in your cache line)?
User avatar
Zach Wegner
Posts: 1922
Joined: Thu Mar 09, 2006 12:51 am
Location: Earth

Re: average hit rate of pawn hash tables?

Post by Zach Wegner »

Well, I don't use any bucket system for the pawn hash. And anyways, not even one of my entries will fit in a cache line, and I don't expect many people's to fit either.

Perhaps if you did make a bucket system, and keep track of the "age", it would be marginally better. I don't think it would make much difference, especially considering the overhead in cache thrashing.
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: average hit rate of pawn hash tables?

Post by hgm »

If you need multiple cache-line accesses anyway, it would be best to store the hash key and age information of several entries all in the first cache line you probe. Then You can conclude from that single access if you have a hit or not, and if not, which entry you will replace. And then the rest of the accesses can be for that entry only.