I am currently learning Haskell for fun because I always wanted to see how you design programs in a non object orientated sense.
But I am also researching if it is useful to use Haskell for a game engine. My main concern is the GC.
I know that GHC is concurrent and thread local.
I read that the GC usually pauses between 1ms-5ms. I know that it is different for every program, but still I need some numbers to make some calculations.
Let's say my game runs at 60fps
that means every frame needs 0.016666667s
of calculation right? A gc pause would increase this to ~0.017666667
which results in 56fps
. So it s a performance loss of ~4fps
or 7%
. For me that is a pretty big hit.
Now I am counting on the thread local GC because I want my game engine to be highly concurrent.
I want to use the Actor model for the game code so every entity will have it's own memory. If I am right this means that every entity has it's own local garbage collection.
But the main problem is still the game engine with it's main loop. Random fps drops of 7% is pretty big.
Are my calculation correct? Any recommendations that you can give me?
Your calculation is biased.
You're right: 60 fps = 1 frame every 0.0166667 seconds.
Let's suppose (worst case) that the GC pauses the program for 5ms. Each times the GC runs, you lose 0.005. It means that each times the GC is called, you lose 0.333 fps.
To obtain a correct computation, we need to be able to know how often the GC is called, which I don't know and is certainly linked to the amount of data generated by your program.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With