Problem with SF6 and Syzygy TB

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Problem with SF6 and Syzygy TB

Post by syzygy »

Zenmastur wrote:
syzygy wrote:
Zenmastur wrote:I'm using windows 7 with all current patches with minimal tasks in the back ground and 16Gb of ram. It doesn't take that long for SF's working memory set to use all available ram.
If you use 8GB of hash tables, it might help to reduce that to 4GB. Alternatively, or in addition, increasing probe depth should help as well.

Ideally, the OS should not swap memory to disk when under memory pressure but instead release RAM used for caching TB data. But I don't know if all OS's are so smart. (I'm not even sure what Linux does in this case.)
Most of the time I use 4 GB of cache. But even if I reduce this to 1 GB It will still run ram use-age to greater than 16,000 MB. Probe Depth is set at default, which is six if I recall properly. I'm wondering why it shows SF as using 16,000+ MB in the resource console if the OS is doing the caching. Is it because the cache is directly mapped by the program?
Yes, the memory pages containing cached TB data show up as part of the process's memory in the Working Set column of the task manager. The Commit size column will look even worse, but that's just a number.

You're probably not doing this, but just in case, don't store TB files in a RAM disk. That will only make them use RAM twice: once in the RAM disk, once in the page cache. (A good RAM disk might avoid this problem but I doubt they exist for Windows.)
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Problem with SF6 and Syzygy TB

Post by syzygy »

Just thought of something.

If you have 16GB and the WDL tables on SSD, simply disable your swap file. (I think it's called page file on Windows.)

Without a swap file, the system will not swap. Problem solved. When the system runs out of memory (because too much memory is used for caching TB data), the OS will have no other choice than to release memory pages caching TB data. And that is just what we want.

(I'm not kidding or trying to be sarcastic. I really doubt that for normal users, including heavy chess engine users, there is any practical advantage in having a swap file on a 16GB system.)
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Problem with SF6 and Syzygy TB

Post by Michel »

syzygy wrote:
Ideally, the OS should not swap memory to disk when under memory pressure but instead release RAM used for caching TB data. But I don't know if all OS's are so smart. (I'm not even sure what Linux does in this case.)
I hadn't seen this comment, but _as far as I understand_ this is a basic part of memory management which all OS'es implement. Memory which is backed by file storage (like mmapped files) is not swapped out.

Only heap allocated memory is swapped out.
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.
Zenmastur
Posts: 919
Joined: Sat May 31, 2014 8:28 am

Re: Problem with SF6 and Syzygy TB

Post by Zenmastur »

syzygy wrote:Yes, the memory pages containing cached TB data show up as part of the process's memory in the Working Set column of the task manager. The Commit size column will look even worse, but that's just a number.

You're probably not doing this, but just in case, don't store TB files in a RAM disk. That will only make them use RAM twice: once in the RAM disk, once in the page cache. (A good RAM disk might avoid this problem but I doubt they exist for Windows.)
I don't have the TB file on a RAM disk at least for now due to memory limitations, they're on a SSD. I do have and use a ram disk, but I don't know if the version I have removes the memory it uses from the working pool. Even if it could, I haven't set up the OS to allow this, although it's not difficult to do.

syzygy wrote:Just thought of something.

If you have 16GB and the WDL tables on SSD, simply disable your swap file. (I think it's called page file on Windows.)

Without a swap file, the system will not swap. Problem solved. When the system runs out of memory (because too much memory is used for caching TB data), the OS will have no other choice than to release memory pages caching TB data. And that is just what we want.

(I'm not kidding or trying to be sarcastic. I really doubt that for normal users, including heavy chess engine users, there is any practical advantage in having a swap file on a 16GB system.)
I would try this but, I do need more than 16 GB as I often use more than this, sometimes a lot more. It's surprisingly easy to do. I guess that makes me a non-normal user. My next system, coming soon I hope, will be a little more robust in the ram and mass storage departments.

I'm going to try a few things, if they don't help, I'll probably just go back to not using TB's for most tasks. They're nice in some instances, but not mandatory for most.

Regards,

Zen
Only 2 defining forces have ever offered to die for you.....Jesus Christ and the American Soldier. One died for your soul, the other for your freedom.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Problem with SF6 and Syzygy TB

Post by syzygy »

Michel wrote:
syzygy wrote:Ideally, the OS should not swap memory to disk when under memory pressure but instead release RAM used for caching TB data. But I don't know if all OS's are so smart. (I'm not even sure what Linux does in this case.)
I hadn't seen this comment, but _as far as I understand_ this is a basic part of memory management which all OS'es implement. Memory which is backed by file storage (like mmapped files) is not swapped out.

Only heap allocated memory is swapped out.
I am indeed talking about heap allocated memory that (ideally) should not be swapped to disk if a large part of memory is being used to cache mmap()ed TB files.

Ideally, the OS would release memory pages used for caching TB data. Releasing such pages is a very cheap operation as there is no need to swap the data to a pagefile.

Unfortunately the OS cannot always know what is the best thing to do, so will sometimes choose instead to release heap allocated memory pages by swapping their data to the pagefile.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Problem with SF6 and Syzygy TB

Post by syzygy »

Zenmastur wrote:
syzygy wrote:Yes, the memory pages containing cached TB data show up as part of the process's memory in the Working Set column of the task manager. The Commit size column will look even worse, but that's just a number.

You're probably not doing this, but just in case, don't store TB files in a RAM disk. That will only make them use RAM twice: once in the RAM disk, once in the page cache. (A good RAM disk might avoid this problem but I doubt they exist for Windows.)
I don't have the TB file on a RAM disk at least for now due to memory limitations, they're on a SSD. I do have and use a ram disk, but I don't know if the version I have removes the memory it uses from the working pool. Even if it could, I haven't set up the OS to allow this, although it's not difficult to do.
Let me put it like this: RAM disks are simply a bad idea.

If the OS wants to use the data stored in the RAM disk, that data has to be copied to other parts of RAM (the page cache). So everything will simply take up memory _twice_. That is almost never a good idea. It is a very bad idea if you are trying to cope with 68GB of TB data on a 16GB system.
syzygy wrote:Just thought of something.

If you have 16GB and the WDL tables on SSD, simply disable your swap file. (I think it's called page file on Windows.)

Without a swap file, the system will not swap. Problem solved. When the system runs out of memory (because too much memory is used for caching TB data), the OS will have no other choice than to release memory pages caching TB data. And that is just what we want.

(I'm not kidding or trying to be sarcastic. I really doubt that for normal users, including heavy chess engine users, there is any practical advantage in having a swap file on a 16GB system.)
I would try this but, I do need more than 16 GB as I often use more than this, sometimes a lot more. It's surprisingly easy to do. I guess that makes me a non-normal user. My next system, coming soon I hope, will be a little more robust in the ram and mass storage departments.
You often need more than 16 GB, but still use a RAM disk? I'm afraid there is no logic in that.

In the time of 16 MB computers having another 16 MB of swap was a very good idea. The system would at some point run out of memory, and swapping a few MB of RAM to the pagefile was a relatively fast operation. Better to wait maybe a second than to get an out of memory error and a program that quits.

But now imagine a 16 GB system with another 16 GB of swap. Swapping a few GB to the pagefile will freeze your computer for many minutes. That makes your system unusable. Of course if you _really_ need 20 GB and only have 16 GB of physical RAM and lots of patience, then a pagefile will eventually do the trick, but this exceptional and far from ideal. In general, it is better to get an out of memory error if the 16 GB are exceeded, because most likely something went quite wrong and the alternative is a system that is unresponsive for many many minutes after which the user loses hope and forces a reboot.

Disabling any RAM disks and the page file will most likely make any modern system much more responsive.
I'm going to try a few things, if they don't help, I'll probably just go back to not using TB's for most tasks. They're nice in some instances, but not mandatory for most.
5-piece TBs won't eat more than 400MB.
User avatar
RJN
Posts: 303
Joined: Fri Jun 21, 2013 5:18 am
Location: Orion Spiral Arm

Re: Problem with SF6 and Syzygy TB

Post by RJN »

syzygy wrote:Just thought of something.

If you have 16GB and the WDL tables on SSD, simply disable your swap file. (I think it's called page file on Windows.)

Without a swap file, the system will not swap. Problem solved. When the system runs out of memory (because too much memory is used for caching TB data), the OS will have no other choice than to release memory pages caching TB data. And that is just what we want.

(I'm not kidding or trying to be sarcastic. I really doubt that for normal users, including heavy chess engine users, there is any practical advantage in having a swap file on a 16GB system.)
The only "practical advantage" that I have seen is that to enable large pages when hash is 8GB on a 16GB machine, there must be a page file of at least 4GB. This is on Win7 with H4.

(discussed here: http://talkchess.com/forum/viewtopic.ph ... _view=flat)

BTW, concerning the topic of the thread, I have never seen SF (or H4) thrashing the page file when using Syzygy-6 , RAM just fills up to the high 90% range, as some others here have also observed, and will be released as needed if another program is opened, all A-OK.
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Problem with SF6 and Syzygy TB

Post by hgm »

syzygy wrote:But now imagine a 16 GB system with another 16 GB of swap. Swapping a few GB to the pagefile will freeze your computer for many minutes. That makes your system unusable.
But it is rather unlikely your working set will abruptly change from one 16GB area to a completely different 16GB area. More typically the working set would be perhaps 1GB, and slowly diffuse through the 32GB available virtual memory, perhaps accessing 10 MB of new memory every second. The swapping would easily keep up with that.

The key factor in determining how much swapping slows you down is how often data, once brought into memory, can be used before the page has to be swapped out again.
Zenmastur
Posts: 919
Joined: Sat May 31, 2014 8:28 am

Re: Problem with SF6 and Syzygy TB

Post by Zenmastur »

I don't know whats going on ... maybe my computer is having problems. I ran a bunch of tests on it and everything seems to be OK. But I keep having weird problems with SF and Syzygy for some reason.

[D]8/8/8/8/3bK3/5n2/5k1p/7Q b - - 99 117

This position is dead lost for black. This is what I get from SF6 0315 development version:

Code: Select all

2015-04-04 23:00:44.898 Arena 3.5
2015-04-04 23:00:44.902
2015-04-04 23:00:45.222**----------New game---2015-04-04 23:00:45,222 Sat -------------
2015-04-04 23:00:45.393**screen: 1920x1080
2015-04-04 23:00:45.393**Monitors: 1
2015-04-04 23:00:45.393**Monitor0: 1920x1080
2015-04-04 23:00:45.393**FormMonitor: 0
2015-04-04 23:00:45.409**Loading  1
2015-04-04 23:01:49.429**----------New game---2015-04-04 23:01:49,429 Sat -------------
2015-04-04 23:02:22.918*1*-------------------------Starting engine 1 SF6-325--------------------------
2015-04-04 23:02:22.918*1*Configured Engine 1 Type:  Auto
2015-04-04 23:02:22.918*1*Engine 1 dir: L:\LB
2015-04-04 23:02:22.918*1*Engine 1 commandline: L:\LB\SF6-325.exe 
2015-04-04 23:02:23.105*1*Engine 1 ProcessID: 575556
2015-04-04 23:02:23.105*1*Engine 1 Prio:64 ThreadPrio:0
2015-04-04 23:02:23.105-->1:xboard
2015-04-04 23:02:23.136-->1:uci
2015-04-04 23&#58;02&#58;23.807<--1&#58;Stockfish 250315 64 POPCNT by Tord Romstad, Marco Costalba and Joona Kiiski
2015-04-04 23&#58;02&#58;23.838<--1&#58;Unknown command&#58; xboard
2015-04-04 23&#58;02&#58;23.838<--1&#58;id name Stockfish 250315 64 POPCNT
2015-04-04 23&#58;02&#58;23.838<--1&#58;id author Tord Romstad, Marco Costalba and Joona Kiiski
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Write Debug Log type check default false
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Contempt type spin default 0 min -100 max 100
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Min Split Depth type spin default 0 min 0 max 12
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Threads type spin default 1 min 1 max 128
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Hash type spin default 16 min 1 max 1048576
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Clear Hash type button
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Ponder type check default true
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name MultiPV type spin default 1 min 1 max 500
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Skill Level type spin default 20 min 0 max 20
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Move Overhead type spin default 30 min 0 max 5000
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Minimum Thinking Time type spin default 20 min 0 max 5000
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Slow Mover type spin default 80 min 10 max 1000
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name UCI_Chess960 type check default false
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name SyzygyPath type string default <empty>
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name SyzygyProbeDepth type spin default 1 min 1 max 100
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name Syzygy50MoveRule type check default true
2015-04-04 23&#58;02&#58;23.854<--1&#58;option name SyzygyProbeLimit type spin default 6 min 0 max 6
2015-04-04 23&#58;02&#58;23.854<--1&#58;uciok
2015-04-04 23&#58;02&#58;23.854-->1&#58;setoption name Write Debug Log value false
2015-04-04 23&#58;02&#58;23.854-->1&#58;setoption name Contempt value 0
2015-04-04 23&#58;02&#58;23.854-->1&#58;setoption name Min Split Depth value 0
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name Threads value 1
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name Hash value 2048
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name Ponder value true
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name MultiPV value 1
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name Skill Level value 20
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name Move Overhead value 30
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name Minimum Thinking Time value 20
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name Slow Mover value 80
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name UCI_Chess960 value false
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name SyzygyPath value <empty>
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name SyzygyProbeDepth value 1
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name Syzygy50MoveRule value true
2015-04-04 23&#58;02&#58;23.869-->1&#58;setoption name SyzygyProbeLimit value 6
2015-04-04 23&#58;02&#58;23.916-->1&#58;isready
2015-04-04 23&#58;02&#58;23.955<--1&#58;readyok
2015-04-04 23&#58;03&#58;28.109**Time for starting engines for analysis&#58;0 ms
2015-04-04 23&#58;03&#58;28.109-->1&#58;isready
2015-04-04 23&#58;03&#58;28.109<--1&#58;readyok
2015-04-04 23&#58;03&#58;28.127-->1&#58;ucinewgame
2015-04-04 23&#58;03&#58;28.127-->1&#58;isready
2015-04-04 23&#58;03&#58;38.234-->1&#58;position fen 8/8/8/8/3bK3/5n2/5k1p/7Q b - - 99 117
2015-04-04 23&#58;03&#58;38.234-->1&#58;go infinite
2015-04-04 23&#58;03&#58;38.234**Time for starting analysis&#58;10.125
2015-04-04 23&#58;03&#58;43.172<--1&#58;readyok
2015-04-04 23&#58;03&#58;43.188<--1&#58;info depth 1 seldepth 1 multipv 1 score cp 0 nodes 20 nps 1666 tbhits 0 time 12 pv f3e1
2015-04-04 23&#58;03&#58;43.281<--1&#58;info depth 2 seldepth 2 multipv 1 score cp 0 nodes 40 nps 3333 tbhits 0 time 12 pv f3e1
2015-04-04 23&#58;03&#58;43.281<--1&#58;info depth 3 seldepth 2 multipv 1 score cp 0 nodes 60 nps 5000 tbhits 0 time 12 pv f3e1
2015-04-04 23&#58;03&#58;43.281<--1&#58;info depth 4 seldepth 2 multipv 1 score cp 0 nodes 80 nps 6666 tbhits 0 time 12 pv f3e1
2015-04-04 23&#58;03&#58;43.297<--1&#58;info depth 5 seldepth 2 multipv 1 score cp 0 nodes 100 nps 8333 tbhits 0 time 12 pv f3e1
2015-04-04 23&#58;03&#58;43.297<--1&#58;info depth 6 seldepth 2 multipv 1 score cp 0 nodes 120 nps 10000 tbhits 0 time 12 pv f3e1
2015-04-04 23&#58;03&#58;43.297<--1&#58;info depth 7 seldepth 2 multipv 1 score cp 0 nodes 140 nps 11666 tbhits 0 time 12 pv f3e1

.
.
.

2015-04-04 23&#58;03&#58;43.609<--1&#58;info depth 99 seldepth 2 multipv 1 score cp 0 nodes 1980 nps 7528 tbhits 0 time 263 pv f3e1
2015-04-04 23&#58;03&#58;43.624<--1&#58;info depth 100 seldepth 2 multipv 1 score cp 0 nodes 2000 nps 7604 tbhits 0 time 263 pv f3e1
2015-04-04 23&#58;03&#58;43.624<--1&#58;info depth 101 seldepth 2 multipv 1 score cp 0 nodes 2020 nps 7680 tbhits 0 time 263 pv f3e1
2015-04-04 23&#58;03&#58;43.624<--1&#58;info depth 102 seldepth 2 multipv 1 score cp 0 nodes 2040 nps 7756 tbhits 0 time 263 pv f3e1
2015-04-04 23&#58;03&#58;43.624<--1&#58;info depth 103 seldepth 2 multipv 1 score cp 0 nodes 2060 nps 7832 tbhits 0 time 263 pv f3e1
2015-04-04 23&#58;03&#58;43.640<--1&#58;info depth 104 seldepth 2 multipv 1 score cp 0 nodes 2080 nps 7908 tbhits 0 time 263 pv f3e1
2015-04-04 23&#58;03&#58;43.640<--1&#58;info depth 105 seldepth 2 multipv 1 score cp 0 nodes 2100 nps 7984 tbhits 0 time 263 pv f3e1

.
.
.

2015-04-04 23&#58;03&#58;43.702<--1&#58;info depth 124 seldepth 2 multipv 1 score cp 0 nodes 2480 nps 9429 tbhits 0 time 263 pv f3e1
2015-04-04 23&#58;03&#58;43.718<--1&#58;info depth 125 seldepth 2 multipv 1 score cp 0 nodes 2500 nps 9505 tbhits 0 time 263 pv f3e1
2015-04-04 23&#58;03&#58;43.718<--1&#58;info depth 126 seldepth 2 multipv 1 score cp 0 nodes 2520 nps 9581 tbhits 0 time 263 pv f3e1
2015-04-04 23&#58;03&#58;43.718<--1&#58;info depth 127 seldepth 2 multipv 1 score cp 0 nodes 2540 nps 9657 tbhits 0 time 263 pv f3e1
Is this normal?

Regards,

Zen
Only 2 defining forces have ever offered to die for you.....Jesus Christ and the American Soldier. One died for your soul, the other for your freedom.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Problem with SF6 and Syzygy TB

Post by Ferdy »

Zenmastur wrote:I don't know whats going on ... maybe my computer is having problems. I ran a bunch of tests on it and everything seems to be OK. But I keep having weird problems with SF and Syzygy for some reason.

[D]8/8/8/8/3bK3/5n2/5k1p/7Q b - - 99 117

This position is dead lost for black. This is what I get from SF6 0315 development version:

Code: Select all

2015-04-04 23&#58;03&#58;43.718<--1&#58;info depth 127 seldepth 2 multipv 1 score cp 0 nodes 2540 nps 9657 tbhits 0 time 263 pv f3e1
Is this normal?

Regards,

Zen
It is normal because of the high value of fifty move counter in fen.