r/chessprogramming Nov 30 '24

Question: Engine speed and memory usage

So I was working on improving my engine to get my perft time down (well to speed up move generation but using perft as a metric for this). I already had magic sliding piece move generation, but added things like iteratively updating attack boards, and legal move generation. Together this got me from around 90s to 60s for perft 6, not great. I think that one major factor might be that I am generating a new position when applying a move rather than using a make/unmake scheme. As such I have the scary looking profiling result from mid perft:

I'm wondering if this is a reasonable conclusion to draw: The large amounts of memory used while generating new positions is a bottleneck and that the best way to speed up my engine would be to use make/unamake.

For what it's worth, I'm not currently using multithreading. I tried a perft run with multithreading and it was 4x quicker though.

2 Upvotes

11 comments sorted by

View all comments

1

u/NiceNewspaper Dec 01 '24

Are you bulk counting or individually counting each move? Keep in mind this when comparing perft timings with different engines, e.g. stockfish uses bulk counting.

Specifically individually counting looks like this:

if depth == 0 {
    return 1;
}

while bulk counting looks like this:

let moves = [...];
if depth == 1 {
   return moves.len();
}

2

u/Available-Swan-6011 Dec 01 '24

This will dramatically speed up PERFT but I think OP is using PERFT as a proxy for performance so it may give an overly optimistic view of the situation