Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Mar 2008 10:29:24 +0000 (GMT)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Peter Jeremy <peterjeremy@optushome.com.au>
Cc:        cvs-src@freebsd.org, Roman Divacky <rdivacky@freebsd.org>, src-committers@freebsd.org, cvs-all@freebsd.org, Jung-uk Kim <jkim@freebsd.org>
Subject:   Re: cvs commit: src/usr.sbin/moused moused.c
Message-ID:  <20080306102751.J21309@fledge.watson.org>
In-Reply-To: <20080306095407.GS68971@server.vk2pj.dyndns.org>
References:  <200803060022.m260MHSx017085@repoman.freebsd.org> <20080306092045.GA54220@freebsd.org> <20080306095407.GS68971@server.vk2pj.dyndns.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 6 Mar 2008, Peter Jeremy wrote:

> On Thu, Mar 06, 2008 at 10:20:45AM +0100, Roman Divacky wrote:
>> On Thu, Mar 06, 2008 at 12:22:17AM +0000, Jung-uk Kim wrote:
>>>   Prefer clock_gettime(2) over gettimeofday(2) and use CLOCK_MONOTONIC_FAST.
>>>   It is only used to track elapsed time and it does not have to be 
>>> precise.
>>
>> what is the rationale behind this? what is the expected improvement? I am 
>> not questioning the change I am just curious..
>
> There's been a recent extensive thread about poor X11 performance and it 
> turns out the the Xserver can issue multiple gettimeofday(2) calls every 
> time it sees a mouse movement.  gettimeofday(2) on FreeBSD is relatively 
> expensive (the Project chose accuracy over speed) and clock_gettime(2) using 
> CLOCK_MONOTONIC_FAST is a much cheaper alternative when accuracy isn't 
> critical.
>
> The Xserver should be using clock_gettime(2) but there's a bug in its 
> POSIX-compatibility selection.  Applying a similar fix to moused is a 
> logical extension.

Many applications also assume that gettimeofday(2) returns a monotonically, 
and possibly consistently, increasing value.  Sometimes this is fine (log 
timestamps) and other times this is not (time deltas used to calculate mouse 
acceleration, etc).

Robert N M Watson
Computer Laboratory
University of Cambridge



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080306102751.J21309>