Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: What about more of that multithreading?  (Read 776 times)

slowpersun

  • Bay Watcher
    • View Profile
What about more of that multithreading?
« on: April 22, 2025, 08:53:54 pm »

So the game already contains at least some multithreading, between blog posts, videos, and older threads like this (threading came up while discussing pathfinding):

It won't. Pathfinding is not a major contributor to FPS issues. Sorry, people have just been wrong about this the whole time. You can get an FPS boost from fixing up pathfinding a bit--6% is 6%, reducing that helps!--but FPS death will set in just as it does now, even with magic oracle pathfinding that takes 0 time. It's not a pathfinding issue.

If I seem bothered by this, it's because I pondered the pathfinding a good deal too before I actually bothered to do the bare minimum work in actually figuring out why the game runs slowly and learned that, no, pathfinding has basically nothing to do with it. I literally had to be handed a save that had a pathfinding edge case (24 tightly-closed doors) before I even found the pathfinding function, since it's buried so deep due to its, again, not being a major use of CPU time.

Anyhow, the above quote is still slightly under 2.5 years old, so I can assume that there is no less multi-threading in the game now, although apparently it's not ALL related to pathfinding.  But has any threading been applied to temperature checks?  What about fluids (well, water basically) flowing?  For a game that simulates a surprising amount of physics, it's also equally surprising when certain parts of physics get skipped to reduce CPU load; ie, the game doesn't have a dew point, humidity doesn't really seem to exist (I guess steam just ceases to exist?).

I'm not expecting the game to ever allow hitting the triple point of water (or even steam power), but might be nice to finally use magma to heat water for bathing, maybe even a bath house.  Those were big in the Middle Ages!  Or even just Roman Empire, they so fancy there were three options!  Although the bath house kind of obsolete now, what with showers being invented.  Also curious also since siege update might also lead to more disease options (like, why can't that catapult throw corpses?), although that is less relevant here.
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: What about more of that multithreading?
« Reply #1 on: April 22, 2025, 11:18:54 pm »

I can't remember what all was multithreaded, but temperature was something that was added as part of the experimental multithreading options a while back.  I'm not sure if any of that was ever promoted from experimental status or not.  I seem to remember enabling the option had relatively little impact on the forts I tested in, like a few percent difference at most.  It would probably help a lot more if someone is pumping magma around though.
Logged
Through pain, I find wisdom.

slowpersun

  • Bay Watcher
    • View Profile
Re: What about more of that multithreading?
« Reply #2 on: April 22, 2025, 11:40:48 pm »

I can't remember what all was multithreaded, but temperature was something that was added as part of the experimental multithreading options a while back.  I'm not sure if any of that was ever promoted from experimental status or not.  I seem to remember enabling the option had relatively little impact on the forts I tested in, like a few percent difference at most.
From what I understand (at least off the wiki) is that the game just doesn't even bother to track water temperature except above ground anyways; put another way, water doesn't ever freeze underground that I'm aware of.  I'm assuming this is so in order to just obviate the need for a lot of extra CPU load, although there are other possible explanations.

So assuming threading is implemented for temperature, it probably wouldn't show much improvement... yet!  The problem is that it would be much improved for calculations that are being deliberately avoided, at least as far as I can tell.  Might have to start a separate thread regarding the avoidance of CPU load, but this kind of captures it anyways.

I guess I was just hoping for some sort of master list for what threading occurs when/where, and what can't/won't ever be threaded (either 'cuz not possible, or just not worth any effort currently).  Except for that one thread about pathfinding, all the multi-threading discussions are from like over 10 years ago and are pointless to necro.  But prolly faster to ask here than Steam forums.
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: What about more of that multithreading?
« Reply #3 on: April 23, 2025, 06:48:16 pm »

From what I understand (at least off the wiki) is that the game just doesn't even bother to track water temperature except above ground anyways; put another way, water doesn't ever freeze underground that I'm aware of.  I'm assuming this is so in order to just obviate the need for a lot of extra CPU load, although there are other possible explanations.

Tile temperatures are tracked everywhere, including underground, but only above-ground temperatures vary according to the weather - subterranean tiles always sit at a temperature of 10015 (47F/8.3C) unless they're adjacent to magma (in which case they jump to 10075, or 107F/41.7C) or a fire-based creature is walking nearby.

I guess I was just hoping for some sort of master list for what threading occurs when/where, and what can't/won't ever be threaded (either 'cuz not possible, or just not worth any effort currently).  Except for that one thread about pathfinding, all the multi-threading discussions are from like over 10 years ago and are pointless to necro.  But prolly faster to ask here than Steam forums.
Right now, the only thing that's multithreaded is certain unit updates, and it's my understanding that most of those are centered around line-of-sight/proximity checks which happen during combat and conversations.
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

slowpersun

  • Bay Watcher
    • View Profile
Re: What about more of that multithreading?
« Reply #4 on: April 23, 2025, 07:23:09 pm »

Tile temperatures are tracked everywhere, including underground, but only above-ground temperatures vary according to the weather - subterranean tiles always sit at a temperature of 10015 (47F/8.3C) unless they're adjacent to magma (in which case they jump to 10075, or 107F/41.7C) or a fire-based creature is walking nearby.
Was wondering about that part of temperature tracking, wiki is kind of unclear, thanks.  Makes sense for the weather not to affect anything deep underground (or even not that deep: https://en.wikipedia.org/wiki/Root_cellar), although also just more computationally efficient.  Does weather still calculate interior temperatures for above-ground structures?  Put another way, fortifications allow for the passage of water, what about temperature?

Could always be changed later with the underground map updates, could be interesting to have to deal with seasonal permafrost in cold biomes.  Or just magic being used to throw down ice walls or whatever.
Right now, the only thing that's multithreaded is certain unit updates, and it's my understanding that most of those are centered around line-of-sight/proximity checks which happen during combat and conversations.
Makes sense for threading implementation to be prioritized for whatever is necessary first (assuming threading is even possible as a solution).  Why I was hoping there was already a thread listing what threading where.

Is that only on experimental branch?  Hard to track when stuff gets pushed out of experimental, although LUA stuff prolly still in experimental right now.
Logged

slowpersun

  • Bay Watcher
    • View Profile
Re: What about more of that multithreading?
« Reply #5 on: April 28, 2025, 05:11:37 pm »

So the game already contains at least some multithreading, between blog posts, videos, and older threads:

So assuming threading is implemented for temperature, it probably wouldn't show much improvement... yet!

The following video confirms multi-threading HAS been applied to temperature, at least experimentally (unclear if has moved out of experimental or not, considering age of the video):

https://youtu.be/79J3X8ulER0?si=4_gktC-4qjgLQZqI&t=1175

I hadn't originally watched this video when I started this thread last week, hence why I am kind of answering my own question now... but also why I requested some sort of master multi-threading post to list what has or hasn't been threaded AND if threading is still in experimental or not, just for purposes of clarification.

I actually asked why the suggested history lengths got chopped back so hard for the steam release in the last FotF, Tarn said he thinks he did it because he thought it might improve performance
It is the primary goal of the game. The largest update the game has ever had, 0.40.01, was dedicated entirely to introducing this, and it's only expanded since. It's not all-encompassing, but to say it's not in the game at all is wrong.

If running the game world concurrently with fort mode is a game goal, why not continue running world events (ie, concurrent world gen) on a separate thread?  Seems like an obvious candidate for testing... not saying it will get implemented anytime soon, if ever, but seems worth testing at least!

The only reason I can think of why not to try this is that it would preclude any players/machines that lack multiple cores, rare thought that is these days.  So I guess some sort of game option to allow single core usage as some sort of legacy option might be necessary.
Logged