1
DF Suggestions / A way to reduce job cancellation spam
« on: October 17, 2011, 01:01:49 am »
tl;dr version: Use exponential backoff with an (optional) maximum period.
Long version: This may be related to some of the listed development goals already (e.g. Req79 under Bug Fixes), but I can't be sure, so here we go.
DF has a problem with job cancellation spam. A lot of this is somewhat unavoidable, but not all of it. In particular: Have you ever sealed off an area, only to discover that there's a XXcave spider silk sockXX somewhere down in the depths that you haven't forbidden (and can't find), and now some dwarf tries to go get it a hundred times a day? I know I have. There are workarounds to this problem, but a solution would be better.
So, my suggestion is this: When an item is found to be inaccessible for some task or another, make the game wait a while before firing up A* to find it again (as, last I checked, it does in at least some cases). If it still can't be found next time, double the amount of time (and each subsequent time). This is called "exponential backoff." This will save both on cancellation spam and CPU time (as A* isn't exactly fast). Of course, some users might not want to have to wait a hundred years for their dwarves to reclaim their lost items once they work out what was wrong, so there should probably be a limit to how long they can have to wait before trying to find it again.
Of course, some jobs shouldn't have this quality, like dwarves searching for food.
Edit: A limitation of this approach: Two dwarves in separate rooms Urist and Burist, both trying to access an electrum bar. Urist can reach it, Burist cannot. If Burist's jobs are always processed first, the bar will never be used. It may be necessary to limit job queries per dwarf-item pair rather than per-item. This will increase the memory requirements, but last I checked these were not the limiting factor for most DF players anyway.
Long version: This may be related to some of the listed development goals already (e.g. Req79 under Bug Fixes), but I can't be sure, so here we go.
DF has a problem with job cancellation spam. A lot of this is somewhat unavoidable, but not all of it. In particular: Have you ever sealed off an area, only to discover that there's a XXcave spider silk sockXX somewhere down in the depths that you haven't forbidden (and can't find), and now some dwarf tries to go get it a hundred times a day? I know I have. There are workarounds to this problem, but a solution would be better.
So, my suggestion is this: When an item is found to be inaccessible for some task or another, make the game wait a while before firing up A* to find it again (as, last I checked, it does in at least some cases). If it still can't be found next time, double the amount of time (and each subsequent time). This is called "exponential backoff." This will save both on cancellation spam and CPU time (as A* isn't exactly fast). Of course, some users might not want to have to wait a hundred years for their dwarves to reclaim their lost items once they work out what was wrong, so there should probably be a limit to how long they can have to wait before trying to find it again.
Of course, some jobs shouldn't have this quality, like dwarves searching for food.
Edit: A limitation of this approach: Two dwarves in separate rooms Urist and Burist, both trying to access an electrum bar. Urist can reach it, Burist cannot. If Burist's jobs are always processed first, the bar will never be used. It may be necessary to limit job queries per dwarf-item pair rather than per-item. This will increase the memory requirements, but last I checked these were not the limiting factor for most DF players anyway.