From owner-freebsd-current@FreeBSD.ORG Fri Oct 28 09:34:32 2005 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EE26416A422 for ; Fri, 28 Oct 2005 09:34:31 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from mail19.syd.optusnet.com.au (mail19.syd.optusnet.com.au [211.29.132.200]) by mx1.FreeBSD.org (Postfix) with ESMTP id C78AA43D5A for ; Fri, 28 Oct 2005 09:34:16 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c220-239-19-236.belrs4.nsw.optusnet.com.au [220.239.19.236]) by mail19.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id j9S9Y4DK000378 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Fri, 28 Oct 2005 19:34:10 +1000 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1]) by cirb503493.alcatel.com.au (8.12.10/8.12.10) with ESMTP id j9S9Y3Hh050060; Fri, 28 Oct 2005 19:34:03 +1000 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost) by cirb503493.alcatel.com.au (8.12.10/8.12.9/Submit) id j9S9Y20c050059; Fri, 28 Oct 2005 19:34:02 +1000 (EST) (envelope-from pjeremy) Date: Fri, 28 Oct 2005 19:34:02 +1000 From: Peter Jeremy To: Poul-Henning Kamp Message-ID: <20051028093402.GT39882@cirb503493.alcatel.com.au> References: <43613541.7030009@mac.com> <26845.1130452524@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <26845.1130452524@critter.freebsd.dk> User-Agent: Mutt/1.4.2.1i X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc Cc: current@freebsd.org Subject: Re: Timers and timing, was: MySQL Performance 6.0rc1 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2005 09:34:32 -0000 On Fri, 2005-Oct-28 00:35:24 +0200, Poul-Henning Kamp wrote: > * Does threads have to return ordered timestamps ? > > Consider: > > CPU1 CPU2 > > gettimeofday(t1) > gettimeofday(t2) > gettimeofday(t3) ... > > [t1 <= t2 <= t3] If this reflects kernel threads, unless there's some sort of explicit synchronization between the two threads, there's no need to guarantee anything better than t1 <[=] t3. If the threads are explicitly synchronised, then we should guarantee t1 <= t2 <= t3. On Thu, 2005-Oct-27 19:50:45 -0400, Chuck Swiger wrote: >I believe Darwin keeps the timecounters of the system exposed on a common >page mapped via the System framework (their libc+libm), which gets mapped >in once by init, and then shared with all of it's children copy-on-write. >They are using the PowerPC timebase registers according to a thread on the >darwin-kernel list. SunOS 4.x (I'm not sure about SunOS 5.x) did this as well. As Poul pointed out, this is much easier with sane hardware. FreeBSD already supports a variety of different timecounters with different levels of accuracy/performance/guarantees. One problem is that this is a system-wide knob whereas different applications may have different requirements. Whilst it's reasonable for MySQL to gather performance statistics, it only needs to measure short time periods and doesn't require extreme accuracy - the TSC would probably be good enough on a UP system (if there was a quick way to measure the current TSC tick rate). I don't think there's any way on i386 to quickly access a timecounter that returns a synchronised time across multiple CPUs. -- Peter Jeremy