Jump to content

Multi-thread Performance improvements


Recommended Posts

25 minutes ago, Yobbo said:

Intel® Core™ i7-8700 CPU @ 3.20GHz × 12

I don't have any saves that really push it, but every time i've checked it the load seems pretty evenly distributed. The exception being save/load which only uses one core.

but does game cpu jump to 100%? i never was able hit game the 100% with cpu. it always sits somewhere 50%. and that's where fps starts drop for me

Link to comment
Share on other sites

38 minutes ago, gabberworld said:

but does game cpu jump to 100%? i never was able hit game the 100% with cpu. it always sits somewhere 50%. and that's where fps starts drop for me

That implies you're not limited by CPU but rather by something else. From the recent benchmark thread RAM speed was actually found to be quite important, so it could likely be hitting a limit there.

Link to comment
Share on other sites

2 hours ago, Yobbo said:

That implies you're not limited by CPU but rather by something else. From the recent benchmark thread RAM speed was actually found to be quite important, so it could likely be hitting a limit there.

thing is. i can program app what can use 100% cpu. i not tested yet the memory vs cpu tho. but i suspect game self have some other issues

yeah atm it seems like its the memory, i managed make exactly 50% cpu usage with my multi-thread test app

by calculation its correct as my memory is 2x slower than cpu

Link to comment
Share on other sites

6 hours ago, yoakenashi said:

My potato of a computer still runs ONI at 69 threads. So I don’t understand why players say it is only single threaded:

No it only spawns but not runs them all. I already posted threads list with detalisation some time ago. I have 6 cores, 6 threads CPU, so maximum one thread can use is 16.66%. Main thread uses almost 100% of 1 core. Two threads from SimDLL together can't even use a half. Others are Unity threads that mostly sleep in background.

proc.thumb.png.ff15676c3f5b8232a3fc826937fca332.png

A technically correct statements would be:
1. There are 3 threads that execute code with game logic.
2. The performance of the game is limited by the performance of the single main thread.
But they are long and nerdy.

Link to comment
Share on other sites

Shorter: The game uses 1,5 cores :lol: ...plus minus 3 gassy moo steaks :confused:

BTW digging with 77 dupes is fun ! My record lays at 500 natural born, fed and alive dupes in the first colony...hope I someday can break my record in survival mode. :afro:

image.thumb.png.4a6831e3d63e67f2f71ccae2a8a65167.png < Half the crew at this digging site

image.thumb.png.ca6cb72a7fe95807447a5a27d6dce4f9.pngimage.thumb.png.10f338e8949acb4343a5732861b11d79.pngimage.thumb.png.dda80de109d0212e821727d0dce470d1.pngimage.thumb.png.f0ad7bdee69cbea9aa4e1ac67aa3a4a3.png < Building gas freezer box

Link to comment
Share on other sites

9 hours ago, SVV said:

Main thread uses almost 100% of 1 core.

I do not see this on my computer. Each of my 4 core are equally utilized; therefore no one thread is maxing out a single core.

Perhaps there are others or other OSes that do not properly distribute the thread load, but mine does.

Link to comment
Share on other sites

30 minutes ago, yoakenashi said:

I do not see this on my computer. Each of my 4 core are equally utilized; therefore no one thread is maxing out a single core.

Perhaps there are others or other OSes that do not properly distribute the thread load, but mine does.

amd

they take years for adding similar multi-thread support like intel invented long time ago

Link to comment
Share on other sites

41 minutes ago, yoakenashi said:

I do not see this on my computer. Each of my 4 core are equally utilized; therefore no one thread is maxing out a single core.

Perhaps there are others or other OSes that do not properly distribute the thread load, but mine does.

What you are seeing is a misleading OS scheduling for threads. It's actually a bit worse then thread maxing a core - it also adds penalty for core switches to the mix. That one thread is still a deciding factor of game performance it's just moved around different cores.

Link to comment
Share on other sites

Yes, the game spawns almost 100 threads. It doesn't matter, because they probably come from unity engine itself. The problem is the main thread occupy 100% of core. The other ones just wait - no impact on CPU. It's actually another signal of bad design as there is really no point of creating more threads than you have cores. If you have 8 cores, 8 threads is enough as each can utilize 100% of that core. You can double this number if you have some troubles with waiting on io, and you are not able to fix it in reasonable time... but having almost 100 that just wait means scheduler needs to switch between them and that hurts performance.

Link to comment
Share on other sites

I have over 20 threads executing in a significant way. At least 12 of them are worker threads doing meaningful computation.

top_s.thumb.jpg.11f6500d7d898704e33c8e25ab299740.jpg

The main thread is using about 1/3 of the total. But much of it, including i expect all of the core simulation code, is clearly already multithreaded.

Link to comment
Share on other sites

3 hours ago, Yobbo said:

I just posted a snapshot of the game running on my OS, clearly performing the majority of its work in worker threads scaled to match the number of cores i have. It is already multithreaded.

Again, so what if you have 100 threads if majority of the job is done just by one thread? Your snapshot clearly shows what we all experience - only one thread is saturating the core, the rest just do nothing.

Link to comment
Share on other sites

The majority, approximately 66% by my testing, of the work was done in threads.

If i compare to another game, factorio, which i think you'd be hard pressed to call unoptimized, i also find 30% of it's work is done in the main thread.

I'm a bit tired of people complaining that this game needs to be made multithreaded when it clearly already is.

Link to comment
Share on other sites

Side note: New top notch cpu`s at around ~3GHz, with a zillion cores ( some maybe virtual and others real ), make up for their low base clock speed with their fat, large l1/2/3 caches running the game.

ONI tip: Aim for the latest cpu with the highest permanent base clock, at ~5GHz and with the least core amount, with the fattest cpu caches and nice possible boost clock speed peak on top :bee:

@cpy that awesome music piece should play on the ONI dancefloor, with all dupes hopping around like nuts :lol:

Link to comment
Share on other sites

On 10/23/2021 at 7:01 PM, yoakenashi said:

I do not see this on my computer. Each of my 4 core are equally utilized; therefore no one thread is maxing out a single core.

Perhaps there are others or other OSes that do not properly distribute the thread load, but mine does.

This is not the only  "proper" distribution of thread load. In fact, depending on workload and other conditions, putting all on one core can be better or putting it on several can be better. It really depends on the situation.

Link to comment
Share on other sites

7 hours ago, Yobbo said:

I'm a bit tired of people complaining that this game needs to be made multithreaded when it clearly already is.

Yobbo, this isn't something to be upset about. Stop nit-picking that the game is technically multi-threaded. The original topic of this thread is "multi-thread improvements", not "there's no multi-thread, please add it".

The simple fact is that if your game is chugging, and you're not reaching close to 100% cpu usage, then there's room for improvement. There are MANY opportunities for parallel operations in this game.

Link to comment
Share on other sites

11 hours ago, Yobbo said:

The majority, approximately 66% by my testing, of the work was done in threads.

If i compare to another game, factorio, which i think you'd be hard pressed to call unoptimized, i also find 30% of it's work is done in the main thread.

I'm a bit tired of people complaining that this game needs to be made multithreaded when it clearly already is.

Can you grab the save from benchmarking thread, run it at 3x speed and grab the thread stats from that?
(It seems to me that most of those additional threads are doing... something but either getting thread locked to often or running things that sim/game loop is not relying much - if they are something that Unity runs because of something not really used by game they could be actually detrimental to overall performance.)

Link to comment
Share on other sites

14 hours ago, Orzelek said:

Can you grab the save from benchmarking thread, run it at 3x speed and grab the thread stats from that?
(It seems to me that most of those additional threads are doing... something but either getting thread locked to often or running things that sim/game loop is not relying much - if they are something that Unity runs because of something not really used by game they could be actually detrimental to overall performance.)

It fluctuates quite wildly when i run that, but it seems to pull the ratio down to about 40-45% in the main thread 55-60% in other threads. 3x speed messes with all kinds of stuff so i tested at 1x speed which already almost maxes out one of my cores with the main thread. The KWorker threads were doing about the same amount of work as in my save (a little less actually), so i'd guess they're doing the actual simulation. That shouldn't change much, as the size of the world is constant, and so as the colony increases in complexity, the proportion of work they do reduces. Similarly for the graphics thread, that won't change much.

I'm wildly guessing the Job.Worker threads are unity-related as they run all the time and don't seem to be doing much. The KWorker threads only run when a game is loaded, follow Klei naming practices, and combine to a decent load.

The distribution at 1x speed on that benchmark save on my machine is about:

  • 90-95% of a core in the main ONI thread
  • 30-40% of a core in 5 ONI sub-threads of rapidly decreasing importance
  • 10-80% of a core in a graphics thread, depending on how much i zoom out (20-25% for normal zoom)
  • 50-60% of a core in 12 KWorker threads (i have 12 logical cores so this is likely one thread per visible core)
  • 20-25% of a core in 12 Job.Worker threads (ditto)

This all combines to around 210% to 230% core utilization on my machine (2.1 to 2.3 cores).

It was hard to get an indicative snapshot but this one is pretty average. The "time" field won't be too accurate as several things were varying as i had this open.

top_benchmark.thumb.jpg.3191348840ae366e650bb6205f2b3a40.jpg

For a normal game i'd say the snapshot i posted before would be a more usual performance profile. That was using a 4-asteroid mid game colony.

 

19 hours ago, Engival said:

Yobbo, this isn't something to be upset about. Stop nit-picking that the game is technically multi-threaded. The original topic of this thread is "multi-thread improvements", not "there's no multi-thread, please add it".

The simple fact is that if your game is chugging, and you're not reaching close to 100% cpu usage, then there's room for improvement. There are MANY opportunities for parallel operations in this game.

I have nothing against what you say in the OP. I fully agree there is room for improvement with the game's performance, and as i originally mentioned i expect it will happen in due course. But i repeatedly see people here and on discord parroting that the game is single-threaded. Most of the statements in this thread are technically correct, but they still imply that the game is not meaningfully multi-threaded. My observations are that this is simply wrong. I don't think it's helpful at all for people to have this attitude because (a) it misleads people who do not know better, (b) it distracts from potentially useful performance suggestions, and (c) it likely causes anyone at Klei who actually reads it to ignore it. If i had already done a bunch of work multithreading something and i saw people complaining about how it wasn't multithreaded, i would probably not even bother reading what they have to say.

Link to comment
Share on other sites

5 hours ago, Yobbo said:

IIf i had already done a bunch of work multithreading something and i saw people complaining about how it wasn't multithreaded, i would probably not even bother reading what they have to say.

Yobbo, that's fair enough. I hope they're not just doing a surface level skim of the forums.

They obviously know what the state of their code is in, and nothing we're saying here should be some major revelation to them.

In the end, they're still running a business, and it comes down to time, money, and risk to do major architecture level optimizations. They could end up breaking a ton of things if they're not careful, or if it's not implemented correctly.

I WOULD like some communication from Klei regarding this though. Those factorio dev posts talking about all the different optimizations they did with belts, trains, and whatever else were really amazing reads, and pretty much cut off any speculation about what they're doing.

Link to comment
Share on other sites

I think Klei will try their best and, like in the past, take iterative steps to improve the games performance.

They don`t want their Steam ratings to have a big negative impact by perhaps breaking the game for the duration of 1 year and making it unplayable with big core adventures and undertakings, so perhaps 4 core support ( instead of 2  ) would be for a fresh Klei game development. If we are (un)lucky, then they will try to allocate more cores with DLC2 and break things for some time. :rolleyes:

There still will be players which have the min spec, 2 cores - So it always has to run "ok`ish" for those folks. I hope Klei will continue to work on the game for many years to come, its so much fun :p

However, if think with future DLC`s maybe coming along someday...long terms save files will be compromised anyway again, like in the past - Sadly. So if the game someday is perhaps broken again for "a short time"( dlc2 :confused: ), it would be great to break it even more at that point with wild core adventures, for a short time frame. At least that is how I would plan it as a studio producer. It may be that Klei is already working on DLC2/tech since a few months, but that`s just speculation from me. I do hope there will be more DLC`s.

Klei reads the forum...So a minimum specification increase to 4 cores ( Intel Hyperthreading: 2 real cores + 2 virtual fake ones ) and 4 core support/allocation with DLC2 would be superb. :indecisiveness::beguiled:

That would mean that the game description on sales platforms ( Steam etc. ) would need to state this new min spec on the product page for a possible DLC2.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...