Fast sigblock (AKA rtld speedup)
Konstantin Belousov
kostikbel at gmail.com
Sun Jan 13 13:51:17 UTC 2013
On Sun, Jan 13, 2013 at 02:32:00PM +0100, Jilles Tjoelker wrote:
> On Sat, Jan 12, 2013 at 05:25:47PM +0100, Jilles Tjoelker wrote:
> > This suggests a different rather simpler change. Libthr can always use
> > its rtld lock implementation instead of only when multiple threads
> > exist. This avoids the sigprocmask() syscalls and should not be much
> > slower than the default implementation in rtld because that also
> > contains atomic operations (both the unpatched and the patched version).
> > People that care about performance of exceptions can then link in libthr
> > (in many cases, it is already linked in to allow for (the possibility
> > of) threading).
>
> > I have tested this and exceptions were indeed more than twice as fast in
> > my test program if I created an extra thread doing nothing than in the
> > fully single-threaded version (with or without libthr).
>
> Here is a patch. It is lightly tested.
>
> The function _thr_rtld_fini() can be removed afterwards because it is no
> longer used.
>
> Index: lib/libthr/thread/thr_init.c
> ===================================================================
> --- lib/libthr/thread/thr_init.c (revision 244639)
> +++ lib/libthr/thread/thr_init.c (working copy)
> @@ -363,6 +363,7 @@
> _thr_signal_init();
> if (_thread_event_mask & TD_CREATE)
> _thr_report_creation(curthread, curthread);
> + _thr_rtld_init();
Please add a comment there, describing the reason for initializing
threaded rtld locks.
> }
> }
>
> Index: lib/libthr/thread/thr_kern.c
> ===================================================================
> --- lib/libthr/thread/thr_kern.c (revision 244639)
> +++ lib/libthr/thread/thr_kern.c (working copy)
> @@ -57,11 +57,6 @@
> return (0);
>
> __isthreaded = threaded;
> - if (threaded != 0) {
> - _thr_rtld_init();
> - } else {
> - _thr_rtld_fini();
> - }
> return (0);
> }
I do not object.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20130113/9c3eb625/attachment.sig>
More information about the freebsd-arch
mailing list