Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Aug 2007 01:09:17 +0200
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        freebsd-arch@FreeBSD.org
Subject:   Re: Lockless uidinfo.
Message-ID:  <20070818230917.GI6498@garage.freebsd.pl>
In-Reply-To: <20070818220756.GH6498@garage.freebsd.pl>
References:  <20070818120056.GA6498@garage.freebsd.pl> <20070818220756.GH6498@garage.freebsd.pl>

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

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

On Sun, Aug 19, 2007 at 12:07:56AM +0200, Pawel Jakub Dawidek wrote:
> Two more things...
>=20
> > The patch below remove per-uidinfo locks:
> >=20
> > 	http://people.freebsd.org/~pjd/patches/uidinfo_lockless.patch
>=20
> We could upgrade from lock-free algorithm I used here to wait-free
> algorithm, but we don't have atomic_fetchadd_long(). How hard will it be
> to implement it?
>=20
> We could then change:
>=20
> 	do {
> 		old =3D uip->ui_proccnt;
> 		if (old + diff > max)
> 			return (0);
> 	} while (atomic_cmpset_long(&uip->ui_proccnt, old, old + diff) =3D=3D 0);
>=20
> to something like this:
>=20
> 	if (atomic_fetchadd_long(&uip->ui_proccnt, diff) + diff > max) {
> 		atomic_subtract_long(&uip->ui_proccnt, diff);
> 		return (0);
> 	}

Ok, after implementing atomic_fetchadd_long() on amd64, we get additional
6% of performance improvement:

x ./uidinfo_lockfree.txt (atomic_cmpset_long loop)
+ ./uidinfo_waitfree.txt (atomic_fetchadd_long)
+--------------------------------------------------------------------------=
----+
|                                                                          =
   +|
|                                                                          =
   +|
|x   xx    xx                                                              =
+ ++|
|  |__MA___|                                                               =
 |AM|
+--------------------------------------------------------------------------=
----+
    N           Min           Max        Median           Avg        Stddev
x   5       1561566       1575987       1568964       1569767     5853.1399
+   5       1662362       1665936       1665810     1664881.8     1541.2693
Difference at 95.0% confidence
        95114.8 +/- 6241.96
        6.05917% +/- 0.397636%
        (Student's t, pooled s =3D 4279.88)

--=20
Pawel Jakub Dawidek                       http://www.wheel.pl
pjd@FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFGx3wdForvXbEpPzQRApSQAKDIUM4EV6lomKGgQouhx/RlehhVbwCgoTPf
rG0yxVgxqJb74QUyxYDSZKY=
=R+1E
-----END PGP SIGNATURE-----

--Li7ckgedzMh1NgdW--



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