diff options
author | Jason Evans <je@facebook.com> | 2010-02-11 16:59:06 (GMT) |
---|---|---|
committer | Jason Evans <je@facebook.com> | 2010-02-11 16:59:06 (GMT) |
commit | 3383af6c2dcc23a423b395a1a17eba9b24ecb200 (patch) | |
tree | b98d9e57132bf5d10f6b11a1ef4f929ea1d31e63 /jemalloc/src | |
parent | b27805b36309681da1936eb33044584547552340 (diff) | |
download | jemalloc-3383af6c2dcc23a423b395a1a17eba9b24ecb200.zip jemalloc-3383af6c2dcc23a423b395a1a17eba9b24ecb200.tar.gz jemalloc-3383af6c2dcc23a423b395a1a17eba9b24ecb200.tar.bz2 |
Fix a profiling bootstrap bug.
Bootstrap profiling in three stages, so that it is usable by the time
the first application allocation occurs.
Diffstat (limited to 'jemalloc/src')
-rw-r--r-- | jemalloc/src/internal/prof.h | 1 | ||||
-rw-r--r-- | jemalloc/src/jemalloc.c | 20 | ||||
-rw-r--r-- | jemalloc/src/prof.c | 17 |
3 files changed, 25 insertions, 13 deletions
diff --git a/jemalloc/src/internal/prof.h b/jemalloc/src/internal/prof.h index 1721ad8..1d56207 100644 --- a/jemalloc/src/internal/prof.h +++ b/jemalloc/src/internal/prof.h @@ -135,6 +135,7 @@ void prof_mdump(void); void prof_udump(void); void prof_boot0(void); bool prof_boot1(void); +void prof_boot2(void); #endif /* JEMALLOC_H_EXTERNS */ /******************************************************************************/ diff --git a/jemalloc/src/jemalloc.c b/jemalloc/src/jemalloc.c index f035d23..6a3f53e 100644 --- a/jemalloc/src/jemalloc.c +++ b/jemalloc/src/jemalloc.c @@ -636,10 +636,6 @@ MALLOC_OUT: } } -#ifdef JEMALLOC_PROF - prof_boot0(); -#endif - /* Register fork handlers. */ if (pthread_atfork(jemalloc_prefork, jemalloc_postfork, jemalloc_postfork) != 0) { @@ -682,6 +678,10 @@ MALLOC_OUT: return (true); } +#ifdef JEMALLOC_PROF + prof_boot0(); +#endif + if (arena_boot()) { malloc_mutex_unlock(&init_lock); return (true); @@ -725,6 +725,13 @@ MALLOC_OUT: malloc_mutex_init(&arenas_lock); +#ifdef JEMALLOC_PROF + if (prof_boot1()) { + malloc_mutex_unlock(&init_lock); + return (true); + } +#endif + /* Get number of CPUs. */ malloc_initializer = pthread_self(); malloc_mutex_unlock(&init_lock); @@ -816,10 +823,7 @@ MALLOC_OUT: #endif #ifdef JEMALLOC_PROF - if (prof_boot1()) { - malloc_mutex_unlock(&init_lock); - return (true); - } + prof_boot2(); #endif /* Allocate and initialize arenas. */ diff --git a/jemalloc/src/prof.c b/jemalloc/src/prof.c index db56659..85b7020 100644 --- a/jemalloc/src/prof.c +++ b/jemalloc/src/prof.c @@ -1043,11 +1043,6 @@ prof_boot1(void) { if (opt_prof) { - /* - * Finish initializing prof_interval, now that narenas is set. - */ - prof_interval /= narenas; - if (ckh_new(&bt2ctx, PROF_CKH_MINITEMS, prof_bt_hash, prof_bt_keycomp)) return (true); @@ -1090,5 +1085,17 @@ prof_boot1(void) return (false); } +void +prof_boot2(void) +{ + + if (opt_prof) { + /* + * Finish initializing prof_interval, now that narenas is set. + */ + prof_interval /= narenas; + } +} + /******************************************************************************/ #endif /* JEMALLOC_PROF */ |