On Tue, May 20, 2014 at 11:09:54AM +0400, Nick Zavaritsky <mej...@gmail.com> 
wrote:
> My program is repeatedly toggling an io watcher from R to RW mode and back.
> This may happen multiple times per one event loop iteration. This toggling 
> behavior
> is caused because of me attempting to buffer a few data items before flush but
> certain conditions may force an early flush. Before blocking the remaining 
> data
> is flushed, at least partially (in ev_prepare).
> 
> Since exchanged data items are quite small I assume flush will succeed and
> there would seldom be a need to watch the underlying file descriptor to become
> ready for write, i.e. the io watcher mode switching pattern bounded by the 
> single
> event loop iteration is R-(RW-R)*-RW-R.
> 
> Please tell me if this 'redundant' mode switching comes with a cost?

Well, obviously, you need to call a function or macro every time you toggle
the flags.

Apart from that, it doesn't matter whether you toggle once or many times per
event loop iteration - when libev polls for new events, it will tell the
backend about them.

For select and poll, the overhead is trivial, for kqueue and epoll, its
nontrivial and even partially depends on outside events. In the worst
case, it is one extra syscall per fd with epoll, in the best case, the
overhead is trivial with epoll.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schm...@schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

_______________________________________________
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to