Notice the "some" in "some positions". For some positions, hashing just doesn't help. For the average case, it certainly helps...ernest wrote:Hi Bob,bob wrote: It is perfectly normal for a particular program to produce the same scores using different hash sizes for some positions
I am extremely surprised at that, at least when you look at PVs (and nodes) obtained after some time elapsed, when the hash table has been overly "filled" - don't pick at me for the word!
Of course, if you have Gigabyte large hashtables, and you look at PVs/nodes after 1 second (or less), you may have the same for 1 or 2 GB hash size...
Different behavior with different hash sizes. (Stockfish 1.9
Moderator: Ras
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Different behavior with different hash sizes. (Stockfish
-
- Posts: 27
- Joined: Fri Jan 02, 2009 9:56 am
- Full name: Arsha
Re: Different behavior with different hash sizes. (Stockfish
I hope this would be my last question.
We also could conclude that “It has reduced the size of tree (regarding 256 MB hash table)” (save time!) but again it has not provided the accurate information.
Can you explain what was happened in these two circumstances?
Position:

Please look carefully at two different analyses by Stockfish 1.9. It seems that in this particular position, smaller hash table has increased the size of the tree but provided more accurate information. Especially it’s apparent at depth 17 (in bold case).bob wrote:In fact, some times hashing _increases_ the size of the tree, because of this grafting issue. But in doing so, you actually get a better search result than if you didn't have hashing at all.
Hash hits can do two things. (1) reduce the size of the tree by saving the effort of searching beyond the hash hit. (2) possibly increase the size of the tree because it introduces deeper searches than expected, which provides more accurate information.
In short, you can save time, or possibly gain increased accuracy. And sometimes even both.
We also could conclude that “It has reduced the size of tree (regarding 256 MB hash table)” (save time!) but again it has not provided the accurate information.
Can you explain what was happened in these two circumstances?
Position:
- 6k1/3qr1p1/1pn1pr2/p5Np/1nPPQP2/2B3P1/1R4K1/4R3 b - - 0 59
- 1...Rh6 2.Rh1 Qb7 3.Ra1 Qc8 4.Re2 h4 5.gxh4 Qf8 6.Bxb4 Nxb4 7.d5 Rxh4 8.d6
+/- (1.13) Depth: 14 00:00:07 2007kN
1...Rh6 2.Rh1 Qb7 3.Ra1 Qc8 4.Re2 h4 5.gxh4 Qf8 6.Bxb4 Nxb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12.Rcc6 Na4 13.Rc7 Rxf5 14.Rd4
+- (1.81) Depth: 20 00:04:46 107mN
-
- Posts: 12792
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: Different behavior with different hash sizes. (Stockfish
With bigger hash it has the right move four seconds faster to the same depth.
What's to explain?
I think it is folly to try to fully understand hash table behavior by analyzing the output for a single position.
Better to do a code review and then to trace the code if you want to understand it.
What's to explain?
I think it is folly to try to fully understand hash table behavior by analyzing the output for a single position.
Better to do a code review and then to trace the code if you want to understand it.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Different behavior with different hash sizes. (Stockfish
As I explained, there are two possible effects from hashing, with respect to the size of the tree.Arsha Mahdavi wrote:I hope this would be my last question.![]()
Please look carefully at two different analyses by Stockfish 1.9. It seems that in this particular position, smaller hash table has increased the size of the tree but provided more accurate information. Especially it’s apparent at depth 17 (in bold case).bob wrote:In fact, some times hashing _increases_ the size of the tree, because of this grafting issue. But in doing so, you actually get a better search result than if you didn't have hashing at all.
Hash hits can do two things. (1) reduce the size of the tree by saving the effort of searching beyond the hash hit. (2) possibly increase the size of the tree because it introduces deeper searches than expected, which provides more accurate information.
In short, you can save time, or possibly gain increased accuracy. And sometimes even both.
We also could conclude that “It has reduced the size of tree (regarding 256 MB hash table)” (save time!) but again it has not provided the accurate information.
Can you explain what was happened in these two circumstances?
Position:Stockfish 1.9 128 MB hash:
- 6k1/3qr1p1/1pn1pr2/p5Np/1nPPQP2/2B3P1/1R4K1/4R3 b - - 0 59
Stockfish 1.9 256 MB hash:
- 1...Rh6 2.Rh1 Qb7 3.Ra1 Qc8 4.Re2 h4 5.gxh4 Qf8 6.Bxb4 Nxb4 7.d5 Rxh4 8.d6
+/- (1.13) Depth: 14 00:00:07 2007kN
1...Rh6 2.Rh1 Qb7 3.Ra1 Qc8 4.Re2 h4 5.gxh4 Qf8 6.Bxb4 Nxb4 7.d5 Rxh4 8.d6
+/- (1.21) Depth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d4
+- (1.81) Depth: 20 00:04:46 107mN
(1) reduce the size of the tree due to saving effort when you encounter the same position a second time.
(2) increase the size of the tree because of the grafting between nodes, which "can" set an N-ply search see deeper than N plies. Sometimes this will increase the size of the tree. Sometimes this will actually reduce the size of the tree.
(2) above is both unpredictable and inconsistent. If you make the table big enough, you should get the same result each and every time. If the table has any overwrites at all, these could be to inconsequential positions, or they could cause you to lose critical positions that would either provide a more accurate score or a smaller (sometimes larger) tree.
The effect is quite random, overall, but on average, it improves the strength of the program significantly. In general, bigger hash lets you search deeper, until you reach a point where the hash is large enough that no information is lost due to replacement policy choices. For a single position, you can get almost any result you might dream of...
-
- Posts: 2053
- Joined: Wed Mar 08, 2006 8:30 pm
Re: Different behavior with different hash sizes. (Stockfish
Any example (trivial or not)?bob wrote:[For some positions, hashing just doesn't help.

-
- Posts: 12792
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: Different behavior with different hash sizes. (Stockfish
Here is one from gedankenexperiment:ernest wrote:Any example (trivial or not)?bob wrote:[For some positions, hashing just doesn't help.
A long series of single reply moves. There are no transpositions to benefit from. A hash table will decrease performance, because of also performing the work of computing the hash, storing the hash table entries and looking for them.
-
- Posts: 2053
- Joined: Wed Mar 08, 2006 8:30 pm
Re: Different behavior with different hash sizes. (Stockfish
OKOK Dann...Dann Corbit wrote:A long series of single reply moves.

I mean a position with no game background, you just perform infinite analysis after clearing the hashtable.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Different behavior with different hash sizes. (Stockfish
Not that I have saved. The obvious example where it helps is fine 70 where you can't see the win until somewhere beyond depth=26 without hashing, yet you see it at between 18 and 24 plies with hashing (24 is a normal range due to search reductions and pruning).ernest wrote:Any example (trivial or not)?bob wrote:[For some positions, hashing just doesn't help.
-
- Posts: 2053
- Joined: Wed Mar 08, 2006 8:30 pm
Re: Different behavior with different hash sizes. (Stockfish
Indeed I just did infinite analysis on Fine #70 with Rybka 4 (1-cpu for reproducibility) with 512 MB hash, then 256 MB hash.bob wrote:The obvious example where it helps is fine 70
Of course, the PVs and nodes were different.
I have yet to see a position where, in infinite analysis, PVs and nodes are the same for different hash sizes!
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Different behavior with different hash sizes. (Stockfish
Nodes may well always change for deep searches and different hash sizes. But I have encountered many positions where the score or PV doesn't change at all. The obvious trivial case is a forced mate, of course, or a forced tactical win. But even in many normal positions the score doesn't change, although the node count almost always does (and I can not recall a case where changing the hash size did not change the node count, unless you double the hash size when it was already large enough that no overwrites were happening). However, such a case might well exist, so I would not discount it.ernest wrote:Indeed I just did infinite analysis on Fine #70 with Rybka 4 (1-cpu for reproducibility) with 512 MB hash, then 256 MB hash.bob wrote:The obvious example where it helps is fine 70
Of course, the PVs and nodes were different.
I have yet to see a position where, in infinite analysis, PVs and nodes are the same for different hash sizes!