Merge pull request #5295 from urbit/jb/serf-whey

vere: updates worker memory measurement to include full profile
This commit is contained in:
Joe Bryan 2021-10-04 10:09:26 -07:00 committed by GitHub
commit 6c43748f2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 12 deletions

Binary file not shown.

View File

@ -1236,6 +1236,7 @@
# define c3__werp c3_s4('w','e','r','p') # define c3__werp c3_s4('w','e','r','p')
# define c3__west c3_s4('w','e','s','t') # define c3__west c3_s4('w','e','s','t')
# define c3__what c3_s4('w','h','a','t') # define c3__what c3_s4('w','h','a','t')
# define c3__whey c3_s4('w','h','e','y')
# define c3__whom c3_s4('w','h','o','m') # define c3__whom c3_s4('w','h','o','m')
# define c3__wing c3_s4('w','i','n','g') # define c3__wing c3_s4('w','i','n','g')
# define c3__wild c3_s4('w','i','l','d') # define c3__wild c3_s4('w','i','l','d')

View File

@ -340,6 +340,7 @@ _cw_grab(c3_i argc, c3_c* argv[])
c3_c* dir_c = argv[2]; c3_c* dir_c = argv[2];
u3m_boot(dir_c); u3m_boot(dir_c);
u3C.wag_w |= u3o_hashless;
u3_serf_grab(); u3_serf_grab();
u3m_stop(); u3m_stop();
} }
@ -422,6 +423,7 @@ _cw_meld(c3_i argc, c3_c* argv[])
c3_c* dir_c = argv[2]; c3_c* dir_c = argv[2];
u3C.wag_w |= u3o_hashless;
u3m_boot(dir_c); u3m_boot(dir_c);
u3_serf_grab(); u3_serf_grab();

View File

@ -183,11 +183,11 @@ _serf_prof(FILE* fil_u, c3_w den, u3_noun mas)
/* _serf_grab(): garbage collect, checking for profiling. RETAIN. /* _serf_grab(): garbage collect, checking for profiling. RETAIN.
*/ */
static void static void
_serf_grab(u3_serf* sef_u) _serf_grab(u3_noun sac)
{ {
if ( u3_nul == sef_u->sac) { if ( u3_nul == sac) {
if ( u3C.wag_w & (u3o_debug_ram | u3o_check_corrupt) ) { if ( u3C.wag_w & (u3o_debug_ram | u3o_check_corrupt) ) {
u3m_grab(sef_u->sac, u3_none); u3m_grab(sac, u3_none);
} }
} }
else { else {
@ -225,9 +225,9 @@ _serf_grab(u3_serf* sef_u)
c3_assert( u3R == &(u3H->rod_u) ); c3_assert( u3R == &(u3H->rod_u) );
fprintf(fil_u, "\r\n"); fprintf(fil_u, "\r\n");
tot_w += u3a_maid(fil_u, "total userspace", _serf_prof(fil_u, 0, sef_u->sac)); tot_w += u3a_maid(fil_u, "total userspace", _serf_prof(fil_u, 0, sac));
tot_w += u3m_mark(fil_u); tot_w += u3m_mark(fil_u);
tot_w += u3a_maid(fil_u, "space profile", u3a_mark_noun(sef_u->sac)); tot_w += u3a_maid(fil_u, "space profile", u3a_mark_noun(sac));
u3a_print_memory(fil_u, "total marked", tot_w); u3a_print_memory(fil_u, "total marked", tot_w);
u3a_print_memory(fil_u, "free lists", u3a_idle(u3R)); u3a_print_memory(fil_u, "free lists", u3a_idle(u3R));
@ -241,8 +241,7 @@ _serf_grab(u3_serf* sef_u)
} }
#endif #endif
u3z(sef_u->sac); u3z(sac);
sef_u->sac = u3_nul;
u3l_log("\n"); u3l_log("\n");
} }
@ -253,13 +252,49 @@ _serf_grab(u3_serf* sef_u)
void void
u3_serf_grab(void) u3_serf_grab(void)
{ {
u3_noun sac = u3_nul;
c3_assert( u3R == &(u3H->rod_u) ); c3_assert( u3R == &(u3H->rod_u) );
{
u3_noun sam, gon;
{
u3_noun pax = u3nc(c3__whey, u3_nul);
u3_noun lyc = u3nc(u3_nul, u3_nul);
sam = u3nt(lyc, c3n, u3nq(c3__once, u3_blip, u3_blip, pax));
}
gon = u3m_soft(0, u3v_peek, sam);
{
u3_noun tag, dat, val;
u3x_cell(gon, &tag, &dat);
if ( (u3_blip == tag)
&& (u3_nul != dat)
&& (c3y == u3r_pq(u3t(dat), c3__omen, 0, &val))
&& (c3y == u3r_p(val, c3__mass, &sac)) )
{
u3k(sac);
}
}
u3z(gon);
}
fprintf(stderr, "serf: measuring memory:\r\n"); fprintf(stderr, "serf: measuring memory:\r\n");
u3a_print_memory(stderr, "total marked", u3m_mark(stderr));
u3a_print_memory(stderr, "free lists", u3a_idle(u3R)); if ( u3_nul != sac ) {
u3a_print_memory(stderr, "sweep", u3a_sweep()); _serf_grab(sac);
fprintf(stderr, "\r\n"); }
else {
u3a_print_memory(stderr, "total marked", u3m_mark(stderr));
u3a_print_memory(stderr, "free lists", u3a_idle(u3R));
u3a_print_memory(stderr, "sweep", u3a_sweep());
fprintf(stderr, "\r\n");
}
fflush(stderr); fflush(stderr);
} }
@ -276,7 +311,8 @@ u3_serf_post(u3_serf* sef_u)
// XX this runs on replay too, |mass s/b elsewhere // XX this runs on replay too, |mass s/b elsewhere
// //
if ( c3y == sef_u->mut_o ) { if ( c3y == sef_u->mut_o ) {
_serf_grab(sef_u); _serf_grab(sef_u->sac);
sef_u->sac = u3_nul;
sef_u->mut_o = c3n; sef_u->mut_o = c3n;
} }