Posts

Showing posts with the label multi-threading

Optimisation lessons learned (part 3)

Image
To finish my little series on CPU optimisation (here were part 1 and part 2 , today I bring out the big guns: threading and timing! This is where optimisation really shines as a form of pure entertainment and delight. I can honestly hardly imagine why anyone ever does Sudokus or crosswords. Puzzling to find the best optimisations is so much more fun! Hiccups are horrible without the right tools Framerate hiccups are a special case. This is when the game is running at a high enough framerate, but once in a while a single frame takes a lot longer. Hiccups cause that a game running at 55fps might look a lot less fluent than one running at 30fps, if every second the 55fps consists of 54 smooth frames and one really long one. The difficulty here is that when you gather performance data, the time spent in each function will usually be averaged. This means that if a function runs really fast most of the time and is really slow only once per second, then it will look like a normal function in...

Question: how to synchronise between the game and render thread?

Image
In today's blogpost, I'd like to do something radically different: I'm going to ask you a question . I know that quite a few of the visitors of my blog are hardcore programmers, and since I have a complex situation for which I would like to improve the performance, I figured I could ask for advice here! :) The problem is pretty complex, though, so I figured a short blogpost would be needed to really explain it. In short, this is the question: What is the most efficient way to synchronise renderable objects between the game thread and the render thread? There are a couple of subtleties you need to know to answer this for our situation, though. Let me start with a scheme that shows the approach to threading in the Ronitech (our in-house multiplatform 2D engine), as we use it in Awesomenauts on the Xbox 360 and Playstation 3: This works fine and we managed to get 60fps on console this way. However, the copying phase takes relatively long, so I am still wasting a lot of perfor...