event scheduler: update the heap implementation
At the moment, we use old binary heap from libucw to implement priority queue in the event scheduler (evsched.c
).
Rescheduling a single event means searching for the event, removing it, updating it's time, and reinserting the event into the heap. Search is O(n), insertion is O(log n). This is expensive if we have a large amount of zones.
The newer version of libucw adds increase/decrease operation with O(log n). That's exactly what we need for rescheduling.
When we are at this, we can also simplify the event execution code. At the moment, there is some magic with evsched_begin_process() and evsched_end_process() going on. I think this was legitimate some time ago, but since we execute all scheduled events through the background workers, we can make this a bit simpler.