Here's a breakdown of the key themes from the Hacker News discussion, with supporting quotes and attributions:
Job System Design & Optimization
The initial post discusses the limitations of a "Fork-Join" job system in game development and how replacing it with a queue-based system significantly improved throughput. The discussion highlights the importance of efficient resource management and avoiding spiky workloads.
- Inefficiency of Fork-Join: "The design of the job system decides how we are able to utilize it, and the old design (in use since Arma 2) worked, but it was quite primitive. It only allowed submitting jobs as one block, and there could only be one block active at a time. This means all jobs had to be submitted at once, after which we needed to wait for the jobs to be finished, before we could continue doing other things." (hinkley)
- Benefits of Queues and Throttling: "So I replaced it with a queue instead, that would have n tasks running all the time, instead of up to n and as few as 1. I ended up being able to tune it to about 75-80% of the original number with little problem." (hinkley)
- Avoiding Spiky Processes: "Spiky processes cause problems for both load-shedding and autoscaling schemes. And starting too many tasks at once causes memory pressure on your end, since most data processing tasks take more memory in the middle than at the beginning or the end. You are better off self-throttling your traffic so you make the memory load more sequential and you allow compensatory systems the time they need to adapt appropriately to your sudden peak of traffic." (hinkley)
Parallelism in AI/Scripting with Imperfect Knowledge
A significant portion of the discussion revolves around strategies for parallelizing AI and scripting in games, particularly dealing with shared state and potential conflicts. The main suggestion involves allowing actors to operate on copies of the game world, leading to imperfect knowledge and thus enabling parallelism.
- Parallelism through Local Copies: "If each actor makes a copy of the world for what they know, there's nothing preventing parallelism. This does imply quadratic memory, but you can just cap this - if there's a lot going on, it makes sense for an actor to lose track of some of it." (o11c)
- Managing Shared Resources: "If two scripts consume an item, decrement a variable (hit points, credits, count) then it’s not as simple as giving each script a copy of the world. You get double spending, duplicated items, etc." (Aurornis)
- Addressing Shared Resource Conflict (async requests): "The point of the copy is that they can't actually change anything outside of their local world. They can only send out an async request for global state to change, or send a request to be scheduled on the same executor." (o11c)
- Alternative: Frame N-1/N Model: "Another model may be that all actors read from frame N-1 and write to frame N. Then there's not many copies, just one." (dustbunny) Followed by, "Two, surely? The previous one still being used and the new one being written." (akrotkov) and, "1 copy + the original = 2 instances in memory." (Retric).
- Limitations of the Frame N-1/N Model: "That's fine if actors are not doing much (e.g. just pathfinding and shooting), but is likely to fall apart long before scripting becomes a thing, since there are a lot of tasks where different actors do want to mutate the same object." (o11c)
- AI Convergence as a Feature: "This is AI, having multiple actors plan to gather the same resource etc isn’t necessarily a flaw. It does however result in meaningful game design decisions getting tided up in how the game engine is designed." (Retric)
Complexity and Tradeoffs in Game Engine Design
The discussion emphasizes that game engine design involves making complex tradeoffs that can impact both gameplay and performance. The challenges of multithreading and managing shared state require careful consideration.
- Engine Design Influencing Game Design: "It does however result in meaningful game design decisions getting tided up in how the game engine is designed." (Retric)
- Micro-optimizations: "It's probably pretty insignificant from a players perspective in most contexts. And you could most certainly design some acceleration structures to specifically handle AI convergence specific to your use case." (dustbunny)
- Command-line parameters issues: ""From the feedback on Profiling branch we have seen several times that players had issues caused by setting wrong command-line parameters. That was typically because an old optimization guide told them it would make their game run better. But now that the game is more multithreaded than it used to be, bad settings have a more noticeable and potentially negative impact."" (egypturnash)
Nostalgia for Older Games
A brief comment expresses fondness for the game "Operation Flashpoint: Cold War Crisis".
- Nostalgia: "Ah good ol’ Operation Flashpoint: Cold War Crisis. What an absolute time to be alive." (absurdo)