7 ms·
Jonathan Blow warns against threaded queues in game development, as normally simulating your world isn't the bottleneck (rendering is) and it will just cause a
by SQueeeeeL 6y ago
Jonathan Blow warns against threaded queues in game development, as normally simulating your world isn't the bottleneck (rendering is) and it will just cause a fair bit of unexpected behavior/debugging
- Thaxll 6y agoIndeed, lot of games are actually single threaded.
- dkersten 6y agoIn recent years there has been a trend shift away from this, at least in the AAA engines, towards a job system. This makes sense: you have a thread per core and you create jobs to “go wide” when you can. See for example Unity’s Job system it’s the GDC talk by Naughty Dog from a few years ago. The big games will also prepare data for rendering in parallel (eg culling and sorting and whatnot, although much if this is also done on the GPU). (Going by GDC talks, the rendering teardown articles and just what I see online from Unity/Unreal. I don’t work in games myself)
- asdfasgasdgasdg 6y agoWhich makes total sense because single thread performance is growing more slowly these days. Used to be you'd double every couple of years but today the midrange is only about 50% faster single threaded than it was in '16. Now if you count all the cores you're still seeing things more than double over that time. Compare these similarly priced CPUs from today and a few years ago: i5-6500 and i5-10500. The latter is maybe 30-40% faster single threaded but has more than double the parallel throughput.
- Thaxll 6y agoIt's true but lot of the main area don't multi-thread well like AI and physics.
- asdfasgasdgasdg 6y agoI don't know why AI shouldn't thread well, assuming there is more than one actor. As long as they are operating over an immutable view of the game state, each actor should be able to plan independently and enter its commands independently. Likewise, there are probably some tricks you can do with physics. And anyway in most games interactive physics is only done for a few objects in the game world, and those objects are often not interacting with each other, at least not physically. You could cluster the objects that can affect each other and then do each of them single-threaded.
- corysama 6y ago> As long as they are operating over an immutable view of the game state That's a big issue. There is a surprising amount of back and forth between objects in a single step of gameplay/AI. And, generally gameplay code tends to be a big mess of wild and ever-changing requirements from gameplay designers, extreme time crunch and short term (1 game then burn it) goals. Ivory tower software architecture it is not... Clustering physics into "islands" is common practice though.
- asdfasgasdgasdg 6y agoI'm not a game dev but I do know how software can become a mess. I think engines that are used by many games have a chance to push good practices here.
- gameswithgo 6y agoI mean, not entirely, though the game logic often will be. But usually there is a fair bit of threading going on, and things that are threaded in the engine, or graphics card driver.
- cridenour 6y agoI wish X4 would go this route though, as it is entirely bottle necked by simulation speed.
- SQueeeeeL 6y agoI imagine execution order/consistency is very valuable for 4X games, and most of the time, results are dependent on each other (who wins a battle may depend on the current status of an empire, which is dependent on the outcome of various planet level actions, for example). It'd probably be a very different game to have each action be stateless, could be a cool exercise though
- R0b0t1 6y ago>as normally simulating your world isn't the bottleneck Dwarf Fortress has entered the chat
- zemo 6y agostatements like this really need to be put into context. Maybe that's true for his games, but it's not necessarily true for all games. His latest game, The Witness, is a first-person puzzle game with zero non-player characters, no kinematics, and a variety of puzzles based around light and rendering. He designs games that don't have much to simulate and do have complicated rendering situations. Meanwhile, Doom Eternal has no main or render thread at all, and instead uses a massively parallel jobs system. https://www.dsogaming.com/news/doom-eternal-does-not-have-a-main-or-render-thread-anti-aliasing-uses-up-to-32-temporal-subsamples/ https://www.dsogaming.com/news/doom-eternal-does-not-have-a-...
- SQueeeeeL 6y agoI think the majority of game devs who would get advice from lectures/hacker news comments are probably making games on a small enough scope/scale that choosing a single threaded game logic engine is fairly reasonable. The people at Bethesda are the best of the best; this kind of reminds me of the fitness "advice" I was once given to not go on long jogs/runs because "all the best marathon runners are super skinny", but that only applies to world class marathoners, not dudes running a 5k on the weekend.
- zemo 6y agopeople who work in games also read HN you know.
- MaulingMonkey 6y agoAnd said AAA devs aren't "ubermensch". They run a large gamut of specialties and skillsets - plenty of them will benefit from extra context. And some of those small scale hobby/indie devs may later end up working for "the big leagues" as well, so the extra context can benefit them too.
- SQueeeeeL 6y agotbf I said take advice from HN. I except people deeply involved in games to have their own specialized info us mortals can't touch (or they just do their own testing)
- corysama 6y agoI'd appreciate a link so I could hear his whole argument. You can argue about when it is appropriate to use threads at all. But, if I'm going to use threads, I use a threaded queue for communication exclusively.
- TwoBit 6y agoSim games (eg SimCity, Sims) could spend more time on sim than graphics.
- winrid 6y agoIn some cases you have to. I'm working on a game and absolutely need separate threads for animation, rendering, and constructing meshes (it's kind of procedural - is part 3d map renderer).