[Dovecot] Dovecot waking every 50ms when doing nothing

Timo Sirainen tss at iki.fi
Sun Jun 3 18:36:24 EEST 2007


On Sun, 2007-06-03 at 18:27 +0300, Timo Sirainen wrote:
> ..Or maybe just fix the basic timeout_*() API. Add a new timeout_reset()
> call == timeout_remove() + timeout_add(original values) and then make
> the implementation be fast with hundreds of timeouts. The timeouts are
> currently kept in linked list, so that could be changed to red-black
> tree I guess (sorted by next execution time). Or is there a better data
> structure for this?

Continuing my monolog.. :)

There are only a few different idle timout values, so maybe the
idle_timeout_*() API is a good idea anyway. It allows the implementation
to be really fast and simple:

struct idle_timeout {
  struct idle_timeout *prev, *next;
  time_t next_run;
  void *context;
};

So a doubly linked list for each different timeout value. Adding a new
timeout or reseting existing one moves the struct to last in the list.
When timeout handler runs, it needs to check only the first ones in the
list and move them to last.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://dovecot.org/pipermail/dovecot/attachments/20070603/0b585af6/attachment.bin 


More information about the dovecot mailing list