I've been testing my engine's functionality by running some of the tests from testsuite.epd. Everything seems to check out with regard to correct moves being found, but I find the speed to be very disappointing.
Earlier this evening it took 10.8 seconds to run perft 6 from the starting position; the reason being that I was using a Vector to store my move list. The allocation of this vector in the perft function took a huge amount of time. I've removed it and replaced it with an array, dropping the perft time from 10.8 to 8.4 seconds.
8.4 seconds is still slow.
I switched my Rust toolchain from windows-gnu to windows-msvc (microsoft), to make sure it wasn't a problem with gnu-part of the toolchain. The Rust compiler uses LLVM to compile (just like CLANG does), and then links the files using either GNU's or Microsoft's linker. (Rust doesn't have its own linker.)
No difference; when using the MSVC toolchain, the perft 6 run from the starting position still took 8.4 seconds.
Then I installed Intel VTune to profile the program (when linked with MSVC; VTune under Windows doesn't seem to understand the GNU debug symbols so all functions are mangled.)
See the attached screenshot. (edit: can't attach anything...)
Short explanation then:
Some function in the MSVC runtime is taking half the time of this run, or 4.2 seconds. When clicking through the results and opening the source code in the profiler, the next most used functions are the make/unmake functions. They take the most amount of time, followed by square_attacked. (After the MSVC function...) High usage of make_move, unmake_move and square_attacked() is to be expected of course. (I still find it strange that make_move() doesn't make an appearance, but perft() does; when clicking the result for perft(), it highlights the make_move() line as the one used most.)
The only thing I can imagine that is taking so much time is the memory allocation of the array in the perft function:
Code: Select all
let mut move_list = MoveList::new();
Does anyone have any idea how I can speed up this perft function by bringing down the time spent in code that is not mine? If half of the time is going to be spent in MSVC libraries (in particular that one function shown in the VTune screenshot), this is going to become one slow engine.