Source 2 & Multicore Support

How well does Source 2 use multiple CPU cores? For me, GMOD feels like it always only uses one core for literally everything, which at least makes coding stuff easier.
Now with CPUs that actually have 128 logical cores, servers could extremely benefit from physics and entity logic being handled in seperate threads.
Is this even possible and does Source 2 already do that and with what extent?



1 Like

Like Source 1, a bunch of processes are spread over multicore. But you’re only going to get all your cores being used it if has to do a lot of those.

For example, if the animation/bone system is multithreaded, that means that it’s going to take each model and split them into stacks for each worker thread to work through. If you only have one animated model in your scene it isn’t really gonna be of any benefit.


The great thing about multithreading in S&Box though is that we can use C# threads to run proper async/parallel tasks in addon code. This will actually take advantage of multiple cores, unlike Lua coroutines.


Re: Physics

Modern physics engines such as PhysX automatically split the game world into “islands”, which are groups of entities that might/might not interact on a given frame. Entities in different islands are basically guaranteed to not interact at all. The physics engine then processes each island on a separate thread.

In S&Box, this would require explicit support from Rubikon, though, and I believe very little information is known about it.

Re: Entities

Likewise, modern engines employ what is called an ECS to drive most of the core engine logic. You can look up what it is in more detail, but the gist of it is that it’s an architecture that enables a lot of logic/data/entities to be processed in parallel, independently, and/or concurrently, as well as taking advantage of modern superscalar CPU architectures and caching. I’d be surprised if Source 2 doesn’t employ it in at least some capacity.

Re: rendering

Pretty sure Source 2 has been using multithreaded rendering for ages (i.e. in Dota2 etc.), so that should be improved too.

And like @tripperful mentioned, we’re also going to have threads in the scripting layer, so this shouldn’t be as much of an issue as it used to be in GMod.