Date: Fri, 11 Jan 2013 11:54:59 +0200 From: Konstantin Belousov <kostikbel@gmail.com> To: arch@freebsd.org, toolchain@freebsd.org Subject: Re: Fast sigblock (AKA rtld speedup) Message-ID: <20130111095459.GZ2561@kib.kiev.ua> In-Reply-To: <20130107182235.GA65279@kib.kiev.ua> References: <20130107182235.GA65279@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
--NSDslKtQVY7LeFYu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 07, 2013 at 08:22:35PM +0200, Konstantin Belousov wrote: > Below is the forward of the patch for which I failed to obtain a private > review. Might be, the list generates more responses. >=20 > Our rtld has a performance bootleneck, typically exposed by the images > with the lot of the run-time relocation processing, and by the C++ > exception handling. We block the signals delivery during the rtld > performing the relocations, as well as for the dl_iterate_phdr(3) (the > later is used for finding the dwarf unwinding tables). >=20 > The signal blocking is needed to allow the rtld to resolve the symbols > for the signal handlers in the safe way, but also causes 2 syscalls > overhead per each rtld entry. >=20 > The proposed approach allows to shave off those two syscalls, doubling > the FreeBSD performance for the (silly) throw/catch C++ microbenchmark. >=20 > Date: Mon, 13 Aug 2012 15:26:00 +0300 > From: Konstantin Belousov <kostikbel@gmail.com> >=20 > ... >=20 > The basic idea is to implement sigprocmask() as single write into usermode > address. If kernel needs to calculate the signal mask for current thread, > it takes into the consideration non-zero value of the word at the agreed > address. Also, usermode is informed about signals which were put on hold > due to fast sigblock active. >=20 > As I said, on my measurements in microbenchmark that did throw/catch in > a loop, I see equal user and system time spent for unpatched system, and > same user time with zero system time on patched system. >=20 > Patch can be improved further, e.g. it would be nice to allow rtld to fall > back to sigprocmask(2) if kernel does not support fast sigblock, to preve= nt > flag day. Also, the mask enforced by fast sigblock can be made configurab= le. >=20 > Note that libthr already blocks signals by catching them, and not using r= tld > service in the first line handler. I tried to make the change in the spir= it > of libthr interceptors, but handoff to libthr appears too complicated to > work. In fact, libthr can be changed to start using fast sigblock instead > of wrapping sigaction, but this is out of scope of the proposal right now. >=20 > Please comment. So there were no overly negative comments, and thanks to Alfred and David for useful notes. The patch at http://people.freebsd.org/~kib/misc/rtld-sigblock.2.patch is the commit candidate. Now kernel informs rtld about supprt for fast_sigblock with new auxv flag. Rtld can operate on old (and possibly future) kernels without fast_sigblock, rtld checks the auxv for presence of the ELF_BSDF_FASTSIGBLK flag before use. --NSDslKtQVY7LeFYu Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIcBAEBAgAGBQJQ7+FyAAoJEJDCuSvBvK1BsJYP/iWcrdR8vkZY7F0vNFXpBxjR ut2gpD7pkI4biwsZECz8HzyR6nOceyxENv7ufyVu9M2bkIvwb7mIIfgnjAkBzvik yRh/LOl7eY0GBJpYtykF3m9dp3s+hPvF+SBg1NjQD5x8snC8uIWlToNRxms24P9i 0sUn4KosmntfedrVlLgf2cuXR3QJzOs7h9A1O/RBjelcMVMB1E1SmatrrCqAVWhz EwwKBdOhtyOWtKXEY3tkcsjsjI5nlsUnBOs17mwO1vqID956xZmCQGXM1/sM8yWH 2TAzKa89l06E9ql11lM+z6gzQ6oJb587S8VRPXgwaZU4pIKbgq3jbz2uFcsQKUiz IONGZyZBhO2VrvJWccE/5uASnc24yMck4eHztkibm6SqyrG0qnUZLxNmL2bUQXiN yg+U/DRxXjBBCFWiDnD6U3x+JlVbv91vIsOtrOGbmsIpXeZJ8ggybDD1ejR7n8fN 7V9UXneHrqM2/j7xFwZElqL7DfALVYv5pSqe/n0kf0/RkOZk3GMo3qZLf48im1A+ 8+2Iwez9MZDeWlIAJJPyrIPitZppjLCOb2NJZKFznc/tTQVg8Ug3GM8EnlzvRbw/ XltAhJilvGXGrZrrqxLekFeV9UUc0rQldZ/Wel9xFmrS5DrYNd94PME/lbRdzrEY ilQiq6EeRxZ893rISj3Q =66cr -----END PGP SIGNATURE----- --NSDslKtQVY7LeFYu--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130111095459.GZ2561>