From owner-freebsd-arch Mon Jan 14 12: 7:27 2002 Delivered-To: freebsd-arch@freebsd.org Received: from rover.village.org (rover.bsdimp.com [204.144.255.66]) by hub.freebsd.org (Postfix) with ESMTP id D256137B417 for ; Mon, 14 Jan 2002 12:07:18 -0800 (PST) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.11.3/8.11.3) with ESMTP id g0EK7Hl10261; Mon, 14 Jan 2002 13:07:17 -0700 (MST) (envelope-from imp@village.org) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.11.6/8.11.6) with ESMTP id g0EK7Gx74793; Mon, 14 Jan 2002 13:07:17 -0700 (MST) (envelope-from imp@village.org) Date: Mon, 14 Jan 2002 13:07:05 -0700 (MST) Message-Id: <20020114.130705.84407599.imp@village.org> To: bmilekic@technokratis.com Cc: arch@FreeBSD.ORG Subject: Re: 64 bit counters again From: "M. Warner Losh" In-Reply-To: <20020114114911.A24990@technokratis.com> References: <20020114105859.A24635@technokratis.com> <3C4305E5.65BB32A6@FreeBSD.org> <20020114114911.A24990@technokratis.com> X-Mailer: Mew version 2.1 on Emacs 21.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 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 In message: <20020114114911.A24990@technokratis.com> Bosko Milekic writes: : You're going to run into the same problem with a 64-bit counter, as : Terry pointed out. You're just going to end up moving the time it : takes from 172 seconds to some other, slightly longer, although equally : unreasonable, time. A 64-bit qauntity would take 738734374912 seconds to overflow if the 32-bit one overflowed in 172 seconds. That strikes me as a reasonable enough period of time. If I did the math right, that's on the order of 23 millinia (23425 years). : Instead of counting bytes, perhaps you should count : K or M Bytes. Just take the delta you're about to add to your counter : and divide it by something reasonable before adding it. If you are : really bent on getting accurate results, maintain a separate counter : and sum remainders in it. I'm sure you'll get slightly more accurate : data while not changing all counters to be 64-bits wide on non-64 bit : platforms (i.e., you'll keep the added execution time local to that : specific code you're working on). That's a whole lot more hair than a 64-bit counter :-). Maybe you could do it in k bytes, but the typical packet size is on the order of 1.5k, so you have an error in the neighborhood of 50%. This would be 0M always. It seems to be that the atomicacy of the updates for any accumlated remainder scheme would be the same as for a 64-bit counter, and a whole lot more hair. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message