diff --git a/include/noun/allocate.h b/include/noun/allocate.h index 32a8e8d37a..19c2c7d1a8 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -402,6 +402,11 @@ c3_w u3a_mark_noun(u3_noun som); + /* u3a_mark_road(): mark ad-hoc persistent road structures. + */ + c3_w + u3a_mark_road(c3_o pri_o); + /* u3a_sweep(): sweep a fully marked road. */ c3_w @@ -422,11 +427,16 @@ void u3a_lop(c3_w lab_w); - /* u3a_print_memory: print memory amount. + /* u3a_print_memory(): print memory amount. */ void u3a_print_memory(c3_c* cap_c, c3_w wor_w); + /* u3a_maid(): maybe print memory. + */ + c3_w + u3a_maid(c3_o pri_o, c3_c* cap_c, c3_w wor_w); + /* u3a_deadbeef(): write 0xdeadbeef from hat to cap. */ void diff --git a/include/noun/jets.h b/include/noun/jets.h index 16c318c29e..fcfd345867 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -260,7 +260,7 @@ /* u3j_mark(): mark jet state for gc. */ c3_w - u3j_mark(void); + u3j_mark(c3_o pri_o); /* u3j_free(): free jet state. */ diff --git a/include/noun/manage.h b/include/noun/manage.h index eb11e9401d..14619f2bd7 100644 --- a/include/noun/manage.h +++ b/include/noun/manage.h @@ -94,7 +94,7 @@ /* u3m_mark(): mark all nouns in the road. */ c3_w - u3m_mark(void); + u3m_mark(c3_o pri_o); /* u3m_grab(): garbage-collect the world, plus extra roots. */ diff --git a/include/noun/nock.h b/include/noun/nock.h index ff376a875a..087ef802fe 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -110,7 +110,7 @@ /* u3n_mark(): mark bytecode cache. */ c3_w - u3n_mark(void); + u3n_mark(c3_o pri_o); /* u3n_free(): free bytecode cache. */ diff --git a/include/noun/vortex.h b/include/noun/vortex.h index dfb7e8bae4..bcee4b636a 100644 --- a/include/noun/vortex.h +++ b/include/noun/vortex.h @@ -147,4 +147,4 @@ /* u3v_mark(): mark arvo kernel. */ c3_w - u3v_mark(void); + u3v_mark(c3_o pri_o); diff --git a/noun/allocate.c b/noun/allocate.c index 7f22724396..fabc3bf3f4 100644 --- a/noun/allocate.c +++ b/noun/allocate.c @@ -1614,12 +1614,12 @@ u3a_mark_noun(u3_noun som) } /* u3a_print_memory: print memory amount. +** +** Must print to stderr -- not uH/uL (because loja allocates). */ void u3a_print_memory(c3_c* cap_c, c3_w wor_w) { - FILE *fil_f = u3_term_io_hija(); - c3_w byt_w = (wor_w * 4); c3_w gib_w = (byt_w / 1000000000); c3_w mib_w = (byt_w % 1000000000) / 1000000; @@ -1628,20 +1628,46 @@ u3a_print_memory(c3_c* cap_c, c3_w wor_w) if ( byt_w ) { if ( gib_w ) { - fprintf(fil_f, "%s: GB/%d.%03d.%03d.%03d\r\n", + fprintf(stderr, "%s: GB/%d.%03d.%03d.%03d\r\n", cap_c, gib_w, mib_w, kib_w, bib_w); } else if ( mib_w ) { - fprintf(fil_f, "%s: MB/%d.%03d.%03d\r\n", cap_c, mib_w, kib_w, bib_w); + fprintf(stderr, "%s: MB/%d.%03d.%03d\r\n", cap_c, mib_w, kib_w, bib_w); } else if ( kib_w ) { - fprintf(fil_f, "%s: KB/%d.%03d\r\n", cap_c, kib_w, bib_w); + fprintf(stderr, "%s: KB/%d.%03d\r\n", cap_c, kib_w, bib_w); } else if ( bib_w ) { - fprintf(fil_f, "%s: B/%d\r\n", cap_c, bib_w); + fprintf(stderr, "%s: B/%d\r\n", cap_c, bib_w); } } - u3_term_io_loja(0); +} + +/* u3a_maid(): maybe print memory. +*/ +c3_w +u3a_maid(c3_o pri_o, c3_c* cap_c, c3_w wor_w) +{ + if ( c3y == pri_o ) { + u3a_print_memory(cap_c, wor_w); + } + return wor_w; +} + +/* u3a_mark_road(): mark ad-hoc persistent road structures. +*/ +c3_w +u3a_mark_road(c3_o pri_o) +{ + c3_w tot_w = 0; + tot_w += u3a_maid(pri_o, " namespace", u3a_mark_noun(u3R->ski.gul)); + tot_w += u3a_maid(pri_o, " trace stack", u3a_mark_noun(u3R->bug.tax)); + tot_w += u3a_maid(pri_o, " trace buffer", u3a_mark_noun(u3R->bug.mer)); + tot_w += u3a_maid(pri_o, " profile batteries", u3a_mark_noun(u3R->pro.don)); + tot_w += u3a_maid(pri_o, " profile doss", u3a_mark_noun(u3R->pro.day)); + tot_w += u3a_maid(pri_o, " new profile trace", u3a_mark_noun(u3R->pro.trace)); + tot_w += u3a_maid(pri_o, " memoization cache", u3h_mark(u3R->cax.har_p)); + return u3a_maid(pri_o, "total road stuff", tot_w); } /* u3a_sweep(): sweep a fully marked road. diff --git a/noun/jets.c b/noun/jets.c index 67b15dccbf..8f887067ef 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -2250,18 +2250,26 @@ _cj_mark_hank(u3_noun kev, void* dat) /* u3j_mark(): mark jet state for gc. */ c3_w -u3j_mark(void) +u3j_mark(c3_o pri_o) { c3_w tot_w = 0; - tot_w += u3h_mark(u3R->jed.war_p); - tot_w += u3h_mark(u3R->jed.cod_p); - tot_w += u3h_mark(u3R->jed.han_p); - tot_w += u3h_mark(u3R->jed.bas_p); - u3h_walk_with(u3R->jed.han_p, _cj_mark_hank, &tot_w); - if ( u3R == &(u3H->rod_u) ) { - tot_w += u3h_mark(u3R->jed.hot_p); + + tot_w += u3a_maid(pri_o, " warm jet state", u3h_mark(u3R->jed.war_p)); + tot_w += u3a_maid(pri_o, " cold jet state", u3h_mark(u3R->jed.cod_p)); + tot_w += u3a_maid(pri_o, " hank cache", u3h_mark(u3R->jed.han_p)); + tot_w += u3a_maid(pri_o, " battery hash cache", u3h_mark(u3R->jed.bas_p)); + + { + c3_w han_w = 0; + u3h_walk_with(u3R->jed.han_p, _cj_mark_hank, &han_w); + tot_w += u3a_maid(pri_o, " call site cache", han_w); } - return tot_w; + + if ( u3R == &(u3H->rod_u) ) { + tot_w += u3a_maid(pri_o, " hot jet state", u3h_mark(u3R->jed.hot_p)); + } + + return u3a_maid(pri_o, "total jet stuff", tot_w); } /* _cj_free_hank(): free hank cache. diff --git a/noun/manage.c b/noun/manage.c index 7d3517da33..2a1d2576c3 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -491,18 +491,13 @@ _pave_parts(void) /* u3m_mark(): mark all nouns in the road. */ c3_w -u3m_mark(void) +u3m_mark(c3_o pri_o) { c3_w tot_w = 0; - tot_w += u3j_mark(); - tot_w += u3n_mark(); - tot_w += u3a_mark_noun(u3R->ski.gul); - tot_w += u3a_mark_noun(u3R->bug.tax); - tot_w += u3a_mark_noun(u3R->bug.mer); - tot_w += u3a_mark_noun(u3R->pro.don); - tot_w += u3a_mark_noun(u3R->pro.trace); - tot_w += u3a_mark_noun(u3R->pro.day); - tot_w += u3h_mark(u3R->cax.har_p); + tot_w += u3v_mark(pri_o); + tot_w += u3j_mark(pri_o); + tot_w += u3n_mark(pri_o); + tot_w += u3a_mark_road(pri_o); return tot_w; } @@ -1151,8 +1146,7 @@ u3m_grab(u3_noun som, ...) // terminate with u3_none // u3h_free(u3R->cax.har_p); // u3R->cax.har_p = u3h_new(); - u3v_mark(); - u3m_mark(); + u3m_mark(c3n); { va_list vap; u3_noun tur; diff --git a/noun/nock.c b/noun/nock.c index a0affa029c..aa7472d0d0 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -2556,12 +2556,15 @@ _n_bam(u3_noun kev, void* dat) /* u3n_mark(): mark the bytecode cache for gc. */ c3_w -u3n_mark() +u3n_mark(c3_o pri_o) { - c3_w bam_w = 0; + c3_w bam_w = 0, har_w = 0; u3p(u3h_root) har_p = u3R->byc.har_p; u3h_walk_with(har_p, _n_bam, &bam_w); - return bam_w + u3h_mark(har_p); + + bam_w = u3a_maid(pri_o, " bytecode programs", bam_w); + har_w = u3a_maid(pri_o, " bytecode cache", u3h_mark(har_p)); + return u3a_maid(pri_o, "total nock stuff", bam_w + har_w); } /* _n_feb(): u3h_walk helper for u3n_bree diff --git a/noun/vortex.c b/noun/vortex.c index b9a1cc5d47..b1aee1f7e6 100644 --- a/noun/vortex.c +++ b/noun/vortex.c @@ -405,24 +405,19 @@ _cv_mark_ova(u3p(u3v_cart) egg_p) /* u3v_mark(): mark arvo kernel. */ c3_w -u3v_mark(void) +u3v_mark(c3_o pri_o) { + u3v_arvo* arv_u = &(u3H->arv_u); c3_w tot_w = 0; - u3v_arvo* arv_u = &(u3H->arv_u); - - tot_w += u3a_mark_noun(arv_u->yot); - tot_w += u3a_mark_noun(arv_u->now); - tot_w += u3a_mark_noun(arv_u->wen); - tot_w += u3a_mark_noun(arv_u->sen); - tot_w += u3a_mark_noun(arv_u->own); - - tot_w += u3a_mark_noun(arv_u->roe); - tot_w += u3a_mark_noun(arv_u->key); - - tot_w += u3a_mark_noun(arv_u->roc); - - tot_w += _cv_mark_ova(arv_u->ova.egg_p); - - return tot_w; + tot_w += u3a_maid(pri_o, " wish cache", u3a_mark_noun(arv_u->yot)); + tot_w += u3a_maid(pri_o, " date", u3a_mark_noun(arv_u->now)); + tot_w += u3a_maid(pri_o, " formatted date", u3a_mark_noun(arv_u->wen)); + tot_w += u3a_maid(pri_o, " instance string", u3a_mark_noun(arv_u->sen)); + tot_w += u3a_maid(pri_o, " identity", u3a_mark_noun(arv_u->own)); + tot_w += u3a_maid(pri_o, " pending events", u3a_mark_noun(arv_u->roe)); + tot_w += u3a_maid(pri_o, " event-log key", u3a_mark_noun(arv_u->key)); + tot_w += u3a_maid(pri_o, " kernel", u3a_mark_noun(arv_u->roc)); + tot_w += u3a_maid(pri_o, " egg basket", _cv_mark_ova(arv_u->ova.egg_p)); + return u3a_maid(pri_o, "total arvo stuff", tot_w); } diff --git a/vere/raft.c b/vere/raft.c index e86c90151e..1f6830aae6 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1865,7 +1865,7 @@ _raft_grab(u3_noun ova) fprintf(stderr, "space profile: "); _raft_print_memory(sac_w); - utv_w = u3v_mark(); + utv_w = u3v_mark(c3n); fprintf(stderr, "arvo stuff: "); _raft_print_memory(utv_w);