Low and Medium compression could be much faster by skipping legality check when decoding.
|
let r = uci.to_move(&self.chess).map_err(|_| DecodeError {}); |
|
Some(r.map(|m| { |
|
self.chess.play_unchecked(m); // uci.to_move already checks legality |
|
self.index += 2; |
|
m |
|
})) |
The to_move method is generating all legal moves under the hood on every single position, which is very slow. I've experimented with removing the legality check from to_move (if the movedata was created using this crate then it should always be legal) and decoding becomes >2x faster.
Changes to to_move:
// if pos.is_legal(candidate) {
Ok(candidate)
// } else {
// Err(IllegalUciMoveError)
// }
cargo bench
decode_low time: [6.1855 µs 6.2020 µs 6.2204 µs]
change: [−54.883% −54.641% −54.385%] (p = 0.00 < 0.05)
Performance has improved.
Low and Medium compression could be much faster by skipping legality check when decoding.
aix/aix-chess-compression/src/naive.rs
Lines 122 to 127 in 728e58f
The
to_movemethod is generating all legal moves under the hood on every single position, which is very slow. I've experimented with removing the legality check fromto_move(if the movedata was created using this crate then it should always be legal) and decoding becomes >2x faster.Changes to
to_move:cargo bench