Fix a profiling bootstrap bug.

Bootstrap profiling in three stages, so that it is usable by the time
the first application allocation occurs.
This commit is contained in:
Jason Evans 2010-02-11 08:59:06 -08:00
parent b27805b363
commit 3383af6c2d
3 changed files with 25 additions and 13 deletions

View File

@ -135,6 +135,7 @@ void prof_mdump(void);
void prof_udump(void); void prof_udump(void);
void prof_boot0(void); void prof_boot0(void);
bool prof_boot1(void); bool prof_boot1(void);
void prof_boot2(void);
#endif /* JEMALLOC_H_EXTERNS */ #endif /* JEMALLOC_H_EXTERNS */
/******************************************************************************/ /******************************************************************************/

View File

@ -636,10 +636,6 @@ MALLOC_OUT:
} }
} }
#ifdef JEMALLOC_PROF
prof_boot0();
#endif
/* Register fork handlers. */ /* Register fork handlers. */
if (pthread_atfork(jemalloc_prefork, jemalloc_postfork, if (pthread_atfork(jemalloc_prefork, jemalloc_postfork,
jemalloc_postfork) != 0) { jemalloc_postfork) != 0) {
@ -682,6 +678,10 @@ MALLOC_OUT:
return (true); return (true);
} }
#ifdef JEMALLOC_PROF
prof_boot0();
#endif
if (arena_boot()) { if (arena_boot()) {
malloc_mutex_unlock(&init_lock); malloc_mutex_unlock(&init_lock);
return (true); return (true);
@ -725,6 +725,13 @@ MALLOC_OUT:
malloc_mutex_init(&arenas_lock); malloc_mutex_init(&arenas_lock);
#ifdef JEMALLOC_PROF
if (prof_boot1()) {
malloc_mutex_unlock(&init_lock);
return (true);
}
#endif
/* Get number of CPUs. */ /* Get number of CPUs. */
malloc_initializer = pthread_self(); malloc_initializer = pthread_self();
malloc_mutex_unlock(&init_lock); malloc_mutex_unlock(&init_lock);
@ -816,10 +823,7 @@ MALLOC_OUT:
#endif #endif
#ifdef JEMALLOC_PROF #ifdef JEMALLOC_PROF
if (prof_boot1()) { prof_boot2();
malloc_mutex_unlock(&init_lock);
return (true);
}
#endif #endif
/* Allocate and initialize arenas. */ /* Allocate and initialize arenas. */

View File

@ -1043,11 +1043,6 @@ prof_boot1(void)
{ {
if (opt_prof) { 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, if (ckh_new(&bt2ctx, PROF_CKH_MINITEMS, prof_bt_hash,
prof_bt_keycomp)) prof_bt_keycomp))
return (true); return (true);
@ -1090,5 +1085,17 @@ prof_boot1(void)
return (false); return (false);
} }
void
prof_boot2(void)
{
if (opt_prof) {
/*
* Finish initializing prof_interval, now that narenas is set.
*/
prof_interval /= narenas;
}
}
/******************************************************************************/ /******************************************************************************/
#endif /* JEMALLOC_PROF */ #endif /* JEMALLOC_PROF */