How long should I sleep the Cooperative Pathfinding Thread?

Started by
0 comments, last by C0lumbo 8 years, 3 months ago

I sleep it for

1000 millisecs / fps

the fps rate is generally 60-70 frames per sec

so it just sleeps for 16-17 milli secs which is extremely fast.

Can I slow down the cpf thread further more because the renderer/mainthread cannot catch up?

Thanks

Jack

Advertisement

What exactly is the thread doing? Waking up every 16ms to see if there's some work that needs doing, and if not, going back to sleep?

If that's it, then I would probably sleep more like 1ms, because the cost of waking up to poll for some work is pretty cheap. But if you're still worried about performance, then you might be better using a better construct like having the thread wait on a semaphore, then when some work is scheduled for it, signal the semaphore and the thread will wake up and do it.

Or maybe you're worried that the thread is taking up too much CPU time and it's affecting the overall performance of the game? In which case, I'd be surprised because I'd have thought pretty much any piece of hardware you might be talking about should have plenty of CPU threads to spare and you probably needn't worry too much about it. I don't think we could tell you how much sleeping would be necessary to free up enough CPU resources for your title without knowing anything about the engine or even the target hardware.

This topic is closed to new replies.

Advertisement