increase select/poll timeout granularity on linux

Marc Lehmann schmorp at schmorp.de
Thu Sep 24 05:06:51 CEST 2009


On Wed, Sep 23, 2009 at 09:00:51PM +0200, Bas Denissen <b.denissen at triple-it.nl> wrote:
> Does anyone on this mailinglist know how to increase the select and/or  
> poll timeout granularity on a linux system? It seems on all the linux  
> boxes I have access to, to be 4 msec. Below is my small test program to  
> test the granularity.

Increase your HZ.

> It probably has something to do with the HZ* settings of the linux  
> kernel, but as far as I can see the standard fedora 11 kernel, which has  
> HZ set to 1000, also has the 4 msec granularity...

It most likely has HZ=250 or something like that, or is a tickless system
with interesting effects.

On my kernel (with HZ=1000), I get 500 from your test program.

Note that AnyEvent cannot give you better accuracy than the underlying
event loop, some of which are limited to 0.01s granularity (and the perl
backend adds almost 1ms to every timeout on typical linux systems).

In general, you should not expect better than 2-4ms, even with event loops
that do not artificially limit the resolution.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      pcg at goof.com
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list