All materials were on a different floor from the structure being built (since it was a road and I was digging underground).
The closest stones by pathfinding were, oh, 30 tiles away horizontally and down one level, but it was a nice straight walk.
The stones that got picked were about 0-4 tiles away horizontally and down four levels, but like I mentioned, HUGE switchbacks. It was a long and arduous walk. It was like being on the other side of the river, repeatedly.
I know it's computationally expensive, but I can think of a few potential improvements. For one thing...So there's 99 limestone stones lying around and your road needs eight of them. Okay. So start at the middle of your building (very short range inaccuracies may not be important, except for bridges), and search outwards from there. Keep going until you run into your first eight pieces of limestone, and then STOP. All limestone is the same and there's really no reason to choose which limestone to use, anyway. You only have to pathfind for whatever material the user has highlighted--you can abandon the data for any material they move off of, as long as changing the highlight stays snappy. Maybe for building doors and stuff where quality matters, you can figure out the closest ten right away, and only continue if the player actually expands that view. Just remember that when the user is pawing through a menu, you can take advantage of their slow reaction time and crunch numbers!
It might really suck if your limestone is across the map, down three levels, around a corner, over the bridge, through the maze, and up the tower. Maybe have a cutoff after a certain amount of time spent, and give up. But for me as a player, it is extremely important to my play experience (heh) that my dwarves know how to pick some reasonably close ingredients. I think that waiting a second for computation time is better than waiting half an hour because my dwarves didn't plan very well.
Meh. This is just my favorite feature to improve. I absolutely LOVE the new simplified interface, and in a 2d world it would be perfect--but in 3d, it might actually perform worse than the old interface unless pathfinding (or a good heuristic!) goes in.
If it's just the delay to the player that you're worried about, I think it would make a great init variable: Number of milliseconds to spend pathing on ingredient selection. You could divide it by "ms to spend when a mason is doing his own thing at a workshop" (a low number) and "ms to spend when the player is placing a building (a high number). You could have a little spinning bar on the build window that tells you it's still pathfinding, and let the player decide how long to wait. You could have a button that says "Do the math right now, for these ingredients". I just feel reeeally strongly about being able to trigger pathfinding on ingredients. It makes the difference between an attentive and responsive architect, and an architect that you want to punch in the face. I don't like to hate my dwarves.