- find hash entry at index i
- use compare-and-swap to flip a bit in the entry from 0 to 1
- read or update the entry
- atomically flip the bit from 1 to 0, to unlock it for other readers
Since, I essentially had to grow the size of the entry by int32 (that is the smallest size that I can use it in compare-and-swap in golang), I decided to only store 32-bit of the hash in the entry. This proves to be good except Zahak plays an illegal move every 1600 games or so (I do not validate the legality of hash moves).
That encouraged me to search other engines, and see how they implement atomicity in their engines, and they DO NOT! I saw some top engiens like Weiss for example even plays hash moves without checking their legality first! Stockfish even admits that neither probing, nor storing are atomic! Not sure how this works, can somone enlighten me
