From owner-freebsd-current@FreeBSD.ORG Fri Oct 28 20:34:55 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 5854C16A41F for ; Fri, 28 Oct 2005 20:34:55 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.FreeBSD.org (Postfix) with ESMTP id F00C343D48 for ; Fri, 28 Oct 2005 20:34:54 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (unknown [192.168.48.2]) by phk.freebsd.dk (Postfix) with ESMTP id 6253DBC50; Fri, 28 Oct 2005 20:34:53 +0000 (UTC) To: Peter Jeremy From: "Poul-Henning Kamp" In-Reply-To: Your message of "Sat, 29 Oct 2005 06:15:05 +1000." <20051028201505.GV39882@cirb503493.alcatel.com.au> Date: Fri, 28 Oct 2005 22:34:52 +0200 Message-ID: <35273.1130531692@critter.freebsd.dk> Sender: phk@critter.freebsd.dk 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 20:34:55 -0000 In message <20051028201505.GV39882@cirb503493.alcatel.com.au>, Peter Jeremy wri tes: >I was thinking that if the cost differential is large enough, it might >be worthwhile using different hardware counters (especially for duration >values where you don't have to worry about getting a valid UTC time). Yes, that is an obvious way to tune things. The problem however is the same: Getting convinced that the TSC is constant frequency is non-trivial. >This would probably mean adding a system call to set a default timer >type which is part of the struct proc - upon reflection, there would be >a significant amount of kernel API churn (at least) to get this to work. And worse: Unless we can sell the concept to the other contemporary UNIXen, another FreeBSD specific API which sees little use. >To go off on a different tangent, would it be possible to use the NTP >algorithms to synchronize the TSC? It all comes down to how much CPU time you're willing to burn to make timekeeping faster... >This gives something like: > now = magic->offset + (rdtsc() * magic->multiplier) >> magic->shift; You should really read http://phk.freebsd.dk/pubs/timecounter.pdf first :-) -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.