Yes; you either use Arc<Mutex<T>>, or you go unsafe. There is no in-between road and be "a little bit safe".Ras wrote: ↑Sun Nov 14, 2021 3:10 pm That would be more reasonable than trying to fight the language because race conditions like that are exactly what the borrow checker is designed to reject. Even if you find a suitable loophole in the language right now, expect that to be closed later because that's the point of Rust. Concurrent TT access without mutex is inherently "unsafe".
I'll see it when I get there. Right now I'm using Arc<Mutex<T>> because I want the engine to have safe code as much as possible until it just isn't practical anymore with regard to speed. Now it's not really a problem because there's only one search thread. (And yes, the Mutex does obviously slow the TT down, but because the TT is in the main thread and the search is in its own thread, that can't be helped.) I use unsafe to swap move structs in memory, and to create an unitialized move list; not doing this tanks the engine's speed by something like 70%, so using unsafe there is essential. (Fortunately in these cases, there's only one line of unsafe code, and it's very obvious what it does and why.)What's more, it's even platform dependent what can work because e.g. atomicity is different on 32 bit vs. 64 bit, and memory ordering is different on x86 vs. ARM so that the latter may require some additional memory barriers.
The only 32-bit version of Rustic is the Raspberry Pi ARM-version, because the 64-bit OS is (as far as I know) still experimental.
I wonder if PicoChess, which is based on a _very_ old version of PyChess, will even run on Bullseye. Support for Python 2 has been dropped, PicoChess is incompatible with newer versions of PyChess, while the PyChess version it uses is incompatible with Python 3. Completely within the Python tradition of "Let's break the world like we see fit, and here's my middle finger."
I.e.... the only reason for me to compile a 32-bit version of Rustic is because I want it to run on the Raspberry Pi under PicoChess. I built my own image (on Buster) which I can use indefinitely until I get around to try and write a proper PicoChess replacement in Rust that _WON'T_ break on every other update of the language.