How many multiple paths are we talking about? You haven't broken down the problem.
Doesn't matter. Assuming you make path finding (or any other threading call for that matter) truly asynchronous and the overhead of kicking off your pool thread is less than the work it's doing then you've saved work for the main thread.
Only a small percentage of your dwarfs are path-finding during a single given point of time.
Agreed, but who cares? As I said if even one dwarf needs to pathfind then that's a potential savings for the main thread.
Even in the worst case scenario, with 400 creatures needing to path.. there will be no performance gain from threading unless your path function is incredibly slow.
How do you figure that? Are you assuming we block until the pathing threads are complete or something. Path results are requested from an asynchronous thread, near the beginning of the main loop, if they're ready then great we use them near the end. If not then they're acted on in the next frame. The next frame which comes faster than it would if it was synchronously calcing paths.
Why would you spend time threading the function (making the game slower for people on a single core) when you could just make the function faster?
I never said it shouldn't be optimized. Assuming that can be done reasonably and while maintaining code flexibility then great do that too. As for single cores you can largely call something like pathfinding synchronously if desired as decided by an init flag. And let's be honest single cores are going away, is there any one even still selling them these days.
Now having said all that, threading is hard.
No
I don't think I've ever had an initial threading plan actually work
Sorry
Hey, if threading is that easy for you then congrats. Maybe I'm just old and grew up in a single threaded world. On the other hand you sound like someone still in school who finds the dinky little threading exercises they give you to teach concepts too easy.
Most of my threading implementations get redesigned because half way through the client suddenly remembers that oh yeah there's this thing we forgot to tell you that completely changes how that's going to work. Or they work great for what they're designed to do but the locking scheme is totally incompatible with the new feature we're adding 6 weeks from now.
Threading a realtime large scale app in the real world is hard. And if you don't believe that then you haven't had to do it yet.
Until you have sat down and spent a few hours running IDA again DF(or you're Toady and have the actual code), you can't really say you understand much about DF. It annoys me when people who are probably not as good at programming as Toady, try to tell him how to program.
I have absolutely zero concrete knowledge of how the DF internals work. Only a reasonable extrapolation of how they could in theory work. And based on that I gave a hypothetical example of how I'd do it after 2 minutes of halfhearted pondering.
Toady is not some sort of programming god. He's a absurdly motivated programmer and there are a hell of a lot of things in DF that are done right. But there are also a hell of a lot of things done wrong. And he probably knows the vast majority of those things and shakes his head when he thinks of how foolish he was back when he wrote them (you show me a programmer that doesn't do that and I'll show you a crappy programmer). Even assuming for the moment that he is a better programmer than me is that any reason not to offer suggestions or feedback? I don't think so and if that annoys you then... Oh well, deal with it.
And I still maintain that threading is a net gain for any given task if (number of concurrent tasks * thread execution time) > ((overall threading maintenance * main loop executions) + (thread spawn time * number of concurrent tasks)). Until you can refute that statement or explain how it does not hold true for pathfinding in DF then you've got no case as far as I can tell.