[rsyslog] high-performance, low-precision time API under linux?

david at lang.hm david at lang.hm
Mon Jun 15 19:01:01 CEST 2009


On Mon, 15 Jun 2009, Aaron Wiebe wrote:

> I went over your post...
>
> You shouldn't be seeing a 4ms response time on a gettimeofday() call -
> this is my test:
>
> gettimeofday({1245079355, 445434}, NULL) = 0 <0.000004>
> gettimeofday({1245079355, 445503}, NULL) = 0 <0.000004>
> gettimeofday({1245079355, 445560}, NULL) = 0 <0.000003>
> gettimeofday({1245079355, 445629}, NULL) = 0 <0.000004>
>
> That's 3-4 microseconds.
>
> For the sake of argument, I checked time() as well, which is obsoleted
> by gettimeofday()...
>
> ime(NULL)                              = 1245079501 <0.000008>
> time(NULL)                              = 1245079501 <0.000007>
> time(NULL)                              = 1245079501 <0.000004>
> time(NULL)                              = 1245079501 <0.000008>
> time(NULL)                              = 1245079501 <0.000004>
>
> About half the speed, but still in the microsecond range.
>
> gettimeofday() is one of the fastest syscalls you can issue.
> Obviously you don't want to beat on it, but I wouldn't worry about
> calling it a few dozen times per second.

this depends greatly on your specific system. linux has some wonderful 
speedups available (basicly it internally does updates only when time 
changes and the system call gets optimized to a read from memory), but 
this is not available on all systems and requires support from glibc. I 
don't remember if the limit is the CPU, 32 bit address space, kernel 
config options, or something else.

I remember seeing that without this kernel optimization a very fast 
pentium (3GHz+) took more than 1 microsecond to do a gettimeofday() call 
(tested by doing 1m calls and it took more than a second)

David Lang



More information about the rsyslog mailing list