From owner-freebsd-current@FreeBSD.ORG Fri Oct 28 10:14:50 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 CE6E816A41F; Fri, 28 Oct 2005 10:14:50 +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 6B76843D45; Fri, 28 Oct 2005 10:14:50 +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 B0FE9BC50; Fri, 28 Oct 2005 10:14:48 +0000 (UTC) To: Jiawei Ye From: "Poul-Henning Kamp" In-Reply-To: Your message of "Fri, 28 Oct 2005 17:48:19 +0800." Date: Fri, 28 Oct 2005 12:14:48 +0200 Message-ID: <30832.1130494488@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: Mark Kirkwood , Pawel Jakub Dawidek , David Xu , "Yuriy N. Shkandybin" , 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 10:14:50 -0000 In message , Jiawe i Ye writes: Very typical numbers... >kern.timecounter.hardware: ACPI-fast -> TSC > getpid(): 0.94267 > gettimeofday(): 1.25332 So timekeeping "as such" takes no more than 310nsec and that includes a TSC read of unknown duration. I consider the 310 nsec acceptable, but if this is a really big problem for people, somebody is welcome to start looking at doing inline assembler code to speed it up >kern.timecounter.hardware: TSC -> ACPI-fast > getpid(): 0.94788 > gettimeofday(): 2.29598 ACPI-fast does an inl() which seems to take a microsecond longer than rdtsc(). One microsecond is disgusting considering that the hardware lives in the chipset and was meant to improve timekeeping performance. >kern.timecounter.hardware: ACPI-fast -> i8254 > getpid(): 0.96921 > gettimeofday(): 5.01292 And i8254 does a outb() and several 8 bit inb on a simulated ISA bus and therefore takes 3.75 usec longer than rdtsc(). -- 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.