From: MenTaLguY Date: 2006-11-07T12:27:44+09:00 Subject: optimized mutex results (Was: Re: fast mutexes for 1.8?) --=-olZJu9/RCmycgZLA5vCZ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2006-11-07 at 02:38 +0900, MenTaLguY wrote: > I'm reasonably confident that I can get the no-contention case for > Mutex#synchronize down to somewhere in-between "noop method" and > "open-coded critical". At that point, Mutex#synchronize becomes the > most appealing option, making one less bump on the road when porting > code from 1.8 to 1.9. Well, I did it mostly. Here's the current results: user system total real optimized open-coded lock: =20 4.570000 0.690000 5.260000 ( 5.259699) brazen open-coded critical: 5.540000 0.460000 6.000000 ( 5.993706) optimized synchronize: 5.820000 1.320000 7.140000 ( 7.134976) timid open-coded critical: =20 7.440000 0.570000 8.010000 ( 8.016543) exclusive: 15.660000 2.670000 18.330000 ( 18.331594) open-coded lock:=20 21.740000 2.310000 24.050000 ( 24.052770) synchronize: 27.210000 3.130000 30.340000 ( 30.353295) =20 "timid open-coded critical" is the "reentrant" version (saving the old value of Thread.critical) which I originally benchmarked against; for the sake of apples-to-apples comparison, I also benchmarked the "brazen" non-reentrant version. Interestingly, the optimized Mutex#lock/Mutex#unlock appears to be faster than directly using Thread.critical from Ruby! If y'all would like to check my work, I've got a tarball and git repository up at: http://moonbase.rydia.net/software/optimized-locking/optimized-locking.tar.= gz and http://moonbase.rydia.net/software/optimized-locking/optimized-locking.git Next I will look at re-implementing condition variables in a similar way. -mental --=-olZJu9/RCmycgZLA5vCZ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQBFT/0sSuZBmZzm14ERAl3cAKCeLS0bTswq3OcYzyveE7eQWX/BKwCgscNy aykhCNrPsC2gtpoAxLe9h14= =xs+4 -----END PGP SIGNATURE----- --=-olZJu9/RCmycgZLA5vCZ--