Too much Hash harms?

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
Laskos
Posts: 10949
Joined: Wed Jul 26, 2006 8:21 pm
Full name: Kai Laskos

Re: Too much Hash harms?

Post by Laskos » Sun Feb 05, 2017 9:05 am

Adam Hair wrote:
Laskos wrote:
hgm wrote:
IIRC in my measurements the search time only started to go up once the overload factor exeded 10.
That seems confirmed. In 1000 games each, about 60,000 positions per Stockfish with different Hash at 6''+0.06'' 1 core, I get the following depths and nps:

Code: Select all

 1.  SF 1M         tpm=148.0 d=16.14 nps=1951575    99%
 2.  SF 4M         tpm=148.1 d=16.30 nps=1955569    80%
 3.  SF 16M        tpm=149.3 d=16.36 nps=1946288    25%
 4.  SF 64M        tpm=149.3 d=16.33 nps=1910916     7%
 5.  SF 256M       tpm=149.5 d=16.25 nps=1817734     2%
 6.  SF 1024M      tpm=149.4 d=16.14 nps=1718677     1%
The last column is approximate Hash usage per move out of available. 25% (16M Hash) seems the optimum here depth-wise. And indeed, a factor of 16 overload seems to not hurt almost at all (4M vs 64M).
I measured depth, nodes per second, and hash usage at 1.5 seconds per move from a set of positions (the 8238 positions from the sim tool; data extracted from Polyglot logs). I think the thinking time would equate to 1 to 1.2 seconds per move on your computer.

Code: Select all

  
Hash	Depth	   NPS	    Hashfull
   1	19.71	1423911.54	98.92%
   4	19.84	1423019.10	98.59%
  16	19.99	1471216.76	73.69%
  32	19.90	1425357.18	43.74%
  64	19.87	1407208.73	22.82%
 256	19.84	1385323.14	 5.69%
1024	19.71	1310237.31	 2.06%
4096	19.66	1284870.14	 1.65%
16 MB of hash seems to be best for this tpm and these positions on my computer. I was expecting a little more of a difference compared to your results.
Good, your Hashfull is very useful, I have just estimation by looking at Hash usage for typical positions. I refined my test now, in LittleBlitzer I just play for 5 moves from 2moves_v1.epd openings, so only opening positions with similar time-to-depth. With InBetween I let them play at fixed depth=17 (about one second per move, but a bit varied time). The result is here, and is more precise than my previous one, because time-to-depth variance is smaller than using full games.

Code: Select all

Games Completed = 1800 of 1800 (Avg game length = 9.963 sec)
Settings = RR/0MB/100000ms per move/M 500cp for 2 moves, D 5 moves/EPD:C:\LittleBlitzer\2moves_v1.epd(32000)
Time = 5544 sec elapsed, 0 sec remaining
 1.  SF 1M                    	300.0/600	0-0-600  	(tpm=964.0 d=17.00 nps=1367595)  99%
 2.  SF 4M                    	300.0/600	0-0-600  	(tpm=901.0 d=17.00 nps=1376814)  98%
 3.  SF 16M                   	300.0/600	0-0-600  	(tpm=860.5 d=17.00 nps=1383201)  60%
 4.  SF 64M                   	300.0/600	0-0-600  	(tpm=861.7 d=17.00 nps=1373527)  18%
 5.  SF 256M                  	300.0/600	0-0-600  	(tpm=901.5 d=17.00 nps=1329987)   5%
 6.  SF 1024M                 	300.0/600	0-0-600  	(tpm=945.3 d=17.00 nps=1255824)   2%
The Hashfull in the last column is an estimation. Your numbers on this are more reliable. The plot of time-to-depth=17 for those opening positions is here:

Image

The extrapolation curve seems to indicate 32M as the optimum Hash and about 40% Hashfull. Also, too much Hash seems to harm as much as to little Hash (on logarithmic scale).

Jouni
Posts: 2432
Joined: Wed Mar 08, 2006 7:15 pm

Re: Too much Hash harms?

Post by Jouni » Sun Feb 05, 2017 9:25 am

I assume, that tests were done with SF? In my tests Houdini and Komodo seems to behave differently: they prefer bigger hash!?
Jouni

User avatar
Laskos
Posts: 10949
Joined: Wed Jul 26, 2006 8:21 pm
Full name: Kai Laskos

Re: Too much Hash harms?

Post by Laskos » Sun Feb 05, 2017 9:40 am

Jouni wrote:I assume, that tests were done with SF? In my tests Houdini and Komodo seems to behave differently: they prefer bigger hash!?
Yes, SF. Seems weird if what you say is true.

syzygy
Posts: 5000
Joined: Tue Feb 28, 2012 10:56 pm

Re: Too much Hash harms?

Post by syzygy » Sun Feb 05, 2017 10:13 am

Laskos wrote:Also, too much Hash seems to harm as much as to little Hash (on logarithmic scale).
Too much hash can harm only if the decrease in nps outweighs the gain of bigger hash.

So if you correct for nps decrease (so just look at total node count), the harm will disappear completely (modulo statistical noise).

The only reason why bigger hash might not gain is that hash is already big enough (for a given test).

User avatar
Laskos
Posts: 10949
Joined: Wed Jul 26, 2006 8:21 pm
Full name: Kai Laskos

Re: Too much Hash harms?

Post by Laskos » Sun Feb 05, 2017 10:22 am

syzygy wrote:
Laskos wrote:Also, too much Hash seems to harm as much as to little Hash (on logarithmic scale).
Too much hash can harm only if the decrease in nps outweighs the gain of bigger hash.

So if you correct for nps decrease (so just look at total node count), the harm will disappear completely (modulo statistical noise).

The only reason why bigger hash might not gain is that hash is already big enough (for a given test).
Yes, NPS drop is substantial after the sweet spot, although the sweet spot in NPS is not necessarily equal in Hash to the sweet spot in time-to-depth, but they seem to be close.

User avatar
Laskos
Posts: 10949
Joined: Wed Jul 26, 2006 8:21 pm
Full name: Kai Laskos

Re: Too much Hash harms?

Post by Laskos » Sun Feb 05, 2017 12:09 pm

Laskos wrote:
Jouni wrote:I assume, that tests were done with SF? In my tests Houdini and Komodo seems to behave differently: they prefer bigger hash!?
Yes, SF. Seems weird if what you say is true.
Seems not to be true for Komodo 10.3. Time-to-depth=17 are here, and their succession seems similar to SF:

Code: Select all

Games Completed = 1800 of 1800 (Avg game length = 11.923 sec)
Settings = RR/0MB/100000ms per move/M 500cp for 2 moves, D 5 moves/EPD:C:\LittleBlitzer\2moves_v1.epd(32000)
Time = 6469 sec elapsed, 0 sec remaining
 1.  K 1M                     	300.0/600	0-0-600  	(tpm=1104.4 d=17.00 nps=1234770)  99%
 2.  K 3M                     	300.0/600	0-0-600  	(tpm=1080.4 d=17.00 nps=1224209)  98%
 3.  K 12M                    	300.0/600	0-0-600  	(tpm=1071.3 d=17.00 nps=1212606)  70%
 4.  K 48M                    	300.0/600	0-0-600  	(tpm=1063.3 d=17.00 nps=1210377)  20%
 5.  K 192M                   	300.0/600	0-0-600  	(tpm=1067.3 d=17.00 nps=1185387)   5%
 6.  K 768M                  	 300.0/600	0-0-600  	(tpm=1136.6 d=17.00 nps=1139547)   2%
Image

It seems that 48M is optimal, comparable to SF 32M. Time-to-depth=17 is a bit longer for Komodo, so the result is normal.

flok

Re: Too much Hash harms?

Post by flok » Sun Feb 05, 2017 2:06 pm

Odd: for Embla there is no difference at all. That is: no TT is dramatic but 1MB or 2048MB no difference:

Code: Select all

  rev 3799
	1 info string nps: 242k, eval: 7, depth: 14, time: 9.428
	2 info string nps: 240k, eval: 7, depth: 14, time: 9.496
	4 info string nps: 243k, eval: 7, depth: 14, time: 9.385
	8 info string nps: 237k, eval: 7, depth: 14, time: 9.614
	16 info string nps: 242k, eval: 7, depth: 14, time: 9.399
	32 info string nps: 243k, eval: 7, depth: 14, time: 9.376
	64 info string nps: 243k, eval: 7, depth: 14, time: 9.370
	128 info string nps: 243k, eval: 7, depth: 14, time: 9.391
	256 info string nps: 243k, eval: 7, depth: 14, time: 9.388
	512 info string nps: 236k, eval: 7, depth: 14, time: 9.655
	1024 info string nps: 243k, eval: 7, depth: 14, time: 9.385
	2048 info string nps: 242k, eval: 7, depth: 14, time: 9.420
	4096 info string nps: 240k, eval: 7, depth: 14, time: 9.476

	without tt:
	x info string nps: 256k, eval: 7, depth: 14, time: 67.545

User avatar
Laskos
Posts: 10949
Joined: Wed Jul 26, 2006 8:21 pm
Full name: Kai Laskos

Re: Too much Hash harms?

Post by Laskos » Sun Feb 05, 2017 2:22 pm

flok wrote:Odd: for Embla there is no difference at all. That is: no TT is dramatic but 1MB or 2048MB no difference:

Code: Select all

  rev 3799
	1 info string nps: 242k, eval: 7, depth: 14, time: 9.428
	2 info string nps: 240k, eval: 7, depth: 14, time: 9.496
	4 info string nps: 243k, eval: 7, depth: 14, time: 9.385
	8 info string nps: 237k, eval: 7, depth: 14, time: 9.614
	16 info string nps: 242k, eval: 7, depth: 14, time: 9.399
	32 info string nps: 243k, eval: 7, depth: 14, time: 9.376
	64 info string nps: 243k, eval: 7, depth: 14, time: 9.370
	128 info string nps: 243k, eval: 7, depth: 14, time: 9.391
	256 info string nps: 243k, eval: 7, depth: 14, time: 9.388
	512 info string nps: 236k, eval: 7, depth: 14, time: 9.655
	1024 info string nps: 243k, eval: 7, depth: 14, time: 9.385
	2048 info string nps: 242k, eval: 7, depth: 14, time: 9.420
	4096 info string nps: 240k, eval: 7, depth: 14, time: 9.476

	without tt:
	x info string nps: 256k, eval: 7, depth: 14, time: 67.545
Yes, seems odd, especially the more stable NPS here. How many positions did you use?

mjlef
Posts: 1467
Joined: Thu Mar 30, 2006 12:08 pm
Contact:

Re: Too much Hash harms?

Post by mjlef » Sun Feb 05, 2017 8:03 pm

Laskos wrote:
Adam Hair wrote:
Laskos wrote:
hgm wrote:
IIRC in my measurements the search time only started to go up once the overload factor exeded 10.
That seems confirmed. In 1000 games each, about 60,000 positions per Stockfish with different Hash at 6''+0.06'' 1 core, I get the following depths and nps:

Code: Select all

 1.  SF 1M         tpm=148.0 d=16.14 nps=1951575    99%
 2.  SF 4M         tpm=148.1 d=16.30 nps=1955569    80%
 3.  SF 16M        tpm=149.3 d=16.36 nps=1946288    25%
 4.  SF 64M        tpm=149.3 d=16.33 nps=1910916     7%
 5.  SF 256M       tpm=149.5 d=16.25 nps=1817734     2%
 6.  SF 1024M      tpm=149.4 d=16.14 nps=1718677     1%
The last column is approximate Hash usage per move out of available. 25% (16M Hash) seems the optimum here depth-wise. And indeed, a factor of 16 overload seems to not hurt almost at all (4M vs 64M).
I measured depth, nodes per second, and hash usage at 1.5 seconds per move from a set of positions (the 8238 positions from the sim tool; data extracted from Polyglot logs). I think the thinking time would equate to 1 to 1.2 seconds per move on your computer.

Code: Select all

  
Hash	Depth	   NPS	    Hashfull
   1	19.71	1423911.54	98.92%
   4	19.84	1423019.10	98.59%
  16	19.99	1471216.76	73.69%
  32	19.90	1425357.18	43.74%
  64	19.87	1407208.73	22.82%
 256	19.84	1385323.14	 5.69%
1024	19.71	1310237.31	 2.06%
4096	19.66	1284870.14	 1.65%
16 MB of hash seems to be best for this tpm and these positions on my computer. I was expecting a little more of a difference compared to your results.
Good, your Hashfull is very useful, I have just estimation by looking at Hash usage for typical positions. I refined my test now, in LittleBlitzer I just play for 5 moves from 2moves_v1.epd openings, so only opening positions with similar time-to-depth. With InBetween I let them play at fixed depth=17 (about one second per move, but a bit varied time). The result is here, and is more precise than my previous one, because time-to-depth variance is smaller than using full games.

Code: Select all

Games Completed = 1800 of 1800 (Avg game length = 9.963 sec)
Settings = RR/0MB/100000ms per move/M 500cp for 2 moves, D 5 moves/EPD:C:\LittleBlitzer\2moves_v1.epd(32000)
Time = 5544 sec elapsed, 0 sec remaining
 1.  SF 1M                    	300.0/600	0-0-600  	(tpm=964.0 d=17.00 nps=1367595)  99%
 2.  SF 4M                    	300.0/600	0-0-600  	(tpm=901.0 d=17.00 nps=1376814)  98%
 3.  SF 16M                   	300.0/600	0-0-600  	(tpm=860.5 d=17.00 nps=1383201)  60%
 4.  SF 64M                   	300.0/600	0-0-600  	(tpm=861.7 d=17.00 nps=1373527)  18%
 5.  SF 256M                  	300.0/600	0-0-600  	(tpm=901.5 d=17.00 nps=1329987)   5%
 6.  SF 1024M                 	300.0/600	0-0-600  	(tpm=945.3 d=17.00 nps=1255824)   2%
The Hashfull in the last column is an estimation. Your numbers on this are more reliable. The plot of time-to-depth=17 for those opening positions is here:

Image

The extrapolation curve seems to indicate 32M as the optimum Hash and about 40% Hashfull. Also, too much Hash seems to harm as much as to little Hash (on logarithmic scale).
For years, Komodo has included a file setHash.txt which explains a process for a user to optimize the has sized for a specific machine and time control, and it in fact uses the 40% fill as the goal. Nice to confirm what we have found.

Mark

flok

Re: Too much Hash harms?

Post by flok » Sun Feb 05, 2017 8:14 pm

Laskos wrote:Yes, seems odd, especially the more stable NPS here. How many positions did you use?
My test was very much broken :-)
I used the same hash-size and only 1 position.
The following results are for 327 positions each:

Code: Select all

1 { "skipped" : 3, "found" : 272, "total" : 327, "took" : 54.711000, "version" : "0.9.8 ponder", "avg-nps" : 284010.052823 }
2 { "skipped" : 3, "found" : 272, "total" : 327, "took" : 51.638000, "version" : "0.9.8 ponder", "avg-nps" : 277504.028041 }
4 { "skipped" : 3, "found" : 272, "total" : 327, "took" : 52.123000, "version" : "0.9.8 ponder", "avg-nps" : 277093.202617 }
8 { "skipped" : 3, "found" : 274, "total" : 327, "took" : 51.963000, "version" : "0.9.8 ponder", "avg-nps" : 270581.586898 }
16 { "skipped" : 3, "found" : 273, "total" : 327, "took" : 51.012000, "version" : "0.9.8 ponder", "avg-nps" : 266421.038187 }
32 { "skipped" : 3, "found" : 272, "total" : 327, "took" : 50.852000, "version" : "0.9.8 ponder", "avg-nps" : 270994.533155 }
64 { "skipped" : 3, "found" : 272, "total" : 327, "took" : 51.689000, "version" : "0.9.8 ponder", "avg-nps" : 269201.570934 }
128 { "skipped" : 3, "found" : 271, "total" : 327, "took" : 52.512000, "version" : "0.9.8 ponder", "avg-nps" : 268882.312614 }
256 { "skipped" : 3, "found" : 271, "total" : 327, "took" : 51.712000, "version" : "0.9.8 ponder", "avg-nps" : 268210.009282 }
512 { "skipped" : 3, "found" : 271, "total" : 327, "took" : 52.265000, "version" : "0.9.8 ponder", "avg-nps" : 264162.307472 } 
1024 { "skipped" : 3, "found" : 271, "total" : 327, "took" : 51.576000, "version" : "0.9.8 ponder", "avg-nps" : 261929.676594 }
2048 { "skipped" : 3, "found" : 271, "total" : 327, "took" : 52.174000, "version" : "0.9.8 ponder", "avg-nps" : 261606.010657 }
4096 { "skipped" : 3, "found" : 271, "total" : 327, "took" : 52.871000, "version" : "0.9.8 ponder", "avg-nps" : 256738.155132 }
And altough the nps is not the highest (only 270k where the highest is 284k nps), it processed the test-file in the shortest time (50.9s, longest is 54.7s) for 32MB hash.

Post Reply