nearly-tickless-tinc

Michael Tokarev mjt at tls.msk.ru
Sun May 29 19:59:47 CEST 2011


29.05.2011 21:43, Loïc Grenié wrote:
>     Hi,
> 
>     tinc has a fixed timeout of 1 second for select() in the main
>   loop. I think this could be improved. Do you think the following
>   patch goes into the right direction ?

First of all, there's another branch, tinc-1.1, which reworks whole
event model of tinc to use other, more efficient mechanisms.

>      I don't know whether pselect() is standard enough (works under
>   "current" linux, however I don't know about the other arches). Maybe
>   a config option is necessary.
> 
>      It's probably possible to simplify at least signal handling (I've
>   tried to keep SIGHUP and SIGALRM blocking as they are,
>   however I suspect that tincd unblocks those signals at the
>   beginning or, at least, does not modify their blocking while
>   running). It is also undoubtedly possible to improve the patch
>   in other ways.

Usual trick in such cases is to use selfpipe - create a pipe(2),
add its read end to the select list, and write a byte to the write
end of it in the signal handler, to make select() to notice it.

But your version is not an improvement.  You eliminate a every-second
wakeup during idle, but you add quite several extra system calls into
the critical path around select() call.  In other words, you optimize
idle loop by making real stuff less efficient.

The selfpipe trick may help here to get things back for sure.

But I'm not really convinced this is the right course - instead,
the 1.1 branch should be made live.  In my opinion anyway.

/mjt


More information about the tinc-devel mailing list