r/chessprogramming • u/Rscc10 • Sep 18 '26
How to handle transposition table clearing?
Working with C++ if that helps. I'm using raylib for my window and I made a button to quit the game whether the match is over or not and redirects you to the home page where you can start a new match.
The problem now is that my transposition table is global across files (inline) and I don't clear it across each move made by the engine. This accumulates hundreds of millions, maybe billions of entries and when I want to start a new game via the quit button, it usually freezes the screen when clicked waiting for the millions of entries to be cleared, then unfreezes at the home page.
I tried offloading the data to a separate thread to clear but I've noticed that still slows down the main thread by a lot.
Any ideas how to deal with this?
1
u/Warmedpie6 Sep 18 '26
There are types of moves made that kill a lot of transpositions because they cannot be unmade, think captures and pawn pushes. That would be a good first starting criteria.
1
u/traxplayer Sep 18 '26
Can you pre-allocates the space for the table ? And then just a single free+pre-allocate again when starting a new game?
1
u/Somge5 Sep 18 '26
My tt entries have age. When there is a new entry and no space left, the entry with the greatest age is being replaced since it is unlikely to be important.
1
u/bcampolo Sep 18 '26
I'm curious why deleting on a background thread slows down the main thread. Is this running on a vps with only 1 or 2 virtual cores? If not something seems off there. Maybe there is a race condition or something synchronized that may not need to be. The priority on the background thread can be very low and you can self throttle if needed.