Jump to content

What does it mean to "Pump the sim once"?


LHACK4142

Recommended Posts

3 hours ago, LHACK4142 said:

Looking at gameplay, it seems like a good part of the loading time is spent "pumping the sim once". I wonder what could this mean?

@K^2

If this is jargon, I'm not recognizing it. The only things that come to mind is having to pump the primer on some older internal combustion engines. This might be just a joke that the simulation has to be started like an old motorcycle.

Link to comment
Share on other sites

4 hours ago, K^2 said:

If this is jargon, I'm not recognizing it. The only things that come to mind is having to pump the primer on some older internal combustion engines. This might be just a joke that the simulation has to be started like an old motorcycle.

I’d guess it has something to do with data marshaling and getting things preloaded into cache. There was a company I used to work for that had an entire thread dedicated to just walks trees/arrays and loading pointers to keep data in cache before the main loops (yes, plural… there were a lot of threads) started processing things.

I don’t recall the details, but it was absolutely essential to get performance where they needed it. (I kept meaning to ask our contacts at Intel why they didn’t add cache management instructions so that we wouldn’t have to play games with the CPU to get it to guess correctly, but never got around to it.)

Link to comment
Share on other sites

37 minutes ago, TheOtherDave said:

I kept meaning to ask our contacts at Intel why they didn’t add cache management instructions so that we wouldn’t have to play games with the CPU to get it to guess correctly, but never got around to it.

They have. SSE/AVX instruction sets include prefetch and stream instructions. Prefetch instructions let you force a cache fetch for a specific address without stalling the pipeline until the fetch is complete (unlike the mov instructions), and the stream instructions let you save contents of an MMX register to memory without hitting the cache. That is, if the address you're writing to isn't in cache, it's not going to be added to cache. Very useful for when you know you're not going to be touching the memory for a while. I've made heavy use of these while working on animation systems in two different studios. Great stuff.

You do have to be careful with these, though. It's very easy to over-engineer this approach and start fighting genuine use of LRU in the cache, causing performance problems elsewhere. Most of the time, you just want to let the cache do its thing.

Link to comment
Share on other sites

The game won't be using the loading screen to prepare the CPU Cache, it'll be all about loading things from your drive, processing them and putting the processed data into RAM and GPU memory. 

Of course, the CPU cache will get used while processing said data, but the idea that'd you specifically load things already into the CPU cache for gameplay while just loading the game is a bit far fetched. If they mostly stick with Unity C# for their code I doubt they are doing low-level cache optimization anyway. But maybe the have some external libraries where they do, e.g. for the orbital mechanics.

Link to comment
Share on other sites

On 2/22/2023 at 12:42 AM, K^2 said:

They have. SSE/AVX instruction sets include prefetch and stream instructions. Prefetch instructions let you force a cache fetch for a specific address without stalling the pipeline until the fetch is complete (unlike the mov instructions), and the stream instructions let you save contents of an MMX register to memory without hitting the cache. That is, if the address you're writing to isn't in cache, it's not going to be added to cache. Very useful for when you know you're not going to be touching the memory for a while. I've made heavy use of these while working on animation systems in two different studios. Great stuff.

You do have to be careful with these, though. It's very easy to over-engineer this approach and start fighting genuine use of LRU in the cache, causing performance problems elsewhere. Most of the time, you just want to let the cache do its thing.

I don't think we were necessarily using a lot of AVX instructions, but I never saw the internals of the code. I remember my boss wanting to use Intel's compilers for better auto-vectorization, though, so maybe it was something they were in the process of switching to?

Link to comment
Share on other sites

×
×
  • Create New...