Relationship between ncallout and callwheelsize

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Jul 20 07:25:36 UTC 2017


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?

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the freebsd-hackers mailing list