Moreover, I find it amusing that you talk about 'refactoring' and 'poor algorithms' while you have never seen the sources and have no idea what algorithms does Toady use. You cannot provide ANY kind of estimates on worthiness of your 'refactoring' w/out analyzing sources first
One can make an educated guess based on the organic way that DF has grown, current performance, and past bugs and refactor efforts. That guess is that the internals of DF are understandably a friggin mess.
If you were a real programmer, you could take steps to answer these questions.
Or maybe I'm someone with a real job who doesn't have time to muck about with DFhack and just comes here during compiles. Who knows...
Ya, but you're having the discussion with people who think it takes a nanosecond to start or dispatch a thread. In their world, four threads will run something four times as fast as one thread.
Nanosecond
S in the plural. As in 700-950 of them. And I've yet to hear from you an actual argument as to why exactly it takes longer than that to do a kernel mode transition and have the scheduler set a flag.
And I never said that 4 cores would run anywhere close to 4 times faster. There are significant overheads to contend with. The cost of context switching, cache hits, and competing with the other ~400 threads windows is running at any given time all mean you're never going to see performance increase linearly with core count. But all of those costs (and they are big costs) I just mentioned are paid by those additional cores, not the one running DF that took <1 microsecond to lift a wait.
The fact remains that there would never be any performance gains from threaded pathfinding. There isn't a (established) pathfinding algorithm more expensive than a windows or linux thread.
Ignoring for the moment that that statement is completely pointless since you have not defined the set of pathing data or heuristic...
First of all I don't believe that, there are a lot of games out there that have multithreaded pathfinding. Do you really think they all implemented it without ever benchmarking to see if it was faster? But even if it were true in the case of DF I don't care. The issue here is not total work to be done (and I have no illusions, threading creates additional total work) but rather work that needs to be done by the main thread. It's perfectly fine even if we double our total workload for pathfinding once costs are factored in but are running them across 3 cores. It's still a net gain. Not to mention you can batch all the requests for each frame up and only make 1 thread per free core. If there are not that many path requests and/or they're as cheap as you say then why do we care about pathing as a performance issue at all?
There is nothing useful for him to read in this thread.
On the contrary, if you read the latest podcast transcript he pretty much implies that he's not all that up on threading. I'll say it again, Toady is not an infallible programming god, he's just a man with a disturbing level of obsession for simulating dwarves. Which I appreciate very much, but do not deify him for.