Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Mar 2004 17:42:06 -0800
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        Mike Jakubik <mikej@rogers.com>
Cc:        net@freebsd.org
Subject:   Re: Byte counters reset at ~4GB
Message-ID:  <20040316014206.GA12382@Odin.AC.HMC.Edu>
In-Reply-To: <2697.192.168.0.200.1079398101.squirrel@192.168.0.1>
References:  <2650.192.168.0.200.1079393908.squirrel@192.168.0.1> <20040316000153.GA73860@router.laiers.local> <2662.192.168.0.200.1079396323.squirrel@192.168.0.1> <20040316004046.GA74287@router.laiers.local> <2697.192.168.0.200.1079398101.squirrel@192.168.0.1>

next in thread | previous in thread | raw e-mail | index | archive | help

--NzB8fVQJ5HfG6fxh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Mar 15, 2004 at 07:48:21PM -0500, Mike Jakubik wrote:
> Max Laier said:
>=20
> > Sure, you measure it ;) ... no, of course it is more expensive to updat=
e a
> > 64bit counter on a 32bit arch, but the key (once again) is descision:
> > While
> > (almost) all of the pf counters are 64bit types you can configure it not
> > to
> > use the loginterface or whatsoever more. So it's up to you: You need 64=
bit
> > counters? You shall have them! You need *fast* 64bit counters? AMD sells
> > nice processors (they say)! ... you get the idea.
>=20
> Got it. In just curious though... realistically, how big of an impact on
> performance is this on a modern CPU? Is it not simply the original 32bit
> calculation x 2?

No, you have to do overflow handling so that adds some to the cost.

I was curious what the actual overhead was so I ran the following
program with both uint32_t and uint64_t counters.  With 64-bit counters,
it was a bit over four times slower on a the dual 2.2GHz Xeon (~2sec vs
~8.4sec).  On a dual opteron, the 32-bit math had a slight edge, but
not much.  Intestingly, runtime was longer then on the Xeon (~3.1s for
32-bit and ~3.8 for 64-bit.)

If you do this test, be sure not to use any optimizer flags or the whole
loop gets optimized out.

-- Brooks

#include <stdio.h>
#include <stdint.h>

int
main (int argc, char **argv)
{
	uint32_t j =3D 0;

	for (j =3D 0; j < 1000000000; j++) {}
	printf("%d\n", j);
}




--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

--NzB8fVQJ5HfG6fxh
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFAVltsXY6L6fI4GtQRAl2rAJ9x2sxnvvzd+Wx8atFF2g01CX22twCfRJwv
RUwgo98YRpEj4APbFOEotwo=
=vDX/
-----END PGP SIGNATURE-----

--NzB8fVQJ5HfG6fxh--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040316014206.GA12382>