Date: Thu, 5 Nov 2015 08:48:37 +0100 From: Hans Petter Selasky <hps@selasky.org> To: Mateusz Guzik <mjguzik@gmail.com>, freebsd-current@freebsd.org Subject: Re: [PATCH] microoptimize by trying to avoid locking a locked mutex Message-ID: <563B09D5.6050000@selasky.org> In-Reply-To: <20151104233218.GA27709@dft-labs.eu> References: <20151104233218.GA27709@dft-labs.eu>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, Did you test this patch works like expected with non x86 platforms? --HPS On 11/05/15 00:32, Mateusz Guzik wrote: > mtx_lock will unconditionally try to grab the lock and if that fails, > will call __mtx_lock_sleep which will immediately try to do the same > atomic op again. > > So, the obvious microoptimization is to check the state in > __mtx_lock_sleep and avoid the operation if the lock is not free. > > This gives me ~40% speedup in a microbenchmark of 40 find processes > traversing tmpfs and contending on mount mtx (only used as an easy > benchmark, I have WIP patches to get rid of it). > > Second part of the patch is optional and just checks the state of the > lock prior to doing any atomic operations, but it gives a very modest > speed up when applied on top of the __mtx_lock_sleep change. As such, > I'm not going to defend this part.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?563B09D5.6050000>