Jump to content
  • Advertisement
silikone

Low-latency, determinism, and multithreading

Recommended Posts

Usually, an engine has to strike a balance between these three factors, sacrificing at least one to maximize another.

I'm looking for some information on how various engines deal with each of these factors, helping one to make the right choice depending on the requirements of a game. For example, determinism is imperative for physics puzzle games, low-latency is in high demand for twitchy shooters, and multithreading suits large-scale simulations.

Share this post


Link to post
Share on other sites
Advertisement
19 minutes ago, Hodgman said:

There are situations where certain multi-threading approaches can introduce non-determinism, but all of those approaches are wrong. If you're multi-threading your game in such a way where your support for threading means that the game is no longer deterministic, then you're doing something terribly wrong and need to turn around and go back. I can't stress that one enough. There's no reason that multi-threaded gameplay code shouldn't behave exactly the same as a single-threaded version.

This is where one may or may not see latency introduced in order to stay deterministic. If you are smart about it, you could detach the game simulation from the player input and feedback. It is crucial that the mouse feels instant, but gunfire and animations don't have to be instant. Of course, for the best programmers, nothing beats having instant everything.

Share this post


Link to post
Share on other sites

Java can also make deterministic floating point operations, but it's not the case for C#. So in the .NET case you can make your own int-based fixed point math library with bitshifting wizardry and taylor series for functions like sines/cosines/etc (I don't know if there's a better way to approximate a function). Also, you could get also a bit more precision in exchange of range using something like this. 

Share this post


Link to post
Share on other sites

Deterministic gameplay depends also on the implementation of your engine. even if your engine runs multithreaded you might have such systems like Unity 3D that does not allow your gameplay code to be executed on different threads (without doing some management heavy synchronization tricks) while a good tested and maintained task/job system will help your gameplay code to speed up (depending on the complexity and dependencies) with splitting different sections into different tasks and spread them along your system so they could run in parallel. This gets performance and behaves deterministic but needs to be modified for different scenario.

Multithreading as @Hodgman mentioned is part of game development since the day as Unreal Engine 3 first releases (and I think also much earlier). Any AAA game engine these days supports multiple threads to run those massive titles these days. Sure a computer CPU runs on a lot faster tick but you do not have scheduling with other processes on a console platform so could exclusively use any except one thread (for PS4, I do not about XB1) for your game running without beeing scheduled into a wait queue. That lets make consoles "seem" fast ;)

Game development these days is more or less planning of what runs when where and how could wait locks be reduced depending on dependencies between different tasks/jobs and systems rather than the difference between being determinstic or performing. Sure floating point and double precision is another topic to be discussed about and I have had many bugs in my career (mostly related to AI) when floating point precision leads to minimal differences but in the end this could be also utilized to let an AI look more natural in behavior :D

Share this post


Link to post
Share on other sites

OpenCL/Cuda is mostly used to make physics computation faster for the drawback of consuming some GPU power. It has some advantage in heavy computing situations but a good designed and tested game loop (for example in a multithreaded task based environment) does the job as well without OpenCL/Cuda

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!