excessive use of gettimeofday(2) and other syscalls

Manish Vachharajani manishv at lineratesystems.com
Tue Sep 6 23:07:05 UTC 2011


Under 7.3 (haven't checked 8 or 9) this issue crops up because the
time system call calls gettimeofday under the hood (see
lib/libc/gen/time.c).  As a result, the kernel tries to get an
accurate subsecond resolution time that simply gets chopped to the
nearest second.  Lots of libraries assume that time is fast because it
is fast under Linux.  Every instance where I have seen this as a
performance issue, the call has been to time not a direct call to
gettimeofday.  The latest openssl (not the one from FreeBSD, but the
one from openssl.org has this issue for example.

Manish

On Tue, Sep 6, 2011 at 4:01 PM, Alexander Best <arundel at freebsd.org> wrote:
> hi there,
>
> in a recent discussion on current@ [1], it was discovered that chromium makes
> excessive use of gettimeofday(2). while searching google, i found other
> software that is/was having the same issue [2]. although this is a programming
> error, it would still be nice, if freebsd could issue a warning in cases like
> these. would it be possible to instruct freebsd to issue a warning, when a
> process issues a certain amount of syscalls per second (maybe tuneable via
> sysctl)?
>
> while calling gettimeofday(2) excessively isn't causing any harm, it triggers
> a lot of context switches and reduces performance. having such warnings in
> place could help a user identify such a process without having to use debugging
> tools, such as ktrace or dtrace.
>
> cheers.
> alex
>
> [1] http://www.mail-archive.com/freebsd-current@freebsd.org/msg131040.html
> [1] https://forum.transmissionbt.com/viewtopic.php?f=2&t=11687
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>



-- 
Manish Vachharajani
Founder
LineRate Systems
manishv at lineratesystems.com
(609)635-9531 M


More information about the freebsd-hackers mailing list