Relationship between ncallout and callwheelsize

Hans Petter Selasky hps at selasky.org
Thu Jul 20 08:20:20 UTC 2017


On 07/20/17 08:59, Sebastian Huber wrote:
> Hello,
> 
> I noticed on a LPC4088 running at 96MHz from external SDRAM that the 
> callout_process() function needs a lot of time even if no callouts are 
> active. The reason is that on a 32-bit architecture with only 13 general 
> purpose registers this function needs a lot of load/store operations. So 
> I tried to reduce the complexity by using compile time constants. I 
> don't understand why the callwheelsize and the timeout(9) 
> pre-allocations are related:
> 
>      ncallout = imin(16 + maxproc + maxfiles, 18508);
>      TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
> 
>      /*
>       * Calculate callout wheel size, should be next power of two higher
>       * than 'ncallout'.
>       */
>      callwheelsize = 1 << fls(ncallout);
>      callwheelmask = callwheelsize - 1;
> 
> The size of the wheel should be related to typical timeout values to 
> balance memory size and hash collisions. Why is there a connection to 
> the timeout(9) pre-allocations?
> 

Hi,

The calloutwheel is simply an optimisation. If you don't need many 
callouts, maybe a per-CPU list will be enough for your purpose.

--HPS


More information about the freebsd-hackers mailing list