From owner-freebsd-arch Sun Feb 17 23: 7:53 2002 Delivered-To: freebsd-arch@freebsd.org Received: from falcon.prod.itd.earthlink.net (falcon.mail.pas.earthlink.net [207.217.120.74]) by hub.freebsd.org (Postfix) with ESMTP id 6986037B41E; Sun, 17 Feb 2002 23:06:44 -0800 (PST) Received: from pool0305.cvx21-bradley.dialup.earthlink.net ([209.179.193.50] helo=mindspring.com) by falcon.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16chsi-0006ya-00; Sun, 17 Feb 2002 23:06:36 -0800 Message-ID: <3C70A7F0.C409B43F@mindspring.com> Date: Sun, 17 Feb 2002 23:06:24 -0800 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Bruce Evans Cc: Poul-Henning Kamp , Matthew Dillon , Julian Elischer , Alfred Perlstein , arch@FreeBSD.ORG, jhb@FreeBSD.ORG, peter@wemm.org, jake@locore.ca Subject: Re: gettimeofday() and crhold()/crfree() (was Re: gettimeofday()andcopyout().Is copyout() MPSAFE on non-i386 archs? ) References: <20020218144148.F4583-100000@gamplex.bde.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bruce Evans wrote: > > > I know the synchronization costs for this would be high. They are too > > > high even in the kernel, so we skip them for the get*time() family, > > > at the cost of getting unsynchronised times. This may be acceptable > > > in some applications. The read-only variable in kernel memory has > > > similar synchronisation problems. It corresponds fairly directly > > > with the variable read by the get*time() family. > > > > I *know* that it is a significant win to flip-flop the > > timecounter context into a reflected user space page > > on each and every clock interrupt. > > That can't be used to implement gettimeofday(). It can only be used > to implement the userland equivalants of get_micro[up]time() and > get_nano[up]time(). I don't like using these even for stamping file > times in seconds in the kernel (though they have more than enough > precision for this), since they give times that are incoherent > relative to other ways of determining the time. I guess you want me to implement it again, outside the context of the code I implemented for ClickArray, and donate it back to the project? The only dependency is that the context is not updated during the copy operation itself, which can be guaranteed by a single "generation" counter save before/test after around the copy (trivial). In actual practice, I've never seen this happen in the time it took the inline function version of the expanded gettimeofday() to run, even under heavy load. I think that's because everything fits in cache, though I can't guarantee that missing two time slices has ever happened in that application (in any case, it's protected). > > The benefits to doing this for squid alone, which must > > make about 5 gettimeofday() calls per transaction in > > order to do "correct" logging (IMO, logging is eye candy, > > though some idiots insist on billing based on post > > processing log files), are more than significant, they > > are a doubling of the transaction rate. > > Apparently they don't actually look at the timestamps and notice > that they (the timestamps) are often the same for different > transactions because the timestamps have low resolution. You > can fake the increment, but then you can fake the time too. Not really. The time stamps are spread over a fairly high latency path of client connection, request complete, connection to back end, request sent, response received, response sent, disconnect. While concurrent requests may end up with the same stamp, individual client timings are pretty accurate -- at least as accurate as calling the kernel kettimeofday() instead, within a very small variance (~.1ms, measured). > > Crossing protection domains for read-only data which is > > frequently accessed is a really, really bad idea. > > Does it really matter for logging? If all you were doing was logging, no, but since the logging is indicative of doing work, yes. 8-) 8-). A significant amout of the system call overhead in the processing of a kevent based program is in the logging. One approach we considered was to add a timestamp to the kevents themselves, and log using that, instead, but it turns out that the logging frequency was lower than the even frequency by enough of a margin that the expense of doing that was too high. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message