refactors |mass in worker and daemon, enables MEMORY_LOG for both

This commit is contained in:
Joe Bryan 2019-07-10 00:21:26 -07:00
parent 29af62cae0
commit 785b3cc8ea
3 changed files with 54 additions and 28 deletions

1
pkg/urbit/configure vendored
View File

@ -18,6 +18,7 @@ defmacro () {
defmacro URBIT_VERSION "\"$URBIT_VERSION\""
[ -n "$MEMORY_DEBUG" ] && defmacro U3_MEMORY_DEBUG 1
[ -n "$MEMORY_LOG" ] && defmacro U3_MEMORY_LOG 1
[ -n "$CPU_DEBUG" ] && defmacro U3_CPU_DEBUG 1
[ -n "$EVENT_TIME_DEBUG" ] && defmacro U3_EVENT_TIME_DEBUG 1

View File

@ -921,18 +921,55 @@ u3_daemon_bail(void)
void
u3_daemon_grab(void* vod_p)
{
c3_w man_w = 0, pir_w = 0;
FILE* fil_u = u3_term_io_hija();
c3_w tot_w = 0;
FILE* fil_u;
c3_assert( u3R == &(u3H->rod_u) );
fprintf(fil_u, "measuring daemon:\r\n");
#ifdef U3_MEMORY_LOG
{
// XX date will not match up with that of the worker
//
u3_noun wen = u3dc("scot", c3__da, u3k(u3A->now));
c3_c* wen_c = u3r_string(wen);
man_w = u3m_mark(fil_u);
pir_w = u3_pier_mark(fil_u);
c3_c nam_c[2048];
snprintf(nam_c, 2048, "%s/.urb/put/mass", u3_pier_stub()->pax_c);
u3a_print_memory(fil_u, "total marked", man_w + pir_w);
struct stat st;
if ( -1 == stat(nam_c, &st) ) {
mkdir(nam_c, 0700);
}
c3_c man_c[2048];
snprintf(man_c, 2048, "%s/%s-daemon.txt", nam_c, wen_c);
fil_u = fopen(man_c, "w");
fprintf(fil_u, "%s\r\n", wen_c);
free(wen_c);
u3z(wen);
}
#else
{
fil_u = u3_term_io_hija();
fprintf(fil_u, "measuring daemon:\r\n");
}
#endif
tot_w += u3m_mark(fil_u);
tot_w += u3_pier_mark(fil_u);
u3a_print_memory(fil_u, "total marked", tot_w);
u3a_print_memory(fil_u, "sweep", u3a_sweep());
u3_term_io_loja(0);
#ifdef U3_MEMORY_LOG
{
fclose(fil_u);
}
#else
{
u3_term_io_loja(0);
}
#endif
}

View File

@ -264,8 +264,7 @@ _worker_grab(u3_noun sac, u3_noun ovo, u3_noun vir)
}
}
else {
c3_w usr_w = 0, man_w = 0, sac_w = 0, ova_w = 0, roe_w = 0, vir_w = 0;
c3_w tot_w = 0;
FILE* fil_u;
#ifdef U3_MEMORY_LOG
@ -282,7 +281,7 @@ _worker_grab(u3_noun sac, u3_noun ovo, u3_noun vir)
}
c3_c man_c[2048];
snprintf(man_c, 2048, "%s/%s.txt", nam_c, wen_c);
snprintf(man_c, 2048, "%s/%s-worker.txt", nam_c, wen_c);
fil_u = fopen(man_c, "w");
fprintf(fil_u, "%s\r\n", wen_c);
@ -297,27 +296,16 @@ _worker_grab(u3_noun sac, u3_noun ovo, u3_noun vir)
#endif
c3_assert( u3R == &(u3H->rod_u) );
fprintf(fil_u, "\r\n");
usr_w = _worker_prof(fil_u, 0, sac);
u3a_print_memory(fil_u, "total userspace", usr_w);
man_w = u3m_mark(fil_u);
sac_w = u3a_mark_noun(sac);
u3a_print_memory(fil_u, "space profile", sac_w);
ova_w = u3a_mark_noun(ovo);
u3a_print_memory(fil_u, "event", ova_w);
roe_w = u3a_mark_noun(u3V.roe);
u3a_print_memory(fil_u, "lifecycle events", roe_w);
vir_w = u3a_mark_noun(vir);
u3a_print_memory(fil_u, "effects", vir_w);
u3a_print_memory(fil_u, "total marked", usr_w + man_w + sac_w + ova_w + vir_w);
tot_w += u3a_maid(fil_u, "total userspace", _worker_prof(fil_u, 0, sac));
tot_w += u3m_mark(fil_u);
tot_w += u3a_maid(fil_u, "space profile", u3a_mark_noun(sac));
tot_w += u3a_maid(fil_u, "event", u3a_mark_noun(ovo));
tot_w += u3a_maid(fil_u, "lifecycle events", u3a_mark_noun(u3V.roe));
tot_w += u3a_maid(fil_u, "effects", u3a_mark_noun(vir));
u3a_print_memory(fil_u, "total marked", tot_w);
u3a_print_memory(fil_u, "sweep", u3a_sweep());
#ifdef U3_MEMORY_LOG