This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse the repository at this point in the history
Reducing memory usage (substantial perf increase)
Instead of passing a variation down through the negamax recursion tree, we instead build it up on the way back out. This allows us to preserve both overall memory and allocations, since we were cloning the variation many times. In order to accommodate this, we also now store merely the "remaining" portion of a variation in our memory bank; now instead of a map from (WorldState -> (full variation, depth-of-finding, score)), we instead maintain a map of ((WorldState, depth-of-finding) -> (remaining variation, score)). So in addition to saving various allocations & memory on the stack, we're saving memory in our cache! which hopefully means we get more cache hits since we have to evict less often. Running time for `./leafline --correspond --depth 5 --from 'rnbqkbnr/pp1p1ppp/2p5/4P3/2P5/8/PP2PPPP/RNBQKBNR b KQkq - 0 3'` has decreased from approximately 19s to approximately 13s, which is sort of unbelievable. the regular benchmarks show a more modest but also consistent improvement in the 5-10% range. Running the same with depth 6 shows the astonishing time drop of 282s -> 156s. PLEASE double check these results; I find them hard to believe.
- Loading branch information
Showing 1 changed file with 32 additions and 35 deletions.