likeawizard / tofiks

UCI chess engine written in Go
GNU General Public License v3.0
16 stars 0 forks source link

Memory allocation #50

Closed SzotsGabor closed 11 months ago

SzotsGabor commented 11 months ago

I set hash to 256 MB but reported memory usage is almost 600 MB. Is that normal?

likeawizard commented 11 months ago

I would not use the word normal but I have observed that the engine takes around 2x of the hash table size of memory.

Again I would need some investigation. I am certain that I the hash table I create is of the right size: entries = number of bytes for Hash / entry size in bytes

It might be go is allocating extra memory in case I wanted to expand it or there is some other memory overhead.

I super appreciate you bringing up all these issues. Working solo I probably have a tunnel vision so it's good to have some input from a different perspective.

likeawizard commented 11 months ago

@SzotsGabor I have put in some work and I can say it's normal - the hash table is of the correct size and it's go's garbage collector that is creating the overhead. There might be ways to try to tinker with the garbage collector but so far I have not found an obvious way to optimize it.

Closing this for now.