From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 8 00:20:29 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1D18916A4B3 for ; Wed, 8 Oct 2003 00:20:29 -0700 (PDT) Received: from razorbill.mail.pas.earthlink.net (razorbill.mail.pas.earthlink.net [207.217.121.248]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4838643F3F for ; Wed, 8 Oct 2003 00:20:28 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from user-2ivfldf.dialup.mindspring.com ([165.247.213.175] helo=mindspring.com) by razorbill.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 1A78cT-0004Ra-00; Wed, 08 Oct 2003 00:20:26 -0700 Message-ID: <3F83BA8C.7149BB52@mindspring.com> Date: Wed, 08 Oct 2003 00:19:40 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Luigi Rizzo References: <410-22003102722174477@M2W077.mail2web.com> <20031007163552.A92652@xorpc.icir.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a4a1b368cc57ebe6f2ebda69331abe2d2ea2d4e88014a4647c350badd9bab72f9c350badd9bab72f9c cc: freebsd-hackers@freebsd.org cc: "akanwar@digitarchy.com" Subject: Re: HZ = 1000 slows down application X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Oct 2003 07:20:29 -0000 Luigi Rizzo wrote: > On Tue, Oct 07, 2003 at 06:17:04PM -0400, akanwar@digitarchy.com wrote: > > We did some intensive profiling of our application. It does not seem like > > we are depending on clock ticks for any calculations. > > > > On the other hand we notice that our slow iterations happen almost at the > > same instant as "microuptime went backward" messages in the system log. We > > if this is the case, probably your code at some point computes a > time difference which turns out negative (or if it is unsigned, it > becomes very very large) upon those events, thus causing some loop > to explode. > It should be easy to check if this is the case, and just ignore > those outliers rather than trying to figure out why the clock > goes backward. I used to see the same "microuptime went backwards" > msg on some of my 400MHz boxes, even without NTP enabled. > Maybe a buggy timer, not sure which timecounter was used on that > box (i read some time ago that the cpu on the soekris4801 has a > weird TSC implementation where the upper 32 bits change when the > lower 32 bits are 0xfffffffd, who knows what other bugs might be > in other hardware...) FWIW: Internally, MacOS X supports "monotime", which is a monotonically increasing time counter, guaranteed to not go backwards. That avoids problems exactly like what you are describing. FreeBSD should consider supporting a "monotime". -- Terry