[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libunwind-devel] Updated fast trace patch with initial performance
From: |
Arun Sharma |
Subject: |
Re: [Libunwind-devel] Updated fast trace patch with initial performance results |
Date: |
Tue, 5 Apr 2011 16:23:28 -0700 |
On Tue, Apr 5, 2011 at 3:13 PM, Lassi Tuura <address@hidden> wrote:
> How far do we want to go in attempting to avoid the one calloc()? :-)
> Choices seem to be:
> a. Use __thread, require per-thread wrapper callbacks from app
> b. Use lock-free global cache stack, must still free 'unused' caches.
> c. Use pthread_getspecific, deal with calloc from pthread_key_create,
> maybe require app to call some init function once at 'safe' time if
> it uses unw_backtrace?
It just occurred to me that we can use both __thread and pthread_setspecific()
--- a/src/x86_64/Gtrace.c
+++ b/src/x86_64/Gtrace.c
@@ -161,6 +161,8 @@ trace_cache_expand (unw_trace_cache_t *cache)
return 0;
}
+static __thread unw_trace_cache_t *tls_cache;
+
/* Get the frame cache for the current thread. Create it if there is none. */
static unw_trace_cache_t *
trace_cache_get (void)
@@ -169,10 +171,11 @@ trace_cache_get (void)
if (pthread_once)
{
pthread_once(&trace_cache_once, &trace_cache_init_once);
- if (! (cache = pthread_getspecific(trace_cache_key)))
+ if (! (cache = tls_cache))
{
cache = trace_cache_create();
pthread_setspecific(trace_cache_key, cache);
+ tls_cache = cache;
}
Debug(5, "using cache %p\n", cache);
return cache;
Hopefully, this will be faster than pthread_getspecific() and may
allow us to defer the call to pthread_setspecific() to a safer point.
-Arun
- Re: [Libunwind-devel] Updated fast trace patch with initial performance results, (continued)
Re: [Libunwind-devel] Updated fast trace patch with initial performance results, Lassi Tuura, 2011/04/05
Re: [Libunwind-devel] Updated fast trace patch with initial performance results, Lassi Tuura, 2011/04/05
- Re: [Libunwind-devel] Updated fast trace patch with initial performance results, Arun Sharma, 2011/04/05
- Re: [Libunwind-devel] Updated fast trace patch with initial performance results, Lassi Tuura, 2011/04/05
- Re: [Libunwind-devel] Updated fast trace patch with initial performance results, Arun Sharma, 2011/04/05
- Re: [Libunwind-devel] Updated fast trace patch with initial performance results, Lassi Tuura, 2011/04/05
- Re: [Libunwind-devel] Updated fast trace patch with initial performance results,
Arun Sharma <=
- Re: [Libunwind-devel] Updated fast trace patch with initial performance results, Paul Pluzhnikov, 2011/04/05
- Re: [Libunwind-devel] Updated fast trace patch with initial performance results, Arun Sharma, 2011/04/05
- Re: [Libunwind-devel] Updated fast trace patch with initial performance results, Paul Pluzhnikov, 2011/04/05