I don't see your refillable item lockup case; refillable items only get more full; it might branch out a bit finding the cheapest cost, but at worst it's just a large number of paths that all have endpoints. Caching the cost at each recipe would also help a lot in these cases (and calculating the set before hand implicitly does that).
The idea is that iterating over a potentially vast number of recipes (such as the ones RP2 adds for block manipulations) may be excessively time consuming.
Scanning all the recipes only has to take action on minecrafts startup or if you enter a world/start a server.
Also there are not that much recipes in minecraft, even not with RedPower 2 + (BTW + BC2 + other mods), so the runtime for that script should be rather short. (below one second)
It's less a performance issue than a balance and programming issue, because:
there are other problems.
how do you prevent endless loops in this script.
something like 9 copper -> copper block -> 9 copper -> copper block
if you do that often enough your MC crashes/freezes -> Stack overflow
A common problem in recursive algorithms.
also, there are variable EU costs in smelting, for example. (induction furnace)
so which one to use?
the lowest?
but an I-Furnace needs EU's to heat up and you can't calculate them by just following recipe trees.
The only way to solve this would be to add a multiplier, which adds about 10% to the final cost.
This would also balance the machine, since it's very overpowered to just bypass all construction effort you actually put in said items.
Using a reference item, btw, should be better. Every machine needs at least a "blueprint". A dropdown list sounds kinda OP, too.
That would balance it even more.
That's it with my brainjuice...