From owner-freebsd-performance@FreeBSD.ORG Tue Jun 3 09:32:02 2008 Return-Path: Delivered-To: freebsd-performance@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30F011065671 for ; Tue, 3 Jun 2008 09:32:02 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail09.syd.optusnet.com.au (mail09.syd.optusnet.com.au [211.29.132.190]) by mx1.freebsd.org (Postfix) with ESMTP id B86938FC0C for ; Tue, 3 Jun 2008 09:32:01 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c220-239-252-11.carlnfd3.nsw.optusnet.com.au (c220-239-252-11.carlnfd3.nsw.optusnet.com.au [220.239.252.11]) by mail09.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id m539Vo7n028647 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 3 Jun 2008 19:31:53 +1000 Date: Tue, 3 Jun 2008 19:31:50 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Sean Chittenden In-Reply-To: Message-ID: <20080603192056.B6242@delplex.bde.org> References: <2B465A44-2578-4675-AA17-EBE17A072017@chittenden.org> <20080602205953.X3162@delplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-performance@FreeBSD.org, Bruce Evans , Claus Guttesen Subject: Re: Micro-benchmark for various time syscalls... X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jun 2008 09:32:02 -0000 On Mon, 2 Jun 2008, Sean Chittenden wrote: >>> rozetta~/devel/c%>sysctl hw.model >>> hw.model: Intel(R) Xeon(R) CPU E5345 @ 2.33GHz >>> >>> rozetta~/devel/c%>./bench_time 9079882 | sort -rnk1 >>> Timing micro-benchmark. 9079882 syscall iterations. >>> Avg. us/call Elapsed Name >>> 1.405469 12.761494 clock_gettime(2/CLOCK_REALTIME) >>> ... >> >> These seem about right for a normal untuned ~2GHz system: > > This begs the question, tuning for time calls. Do you have a best practice > that you use for reducing the cost of time calls? -sc At least try all possible time counters, and choose the one that works best. Best == fastest and accurate enough. Best != highest quality according to kernel hard-coded quality numbers. ntp will tell you if it isn't accurate enough if this isn't obvious. This normally means the TSC on UP systems without power management and ACPI-fast otherwise. The kernel quality parameter gives too much preference to ACPI-fast. Switching between all possible timecounters at runtime is easier in not very old versions of FreeBSD. Old versions didn't even list all timecounters considered at boot time. Some timecounters, e.g., HPET and of course ACPI* on non-ACPI systems are not available even if the hardware supports them unless they are configured at compile time or boot time. It's hard to test the HPET counter on new FreeBSD cluster machines because it is not confiugured and it would require privilege to use if it were configured but not selected. Bruce