]> git.sesse.net Git - stockfish/commit - src/syzygy/tbprobe.cpp
Turn on MADV_RANDOM for Syzygy mmaps (on Unix-like builds)
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 24 Nov 2018 10:17:12 +0000 (11:17 +0100)
committerStéphane Nicolet <cassio@free.fr>
Tue, 27 Nov 2018 07:39:23 +0000 (08:39 +0100)
commitde7182f4eee33029a7b79f6b097db06357669127
tree8ddc7002b84bf11bf28ceecf8da440f7b693bfe3
parent6ab92d2e1c417fa7a9fd87eee0add2bf02112296
Turn on MADV_RANDOM for Syzygy mmaps (on Unix-like builds)

When running on a cloud VM (n1-highcpu-96) with several NVMe SSDs and
some non-SSDs for tablebases, I noticed that the average SSD request size was
more than 256 kB. This doesn't make a lot of sense for Syzygy tablebases,
which have a block size of 32 bytes and very low locality.

Seemingly, the tablebase access patterns during probing make the OS,
at least Linux, think that readahead is advantageous; normally, it
gives up doing readahead if there are too many misses, but it doesn't,
perhaps due to the fairly high overall hit rates. (It seems the kernel cannot
distinguish between reading a block that was paged in because the userspace
wanted it explicitly, and one that was read as part of readahead.)

Setting MADV_RANDOM effectively turns off readahead, which causes
the request size to drop to 4 kB. In the aforemented cloud VM test,
this roughly tripled the amount of I/O requests that were able to go
through, while reducing the total traffic from 2.8 GB/sec to 56 MB/sec
(moving the bottleneck to the non-SSDs; it seems the SSDs could have
sustained many more requests).

Closes https://github.com/official-stockfish/Stockfish/pull/1829

No functional change.
src/syzygy/tbprobe.cpp