[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: guile performance - Ackermann function: way slower than emacs, slowe
From: |
Ken Raeburn |
Subject: |
Re: guile performance - Ackermann function: way slower than emacs, slower still if compiled |
Date: |
Thu, 6 Aug 2009 03:31:51 -0400 |
On Aug 5, 2009, at 10:06, Ken Raeburn wrote:
(1) In scm_pthread_mutex_lock, we leave and re-enter guile mode so
that we don't block the thread while in guile mode. But we could
use pthread_mutex_trylock first, and avoid the costs scm_leave_guile
seems to incur on the Mac. If we can't acquire the lock, it should
return immediately, and then we can do the expensive, blocking
version. A quick, hack version of this changed my run time for
A(3,8) from 17.5s to 14.5s, saving about 17%; sigaltstack and
sigprocmask are still in the picture, because they're called from
scm_catch_with_pre_unwind_handler. I'll work up a nicer patch later.
Ah, we already had scm_i_pthread_mutex_trylock lying around; that made
things easy.
A second timing test with A(3,9) and this version of the patch (based
on 1.9.1) shows the same improvement.
diff --git a/libguile/threads.c b/libguile/threads.c
index 9589336..8458a60 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -1826,10 +1826,15 @@ scm_std_select (int nfds,
int
scm_pthread_mutex_lock (scm_i_pthread_mutex_t *mutex)
{
- scm_t_guile_ticket t = scm_leave_guile ();
- int res = scm_i_pthread_mutex_lock (mutex);
- scm_enter_guile (t);
- return res;
+ if (scm_i_pthread_mutex_trylock (mutex) == 0)
+ return 0;
+ else
+ {
+ scm_t_guile_ticket t = scm_leave_guile ();
+ int res = scm_i_pthread_mutex_lock (mutex);
+ scm_enter_guile (t);
+ return res;
+ }
}
static void
- guile performance - Ackermann function: way slower than emacs, slower still if compiled, Ken Raeburn, 2009/08/04
- Re: guile performance - Ackermann function: way slower than emacs, slower still if compiled, Marijn Schouten (hkBst), 2009/08/04
- Re: guile performance - Ackermann function: way slower than emacs, slower still if compiled, Andy Wingo, 2009/08/05
- Re: guile performance - Ackermann function: way slower than emacs, slower still if compiled, Ken Raeburn, 2009/08/05
- entering and leaving guile mode, and GC stack protection (was Re: guile performance - Ackermann function: way slower than emacs, slower still if compiled), Ken Raeburn, 2009/08/06
- Re: entering and leaving guile mode, and GC stack protection, Andy Wingo, 2009/08/12
- Re: entering and leaving guile mode, and GC stack protection, Ludovic Courtès, 2009/08/14
Re: guile performance - Ackermann function: way slower than emacs, slower still if compiled, Ludovic Courtès, 2009/08/08
Re: guile performance - Ackermann function: way slower than emacs, slower still if compiled, Andy Wingo, 2009/08/05
Re: guile performance - Ackermann function: way slower than emacs, slower still if compiled, Andy Wingo, 2009/08/05