If I have to guess, it is probably good for performance to (re-) use a single
queue. The conversion from bucket-based to heap-based comes at a cost, and also
for both queue types in general they have reallocation overheads that can be
amortized better if they are reused multiple times over a longer period. So
trying to reuse the same queue where possible is often a good idea. For example,
in heuristics like h^FF I think we got a substantial speed boost when we started
reusing the priority queue between different heuristic evaluations, even though
the queue is empty in between and in terms of code readability, making the queue
local to each heuristic evaluation would be cleaner.
Regarding Silvan's question in msg6544, I *think* that typically most of the
queues in the same planning task will end up behaving the same way, so only
having to decide once that bucket-based ones are a bad idea could be good for
performance. But it's hard to be sure without measuring.
Having said all that, I think that code clarity very likely suffers a lot in
cases like Silvan describes if we start reusing these queues because the callers
of the code suddently have to start worrying about an implementation detail. And
it's also a legitimate wish not to have the queue be as chatty as it currently
is. I'd be fine with disabling the output from AdaptiveQueue by default and
adding a compile-time debug flag (usually set to false) that enables the current
output.
Fancier solutions are possible, but probably fall under YAGNI.
|