A comparison of some Perft programs 

Discussion of chess software programming and technical issues.

Moderator: Ras

chessbit
Posts: 53
Joined: Fri Dec 29, 2023 4:47 pm
Location: Belgium
Full name: thomas huijbregts

Re: A comparison of some Perft programs 

Post by chessbit »

I found a few more tricks to boost the speed significantly. It's been two days and I haven't found anything to improve further, so this might be the final version.

no TT, single thread:

Code: Select all

Perft Start 1: 20 0ms 10 MNodes/s
Perft Start 2: 400 0ms 22.2222 MNodes/s
Perft Start 3: 8902 0ms 247.278 MNodes/s
Perft Start 4: 197281 0ms 2192.01 MNodes/s
Perft Start 5: 4865609 0ms 5412.25 MNodes/s
Perft Start 6: 119060324 17ms 6872.17 MNodes/s
Perft Start 7: 3195901860 409ms 7809.66 MNodes/s
OK

Perft Kiwi 1: 48 0ms 24 MNodes/s
Perft Kiwi 2: 2039 0ms 1019.5 MNodes/s
Perft Kiwi 3: 97862 0ms 3624.52 MNodes/s
Perft Kiwi 4: 4085603 0ms 4800.94 MNodes/s
Perft Kiwi 5: 193690690 25ms 7576.1 MNodes/s
Perft Kiwi 6: 8031647685 1301ms 6172.82 MNodes/s
OK
TT, multithread:

Code: Select all

Depth:          10
Nodes:          69352859712417
Time:           20060 ms

Depth:          11
Nodes:          2097651003696806
Time:           279640 ms
Could easily divide this by 2 with a CPU with more cores, or more with a top shelf multithread CPU.
https://github.com/thomashuijbregts

chessbit - fast CPU perft engine
Crownd - strong UCI engine with NNUE evaluation
User avatar
phhnguyen
Posts: 1550
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Perft comparison, part 2: start position, Perft 9, on a new PC

Post by phhnguyen »

Perft comparison, part 2: start position, Perft 9, on a new PC

This follows my earlier comparison on an old PC, Ryzen 7 1700, Perft 8, posted on the first page.
After some years of postponing, I finally bought a new PC. One of my first tasks was to rerun that comparison on the new PC. Several programs have been updated since then. This time, every program ran one depth deeper, Perft 9, including the slow single-thread ones, perft_gpu_2026, Xiphos was added.

Machine
AMD Ryzen 9 9950X3D (16 cores / 32 threads, Zen 5, AVX-512, fast PEXT), 32 GB DDR5-6000 CL38 (EXPO), NVIDIA RTX 5070 12 GB, Windows 11. The PC was idle during the runs.

Results: start position, perft 9 = 2,439,530,234,167 (every program gave the correct count)
Time = the time the program itself reports for the perft calculation (start-up, loading and hash allocation not included). Each program ran in its best configuration: all 32 threads for multi-threaded programs, the best hash size for programs with a hash table, and the fastest build (my own native build or the author's exe, whichever was faster).

Code: Select all

#   Program                          Threads  Hash     Time         Speed
1   perft_gpu_2026                   GPU      8 GB       0.443 s   5,507 Gnps
2   chessbit (boardstate_tt)         32       8 GB       0.972 s   2,510 Gnps
3   MPerft 5.3                       32       8 GB       2.934 s     831 Gnps
4   perft_cpu_2026                   32       8 GB       3.864 s     631 Gnps
5   hqperft 1.1                      1        8 GB     111.0 s        22 Gnps
6   qperft                           1        8 GB     160.9 s        15 Gnps
7   Juddperft                        32       8 GB     210.6 s        12 Gnps
8   chessbit (boardstate_fastest) *  1        -        800.8 s       3.0 Gnps
9   Gigantua *                       1        -       1059.7 s       2.3 Gnps
10  Xiphos 0.6 *                     1        -       3113.7 s       0.78 Gnps
11  BBPerft *                        1        -       4792.4 s       0.51 Gnps
12  Stockfish 19 *                   1        -       6641.6 s       0.37 Gnps
Other builds of the same programs:
  • MPerft 5.3 built on my PC (clang 23, PGO, -march=native): 3.248 s. The author's own v3 exe was faster.
  • MPerft 5.3 in plain bulk-counting mode (-b, the same counting method as the others; its default -n mode counts the last ply differently): 4.448 s.
  • perft_cpu_2026 built with MSVC (the author's CMake build): 4.564 s.
  • hqperft and qperft with a 1 GB hash: 113.2 s and 200.4 s.
  • Xiphos built on my PC (GCC 16, -march=native, PGO) was about 12% slower than the author's bmi2 exe, so the author's exe was used.
The programs and how to run them at their best
FEN = rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

1. perft_gpu_2026 (Ankan Banerjee, github ankan-ban/perft_gpu_2026, 2026-07-29)
Built with nvcc 13.4, -O3 -arch=sm_120.

Code: Select all

perft_gpu.exe "<FEN>" 9 -dtt 8192 -htt 8192
Always set -dtt (GPU memory) and -htt (host memory) yourself. The defaults take 95% of free VRAM and 90% of RAM.

2. chessbit, boardstate_tt branch (Thomas Huijbregts, github thuijbregts/chessbit, 2026-08-01)
Built with clang++ 23, -O3 -march=native -std=c++23, PGO. It is interactive; send these lines:

Code: Select all

setfen <FEN>
tt on
perft -d 9 -t 32 -h 8192
exit
  • Always give -h <MB>. Without it, the hash takes 90% of free RAM.
  • perft -d is the multi-threaded mode; plain perft <d> uses one thread.
3. MPerft 5.3 (Richard Delorme, GitHub abulmo/MPerft, 2026-06-26)
The official mperft-5.3-x86-64-v3.exe was the fastest MPerft build.

Code: Select all

mperft -f "<FEN>" -d 9 -n -t 32 -h 8192 -q
-n is the default fast mode, which does null-move counting at the last-but-one ply. -b gives plain bulk counting.

4. perft_cpu_2026 (Ankan Banerjee, github ankan-ban/perft_cpu_2026, 2026-08-23)
Built with clang++ 23, -O3 -flto -march=native, no PGO. The author's README says PGO slows the hash runs by about 7%.

Code: Select all

perft_cpu.exe "<FEN>" 9 -htt 8192 -mt 32
Always set -htt; the default is 90% of RAM. -nott turns the hash off.

5. hqperft 1.1 (Richard Delorme, github abulmo/hqperft, 2024-03-24)
Built with gcc 16, -Ofast -flto -march=native, PGO.

Code: Select all

hqperft -f "<FEN>" -d 9 -b -H 29
The hash size is given in bits: 2^29 entries x 16 bytes = 8 GB.

6. qperft (H.G. Muller, perft.c from his website)
Built with gcc 16, -O3 -march=native -flto, PGO, as a 64-bit program. That needed a one-line patch: the hash alignment cast (int)Hash truncated pointers.

Code: Select all

qperft 9 H29 "<FEN>"
The hash size is given in bits (H29 = 8 GB). It writes a log file, log.txt, in the working folder.

7. Juddperft (Judd Niemann, github jniemann66/juddperft, 2026-01-11)
Built with g++ 16, -O3 -mcx16 -march=native -flto, PGO. It is interactive:

Code: Select all

memory 8589934592
cores 32
setboard <FEN>
perftfast 9
quit
  • The memory size is in bytes, and "1G" means 10^9 bytes.
  • It allocates about 5 GB at start-up before memory resizes the table.
  • It writes a log file, perft.txt, in the working folder.
8. chessbit, boardstate_fastest branch (Thomas Huijbregts, 2026-07-18)
Built like boardstate_tt. Interactive: setfen <FEN>, perft 9, exit.
  • Problem: it cannot go deeper than perft 7: the depth is a template parameter, and the switch in Cui::generateMoves() has the cases for depths 8-18 commented out, so "perft 8" prints "Nodes: 0". There is no command-line option for it. I uncommented the cases for depths 8 and 9 only; each extra case makes the already long compile longer.
  • Bug report for the author: this branch's perft -d (divide) mode miscounts on positions with castling, even with -t 1. Kiwipete perft 5 gives 193,945,275 instead of 193,690,690. Its plain perft <d> is correct, and so is boardstate_tt in every mode.
9. Gigantua (Daniel Infuehr, github Gigantua/Gigantua, 2021-11-15)
Built with clang++ 23, -O3 -flto -march=native -std=c++20, PGO. This build needed about 40% less time than the official 1.6 exe (perft 8: 37.4 s vs 61.0 s).

Code: Select all

Gigantua.exe "<FEN>" 9
It computes perft 1 to 9 in turn and waits for a key at the end. The time shown is its perft 9 line.

10. Xiphos 0.6 (Milos Tatarevic, github milostatarevic/xiphos)
The author's xiphos-0.6-w64-bmi2.exe. It is a UCI engine with a perft command:

Code: Select all

position startpos
perft 9
quit
To build it with gcc 15 or newer, add -std=gnu17: the C23 default rejects its old-style declarations.

11. BBPerft (Manik Charan, github Mk-Chan/BBPerft, 2020-08-29)
Built with g++ 16, -O3 -march=native -flto, PGO.

Code: Select all

bbperft -f "<FEN>" -d 9
12. Stockfish 19 (Stockfish team, tag sf_19)
make profile-build ARCH=x86-64-avx512icl COMP=mingw, static.

Code: Select all

position startpos
go perft 9
quit
go perft is single-threaded, without a hash table, and prints no time. I added a timer around the perft call in UCIEngine::perft() (uci.cpp; it prints "Time: <ms> ms" after "Nodes searched"), so the start-up and the NNUE loading are not counted. Nothing else was changed.
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
gaard
Posts: 465
Joined: Mon Jun 07, 2010 3:13 am
Location: Holland, MI
Full name: Martin W

Re: A comparison of some Perft programs 

Post by gaard »

For shoots and giggles, I ran AJ Siemelink's 15 year old frcperft code through Claude and ran some benchmarks. It now uses pext bitboards, multithreading, and hash. This is on an old i7 9750H.

Code: Select all

./frcperft -threads 6 -hash 8192 9

frcperft 1.0-opt, (C) 2008-2011 AJ Siemelink
modified version (threads, hashing, pext); threads=6, hash=8192MB, mode=FAST, extract=BUILTIN, count=BUILTIN, pext=1

perft 1             20       0.00s      1.0 mnps  182.5 ticks/move
perft 2            400       0.00s     26.2 mnps   98.8 ticks/move
perft 3           8902       0.00s    236.8 mnps   10.9 ticks/move
perft 4         197281       0.00s    388.3 mnps    6.7 ticks/move
perft 5        4865609       0.00s   2513.3 mnps    1.0 ticks/move
perft 6      119060324       0.02s   5695.0 mnps    0.5 ticks/move
perft 7     3195901860       0.21s  15264.2 mnps    0.2 ticks/move
perft 8    84998978956       2.66s  31978.0 mnps    0.1 ticks/move
perft 9  2439530234167      32.35s  75417.4 mnps    0.0 ticks/move

./frcperft -threads 6 -hash 8192 10

frcperft 1.0-opt, (C) 2008-2011 AJ Siemelink
modified version (threads, hashing, pext); threads=6, hash=8192MB, mode=FAST, extract=BUILTIN, count=BUILTIN, pext=1

perft 1             20       0.00s     18.0 mnps  131.9 ticks/move
perft 2            400       0.00s     24.8 mnps  104.4 ticks/move
perft 3           8902       0.00s    373.4 mnps    6.9 ticks/move
perft 4         197281       0.00s    395.1 mnps    6.6 ticks/move
perft 5        4865609       0.00s   2455.1 mnps    1.1 ticks/move
perft 6      119060324       0.02s   5550.2 mnps    0.5 ticks/move
perft 7     3195901860       0.21s  15146.5 mnps    0.2 ticks/move
perft 8    84998978956       2.67s  31889.4 mnps    0.1 ticks/move
perft 9  2439530234167      32.89s  74165.5 mnps    0.0 ticks/move
perft 10 69352859712417     400.90s 172993.9 mnps    0.0 ticks/move
User avatar
phhnguyen
Posts: 1550
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: A comparison of some Perft programs 

Post by phhnguyen »

I have compiled and run frcperft on my new pc as request from Gaard. His Perft 9 5s takes the rank 5th. Congrats!!!
Below is the result:

frcperft 1.0-opt modified (gaard's version), start position, hash 8192 MB
AMD Ryzen 9 9950X3D (16 cores / 32 threads), Windows 11, GCC 16.2 -march=native PGO, PC idle, one run each

Code: Select all

Threads   perft 8   perft 9   perft 10   perft 10 speed
-------   -------   -------   --------   --------------
     32    0.47 s    5.07 s    52.28 s    1,326,664 mnps
     16    0.49 s    6.44 s    78.65 s      881,832 mnps
      6    1.16 s   17.94 s   203.93 s      340,082 mnps
      6 *  2.66 s   32.35 s   400.90 s      172,994 mnps

* gaard's run on an i7 9750H (post above)
All node counts are correct (perft 10 = 69,352,859,712,417).
The program runs perft 1..N in one go with the same hash table, so its perft 9 time comes after a warm-up by perft 1-8.
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager