"Rainer Gerhards" <[email protected]> writes:

>> -----Original Message-----
>> From: [email protected] [mailto:rsyslog-
>> [email protected]] On Behalf Of Aaron Wiebe
>> Sent: Monday, June 15, 2009 4:56 PM
>> To: rsyslog-users
>> Subject: Re: [rsyslog] high-performance, low-precision time API under
> linux?
>> 
>> I'm slightly confused - whats wrong with gettimeofday()?  It may be
>> higher precision, but it still
>> gives you the ability to find the nearest second with a few extra
> operations.
>> 
>> -Aaron
>
> Much too slow. For example, you can often write a sector quicker to disk than
> gettimeofday() returns...

Really?  That doesn't sound right to me.  Writing a sector to disk can
take 8ms or more.  One would hope gettimeofday would be faster than
that, given that it reports microseconds.  ;)  The exact resolution, of
course, depends on how your kernel is configured.  Here are the
measurements (in CPU cycles) I get running each call (time(NULL) and
gettimeofday(&tv, NULL)) 1000 times:

$ ./some-cycle-costs 
                                    fewest cycles  avg cycles
syscall(NR_time)                    2134           2721.99
syscall(NR_gettimeofday)            2156           2622.87

If I understand your original question properly, you don't need to
always have a timer running.  You can only schedule a timer when there
is I/O buffered.  I'm not sure whether your code lends itself to that or
not.

I would be interested in hearing more about what conditions cause
gettimeofday to be so slow.

Cheers,
Jeff

>> On Mon, Jun 15, 2009 at 10:48 AM, Rainer
>> Gerhards<[email protected]> wrote:
>> > Hi all,
>> >
>> > I am having a hard time finding a suitable-fast but tickles solution to
>> > obtaining low-precision time API under Linux. Please read here:
>> >
>> >
> http://blog.gerhards.net/2009/06/high-peformance-low-precision-time-api.html
>> >
>> > If I don't find a better solution, I'll probably be forced to run
> rsyslogd
>> on
>> > a tick, which would not be a good thing from a power consumption point of
>> > view.
>> >
>> > Comments and suggestions are highly appreciated.
>> >
>> > Thanks,
>> > Rainer
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com

Reply via email to