mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 17:16:33 +08:00
Advise the kernel to use huge pages (Linux)
Align the TT allocation by 2M to make it huge page friendly and advise the
kernel to use huge pages.
Benchmarks on my i7-8700K (6C/12T) box: (3 runs per bench per config)
vanilla (nps) hugepages (nps) avg
==================================================================================
bench | 3012490 3024364 3036331 3071052 3067544 3071052 +1.5%
bench 16 12 20 | 19237932 19050166 19085315 19266346 19207025 19548758 +1.1%
bench 16384 12 20 | 18182313 18371581 18336838 19381275 19738012 19620225 +7.0%
On my box, huge pages have a significant perf impact when using a big
hash size. They also speed up TT initialization big time:
vanilla (s) huge pages (s) speed-up
=======================================================================
time stockfish bench 16384 1 1 | 5.37 1.48 3.6x
In practice, huge pages with auto-defrag may always be enabled in the
system, in which case this patch has no effect. This
depends on the values in /sys/kernel/mm/transparent_hugepage/enabled
and /sys/kernel/mm/transparent_hugepage/defrag.
closes https://github.com/official-stockfish/Stockfish/pull/2463
No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
6d0eabd5fe
commit
39437f4e55
16
src/tt.h
16
src/tt.h
@@ -57,24 +57,22 @@ private:
|
||||
};
|
||||
|
||||
|
||||
/// A TranspositionTable consists of a power of 2 number of clusters and each
|
||||
/// cluster consists of ClusterSize number of TTEntry. Each non-empty entry
|
||||
/// contains information of exactly one position. The size of a cluster should
|
||||
/// divide the size of a cache line size, to ensure that clusters never cross
|
||||
/// cache lines. This ensures best cache performance, as the cacheline is
|
||||
/// prefetched, as soon as possible.
|
||||
/// A TranspositionTable is an array of Cluster, of size clusterCount. Each
|
||||
/// cluster consists of ClusterSize number of TTEntry. Each non-empty TTEntry
|
||||
/// contains information on exactly one position. The size of a Cluster should
|
||||
/// divide the size of a cache line for best performance,
|
||||
/// as the cacheline is prefetched when possible.
|
||||
|
||||
class TranspositionTable {
|
||||
|
||||
static constexpr int CacheLineSize = 64;
|
||||
static constexpr int ClusterSize = 3;
|
||||
|
||||
struct Cluster {
|
||||
TTEntry entry[ClusterSize];
|
||||
char padding[2]; // Align to a divisor of the cache line size
|
||||
char padding[2]; // Pad to 32 bytes
|
||||
};
|
||||
|
||||
static_assert(CacheLineSize % sizeof(Cluster) == 0, "Cluster size incorrect");
|
||||
static_assert(sizeof(Cluster) == 32, "Unexpected Cluster size");
|
||||
|
||||
public:
|
||||
~TranspositionTable() { free(mem); }
|
||||
|
||||
Reference in New Issue
Block a user