From owner-freebsd-performance@FreeBSD.ORG Mon Jun 2 10:55:36 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 561F7106566C for ; Mon, 2 Jun 2008 10:55:36 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail05.syd.optusnet.com.au (mail05.syd.optusnet.com.au [211.29.132.186]) by mx1.freebsd.org (Postfix) with ESMTP id BC6498FC0A for ; Mon, 2 Jun 2008 10:55:35 +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 mail05.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id m52AtNIc015181 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 2 Jun 2008 20:55:28 +1000 Date: Mon, 2 Jun 2008 20:55:23 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Gary Stanley In-Reply-To: <20080602060624.93F5F8FC4A@mx1.freebsd.org> Message-ID: <20080602203217.T3100@delplex.bde.org> References: <2B465A44-2578-4675-AA17-EBE17A072017@chittenden.org> <20080602060624.93F5F8FC4A@mx1.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-performance@freebsd.org, Sean Chittenden 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: Mon, 02 Jun 2008 10:55:36 -0000 On Mon, 2 Jun 2008, Gary Stanley wrote: > At 12:54 AM 6/2/2008, Sean Chittenden wrote: >> PS Is there a reason that time(3) can't be implemented in terms of >> clock_gettime(CLOCK_SECOND)? 10ms seems precise enough compared to >> time_t's whole second resolution. > > Another interesting idea is to map gettimeofday() to userland, sort of like > darwin (commpage) and linux (vsyscall) via read only page. time() can reasonably be implemented like that, but not gettimeofday(). gettimeofday() should have an accuracy of 1 usec and it returns a large data structure that cannot be locked by simple atomic accesses. The read-only page would have to be updated millions of times per second or take a pagefault to access to give the same functionality as FreeBSD gettimeofday(). The updates would cost about 100% of 1 CPU. Other CPUs could then read the time using locking like that in binuptime() but more complicated (needs an atomic update for at least the generation count, and probably more). The pagefaults would give a smaller pessimization (I guess slightly longer to reach microtime() than via the current syscall, and identical time in microtime() to do the update on demand). Bruce