[asterisk-dev] [Code Review] Use kqueue(2) to reduce CPU consumption in *BSD and Mac OS X

Sean Bright sean.bright at gmail.com
Mon Mar 29 16:49:32 CDT 2010


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/543/#review1774
-----------------------------------------------------------


On OpenBSD 4.6:

gcc -o res_timing_kqueue.o -c res_timing_kqueue.c -MD -MT res_timing_kqueue.o -MF .res_timing_kqueue.o.d -MP -pthread -I/home/sean/devel/asterisk/jmls/include   -I/usr/local/include/libxml2 -I/usr/local/include -pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -g3 -Werror -Wunused  -D_FORTIFY_SOURCE=2 -Wundef  -Wmissing-format-attribute -Wformat=2 -isystem /usr/local/include -march=i386 -pthread -ftrampolines  -O6 -fPIC -DAST_MODULE=\"res_timing_kqueue\"   
res_timing_kqueue.c: In function `kqueue_set_nsecs':
res_timing_kqueue.c:160: error: `NOTE_NSECONDS' undeclared (first use in this function)
res_timing_kqueue.c:160: error: (Each undeclared identifier is reported only once
res_timing_kqueue.c:160: error: for each function it appears in.)
res_timing_kqueue.c:160: error: `NOTE_USECONDS' undeclared (first use in this function)
gmake[1]: *** [res_timing_kqueue.o] Error 1

- Sean


On 2010-03-29 16:19:58, Tilghman Lesher wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/543/
> -----------------------------------------------------------
> 
> (Updated 2010-03-29 16:19:58)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> Currently, we use inotify(2), which is a Linux-only kernel API, to check as to whether timezone files have changed, which allows an admin to change the machine timezone on the fly, and we will reparse it.  The alternative currently is for us to sit in what is essentially a busy loop, checking whether a timezone file is changed.  For most situations, these files change very seldom, so this represents quite a bit of CPU consumption over the life of a process.
> 
> The BSDs (and Mac OS X) contain a similar interface, called kqueue(2).  This has been implemented for timezone files, which should conserve CPU usage while running Asterisk on those platforms.
> 
> 
> Diffs
> -----
> 
>   /trunk/Makefile 255321 
>   /trunk/build_tools/menuselect-deps.in 255321 
>   /trunk/configure UNKNOWN 
>   /trunk/configure.ac 255321 
>   /trunk/include/asterisk/autoconfig.h.in 255321 
>   /trunk/main/stdtime/localtime.c 255321 
>   /trunk/pbx/pbx_spool.c 255321 
>   /trunk/res/res_timing_kqueue.c PRE-CREATION 
>   /trunk/tests/test_time.c 255321 
> 
> Diff: https://reviewboard.asterisk.org/r/543/diff
> 
> 
> Testing
> -------
> 
> Now works on Mac OS X 10.6.2.  Succeeds against unit test!!!
> 
> 
> Thanks,
> 
> Tilghman
> 
>




More information about the asterisk-dev mailing list