From b84aa72678882508bcaa33d0ab8636b387ed4320 Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Thu, 7 May 2015 19:16:54 -0400 Subject: [PATCH 01/12] checkpoint --- i/n/a.h | 8 ++++-- i/n/h.h | 2 +- i/n/m.h | 5 ++++ i/n/v.h | 2 +- n/a.c | 8 ++++-- n/h.c | 37 +++++++++++++++--------- n/m.c | 30 ++++++++++--------- n/v.c | 36 ++++++++++++++--------- v/loop.c | 1 + v/reck.c | 87 +++++++++++++++++++++++++++++++++++++++++--------------- 10 files changed, 145 insertions(+), 71 deletions(-) diff --git a/i/n/a.h b/i/n/a.h index 541e24e5f..d7a68dd6d 100644 --- a/i/n/a.h +++ b/i/n/a.h @@ -6,7 +6,7 @@ **/ /* U3_MEMORY_DEBUG: add debugging information to heap. Breaks image. */ -# undef U3_MEMORY_DEBUG +# define U3_MEMORY_DEBUG /** Constants. @@ -264,6 +264,10 @@ c3_global c3_w u3_Code; #endif + /* u3_Prof: memory profile. + */ + c3_global u3_weak u3_Prof; + # define u3_Loom ((c3_w *)(void *)U3_OS_LoomBase) /** Functions. @@ -378,7 +382,7 @@ /* u3a_sweep(): sweep a fully marked road. */ - void + c3_w u3a_sweep(void); /* u3a_sane(): check allocator sanity. diff --git a/i/n/h.h b/i/n/h.h index 0c1d7da96..91c6dba27 100644 --- a/i/n/h.h +++ b/i/n/h.h @@ -118,7 +118,7 @@ /* u3h_mark(): mark hashtable for gc. */ - void + c3_w u3h_mark(u3p(u3h_root) har_p); /* u3h_walk(): traverse hashtable with key, value fn; RETAINS. diff --git a/i/n/m.h b/i/n/m.h index 158805e7c..0495b4d0e 100644 --- a/i/n/m.h +++ b/i/n/m.h @@ -81,6 +81,11 @@ u3_noun u3m_soft_esc(u3_noun sam); + /* u3m_mark(): mark all nouns in the road. + */ + c3_w + u3m_mark(void); + /* u3m_grab(): garbage-collect the world, plus extra roots. */ void diff --git a/i/n/v.h b/i/n/v.h index 51873be47..f4b9de51d 100644 --- a/i/n/v.h +++ b/i/n/v.h @@ -169,5 +169,5 @@ /* u3v_mark(): mark arvo kernel. */ - void + c3_w u3v_mark(void); diff --git a/n/a.c b/n/a.c index 7d505b8d8..2d336dd1f 100644 --- a/n/a.c +++ b/n/a.c @@ -1415,7 +1415,7 @@ u3a_print_memory(c3_c* cap_c, c3_w wor_w) /* u3a_sweep(): sweep a fully marked road. */ -void +c3_w u3a_sweep(void) { c3_w neg_w, pos_w, leq_w, weq_w; @@ -1471,7 +1471,7 @@ u3a_sweep(void) (u3_noun)u3a_to_pom(u3a_outa(u3a_boxto(box_w))), ((u3a_noun *)(u3a_boxto(box_w)))->mug_w, box_u->use_w, box_u->eus_w); - u3m_p("weak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); + // u3m_p("weak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); } weq_w += box_u->siz_w; } @@ -1483,7 +1483,7 @@ u3a_sweep(void) ? ((u3a_noun *)(u3a_boxto(box_w)))->mug_w : u3r_mug(u3a_to_pom(u3a_outa(u3a_boxto(box_w)))), box_u->use_w); - u3m_p("leak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); + // u3m_p("leak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); leq_w += box_u->siz_w; } if ( box_u->cod_w ) { @@ -1534,6 +1534,8 @@ u3a_sweep(void) c3_assert((pos_w + leq_w + weq_w) == neg_w); if ( 0 != leq_w || (0 != weq_w) ) { c3_assert(0); } + + return neg_w; } /* u3a_slab(): create a length-bounded proto-atom. diff --git a/n/h.c b/n/h.c index 698c2f29d..3808c0408 100644 --- a/n/h.c +++ b/n/h.c @@ -631,22 +631,26 @@ u3h_walk(u3p(u3h_root) har_p, void (*fun_f)(u3_noun)) /* _ch_mark_buck(): mark bucket for gc. */ -static void +c3_w _ch_mark_buck(u3h_buck* hab_u) { - c3_w i_w; + c3_w tot_w = 0; + c3_w i_w; for ( i_w = 0; i_w < hab_u->len_w; i_w++ ) { - u3a_mark_noun(hab_u->kev[i_w]); + tot_w += u3a_mark_noun(hab_u->kev[i_w]); } - u3a_mark_ptr(hab_u); + tot_w += u3a_mark_ptr(hab_u); + + return tot_w; } /* _ch_mark_node(): mark node for gc. */ -static void +c3_w _ch_mark_node(u3h_node* han_u, c3_w lef_w) { + c3_w tot_w = 0; c3_w len_w = _ch_popcount(han_u->map_w); c3_w i_w; @@ -658,26 +662,30 @@ _ch_mark_node(u3h_node* han_u, c3_w lef_w) if ( _(u3h_slot_is_noun(sot_w)) ) { u3_noun kev = u3h_slot_to_noun(sot_w); - u3a_mark_noun(kev); + tot_w += u3a_mark_noun(kev); } else { void* hav_v = u3h_slot_to_node(sot_w); if ( 0 == lef_w ) { - _ch_mark_buck(hav_v); + tot_w += _ch_mark_buck(hav_v); } else { - _ch_mark_node(hav_v, lef_w); + tot_w += _ch_mark_node(hav_v, lef_w); } } } - u3a_mark_ptr(han_u); + + tot_w += u3a_mark_ptr(han_u); + + return tot_w; } /* u3h_mark(): mark hashtable for gc. */ -void +c3_w u3h_mark(u3p(u3h_root) har_p) { + c3_w tot_w = 0; u3h_root* har_u = u3to(u3h_root, har_p); c3_w i_w; @@ -687,13 +695,16 @@ u3h_mark(u3p(u3h_root) har_p) if ( _(u3h_slot_is_noun(sot_w)) ) { u3_noun kev = u3h_slot_to_noun(sot_w); - u3a_mark_noun(kev); + tot_w += u3a_mark_noun(kev); } else if ( _(u3h_slot_is_node(sot_w)) ) { u3h_node* han_u = u3h_slot_to_node(sot_w); - _ch_mark_node(han_u, 25); + tot_w += _ch_mark_node(han_u, 25); } } - u3a_mark_ptr(har_u); + + tot_w += u3a_mark_ptr(har_u); + + return tot_w; } diff --git a/n/m.c b/n/m.c index d99f6872d..d1259416e 100644 --- a/n/m.c +++ b/n/m.c @@ -30,11 +30,6 @@ void u3m_dump(void); - /* u3m_mark(): mark all nouns in the road. - */ - void - u3m_mark(void); - /* u3m_fall(): return to parent road. */ void @@ -462,17 +457,19 @@ _pave_parts(void) /* u3m_mark(): mark all nouns in the road. */ -void +c3_w u3m_mark(void) { - u3h_mark(u3R->jed.har_p); - u3a_mark_noun(u3R->jed.das); - u3a_mark_noun(u3R->ski.flu); - u3a_mark_noun(u3R->bug.tax); - u3a_mark_noun(u3R->bug.mer); - u3a_mark_noun(u3R->pro.don); - u3a_mark_noun(u3R->pro.day); - u3h_mark(u3R->cax.har_p); + c3_w tot_w = 0; + tot_w += u3h_mark(u3R->jed.har_p); + tot_w += u3a_mark_noun(u3R->jed.das); + tot_w += u3a_mark_noun(u3R->ski.flu); + 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.day); + tot_w += u3h_mark(u3R->cax.har_p); + return tot_w; } /* _cm_pave(): instantiate or activate image. @@ -872,6 +869,11 @@ u3m_soft_top(c3_w sec_w, // timer seconds /* Make sure the inner routine did not create garbage. */ if ( u3C.wag_w & u3o_debug_ram ) { + if ( u3_none != u3_Prof ) { + fprintf(stderr,"should be checking!\r\n"); + u3z(u3_Prof); + u3_Prof = u3_none; + } u3m_grab(pro, u3_none); } diff --git a/n/v.c b/n/v.c index a9a6bef88..221edeb3a 100644 --- a/n/v.c +++ b/n/v.c @@ -490,37 +490,45 @@ u3v_louse(c3_m how_m) /* _cv_mark_ova(): mark ova queue. */ -static void +c3_w _cv_mark_ova(u3p(u3v_cart) egg_p) { + c3_w tot_w = 0; + while ( egg_p ) { u3v_cart* egg_u = u3to(u3v_cart, egg_p); - u3a_mark_mptr(egg_u); - u3a_mark_noun(egg_u->vir); + tot_w += u3a_mark_mptr(egg_u); + tot_w += u3a_mark_noun(egg_u->vir); egg_p = egg_u->nex_p; } + + return tot_w; } /* u3v_mark(): mark arvo kernel. */ -void +c3_w u3v_mark(void) { + c3_w tot_w = 0; + u3v_arvo* arv_u = &(u3H->arv_u); - u3a_mark_noun(arv_u->yot); - u3a_mark_noun(arv_u->now); - u3a_mark_noun(arv_u->wen); - u3a_mark_noun(arv_u->sen); - u3a_mark_noun(arv_u->own); + 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); - u3a_mark_noun(arv_u->roe); - u3a_mark_noun(arv_u->key); + tot_w += u3a_mark_noun(arv_u->roe); + tot_w += u3a_mark_noun(arv_u->key); - u3a_mark_noun(arv_u->ken); - u3a_mark_noun(arv_u->roc); + tot_w += u3a_mark_noun(arv_u->ken); + tot_w += u3a_mark_noun(arv_u->roc); - _cv_mark_ova(arv_u->ova.egg_p); + tot_w += _cv_mark_ova(arv_u->ova.egg_p); + + return tot_w; } diff --git a/v/loop.c b/v/loop.c index 8103518f8..295b20c73 100644 --- a/v/loop.c +++ b/v/loop.c @@ -420,6 +420,7 @@ u3_lo_open(void) // // Assumption: there are no noun roots outside u3A. // + u3_Prof = u3_none; u3m_grab(u3_none); } #if 0 diff --git a/v/reck.c b/v/reck.c index 7d4a6eac4..2a955d6af 100644 --- a/v/reck.c +++ b/v/reck.c @@ -71,7 +71,7 @@ _reck_lily(u3_noun fot, u3_noun txt, c3_l* tid_l) void _reck_spac(c3_w n) { for (; n > 0; n--) - uL(fprintf(uH," ")); + (fprintf(stderr," ")); } /* _reck_print_memory: print memory amount. cf u3a_print_memory(). @@ -86,17 +86,17 @@ _reck_print_memory(c3_w wor_w) c3_w bib_w = (byt_w % 1000); if ( gib_w ) { - uL(fprintf(uH, "GB/%d.%03d.%03d.%03d\r\n", + (fprintf(stderr, "GB/%d.%03d.%03d.%03d\r\n", gib_w, mib_w, kib_w, bib_w)); } else if ( mib_w ) { - uL(fprintf(uH, "MB/%d.%03d.%03d\r\n", mib_w, kib_w, bib_w)); + (fprintf(stderr, "MB/%d.%03d.%03d\r\n", mib_w, kib_w, bib_w)); } else if ( kib_w ) { - uL(fprintf(uH, "KB/%d.%03d\r\n", kib_w, bib_w)); + (fprintf(stderr, "KB/%d.%03d\r\n", kib_w, bib_w)); } else { - uL(fprintf(uH, "B/%d\r\n", bib_w)); + (fprintf(stderr, "B/%d\r\n", bib_w)); } } @@ -105,10 +105,12 @@ _reck_print_memory(c3_w wor_w) c3_w _reck_meme_noun(u3p(u3h_root) hax, u3_noun non, c3_t dud) { + return 0; + /* u3_weak got = u3h_git(hax, dud ? non & 0x7fffffff : non); if (u3_none != got) { - return 0; // I think? maybe 1 + return 1; } else { c3_w res; @@ -117,10 +119,10 @@ _reck_meme_noun(u3p(u3h_root) hax, u3_noun non, c3_t dud) res = 1; } if (_(u3ud(non))) { - res = 2 + u3r_met(5, non); + res = 3 + 3 + u3r_met(5, non); } else { - res = 1 + res = 3 + 2 + _reck_meme_noun(hax, u3h(non), dud) + _reck_meme_noun(hax, u3t(non), dud); } @@ -129,25 +131,40 @@ _reck_meme_noun(u3p(u3h_root) hax, u3_noun non, c3_t dud) return res; } + */ +} + +/* _reck_noun_grab(): get memory usage, in words, of noun from GC. RETAIN. + * XXX what about unmarking stuff? what's a GC cycle? +*/ +c3_w +_reck_noun_grab(u3_noun non) +{ + return u3a_mark_noun(non); } /* _reck_meme_prof(): print memory profile. RETAIN. */ -void +c3_w _reck_meme_prof(u3p(u3h_root) hax, c3_w den, u3_noun mas) { + c3_w tot_w = 0; u3_noun h_mas, t_mas; if (c3n == u3r_cell(mas, &h_mas, &t_mas)) { _reck_spac(den); - uL(fprintf(uH, "mistyped mass\r\n")); - return; + (fprintf(stderr, "mistyped mass\r\n")); + return tot_w; } if (c3y == h_mas) { _reck_spac(den); _reck_print_memory(_reck_meme_noun(hax, t_mas, false)); _reck_spac(den); _reck_print_memory(_reck_meme_noun(hax, t_mas, true)); + _reck_spac(den); + tot_w += _reck_noun_grab(t_mas); + _reck_print_memory(tot_w); + return tot_w; } else if (c3n == h_mas) { u3_noun it_mas, tt_mas, pit_mas, qit_mas; @@ -155,28 +172,29 @@ _reck_meme_prof(u3p(u3h_root) hax, c3_w den, u3_noun mas) { _reck_spac(den); if (c3n == u3r_cell(t_mas, &it_mas, &tt_mas)) { - uL(fprintf(uH, "mistyped mass list\r\n")); - return; + (fprintf(stderr, "mistyped mass list\r\n")); + return tot_w; } else if (c3n == u3r_cell(it_mas, &pit_mas, &qit_mas)) { - uL(fprintf(uH, "mistyped mass list element\r\n")); - return; + (fprintf(stderr, "mistyped mass list element\r\n")); + return tot_w; } else { c3_c* pit_c = u3m_pretty(pit_mas); - uL(fprintf(uH, "%s\r\n", pit_c)); + (fprintf(stderr, "%s\r\n", pit_c)); free(pit_c); - _reck_meme_prof(hax, den+2, qit_mas); + tot_w += _reck_meme_prof(hax, den+2, qit_mas); t_mas = tt_mas; } } + return tot_w; } else { _reck_spac(den); - uL(fprintf(uH, "mistyped mass head\r\n")); - return; + (fprintf(stderr, "mistyped mass head\r\n")); + return tot_w; } } @@ -227,13 +245,36 @@ _reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav) case c3__mass: p_fav = u3t(fav); { - uL(fprintf(uH, "memory profile:\r\n")); + u3_Prof = u3k(p_fav); + //c3_w usr_w, utm_w, utv_w, ext_w, wep_w; + //uL(fprintf(uH, "memory profile:\r\n")); - u3p(u3h_root) hax = u3h_new(); + //// u3p(u3h_root) hax = u3h_new(); - _reck_meme_prof(hax, 0, p_fav); + //usr_w = _reck_meme_prof(u3_nul, 0, p_fav); + //(fprintf(stderr, "total userspace: ")); + //_reck_print_memory(usr_w); - u3h_free(hax); + //utm_w = u3m_mark(); + //(fprintf(stderr, "u3m stuff: ")); + //_reck_print_memory(utm_w); + + //utv_w = u3v_mark(); + //(fprintf(stderr, "u3v stuff: ")); + //_reck_print_memory(utv_w); + + //ext_w = u3a_mark_noun(pox) + u3a_mark_noun(fav); + //(fprintf(stderr, "extra stuff: ")); + //_reck_print_memory(ext_w); + + //(fprintf(stderr, "total memory: ")); + //_reck_print_memory(usr_w + utm_w + utv_w + ext_w); + + //wep_w = u3a_sweep(); + //(fprintf(stderr, "sweep memory: ")); + //_reck_print_memory(wep_w); + + //// u3h_free(hax); u3z(pox); u3z(fav); return c3y; } break; From 3155535c80ed2401f7f9040fa0aed730f2eae013 Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Fri, 8 May 2015 20:42:09 -0400 Subject: [PATCH 02/12] space profiling works with U3_MEMORY_DEBUG --- i/n/a.h | 6 +- i/n/v.h | 2 + n/a.c | 19 ++++-- n/h.c | 2 +- n/m.c | 5 -- n/v.c | 1 + v/loop.c | 1 - v/raft.c | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ v/reck.c | 165 +--------------------------------------------- 9 files changed, 216 insertions(+), 179 deletions(-) diff --git a/i/n/a.h b/i/n/a.h index d7a68dd6d..207c0e0de 100644 --- a/i/n/a.h +++ b/i/n/a.h @@ -6,7 +6,7 @@ **/ /* U3_MEMORY_DEBUG: add debugging information to heap. Breaks image. */ -# define U3_MEMORY_DEBUG +# undef U3_MEMORY_DEBUG /** Constants. @@ -264,10 +264,6 @@ c3_global c3_w u3_Code; #endif - /* u3_Prof: memory profile. - */ - c3_global u3_weak u3_Prof; - # define u3_Loom ((c3_w *)(void *)U3_OS_LoomBase) /** Functions. diff --git a/i/n/v.h b/i/n/v.h index f4b9de51d..e750c45b2 100644 --- a/i/n/v.h +++ b/i/n/v.h @@ -27,6 +27,8 @@ u3_noun sen; // instance string u3_noun own; // owner list + u3_noun sac; // space profiling + u3_noun roe; // temporary unsaved events u3_noun key; // log key, or 0 diff --git a/n/a.c b/n/a.c index 2d336dd1f..3e4dc40a0 100644 --- a/n/a.c +++ b/n/a.c @@ -1310,9 +1310,13 @@ u3a_mark_ptr(void* ptr_v) c3_w siz_w; #ifdef U3_MEMORY_DEBUG - if ( box_u->eus_w == 0 ) { + if ( 0 == box_u->eus_w ) { siz_w = box_u->siz_w; - } + } + else if ( 0xffffffff == box_u->eus_w ) { // see _raft_prof() + siz_w = 0xffffffff; + box_u->eus_w = 0; + } else { siz_w = 0; } @@ -1331,6 +1335,10 @@ u3a_mark_ptr(void* ptr_v) use_ws -= 1; siz_w = 0; } + // else if ( 0x80000000 == (c3_w)use_ws ) { // see _raft_prof() + // use_ws = -1; + // siz_w = 0xffffffff; + // } else { use_ws = -1; siz_w = box_u->siz_w; @@ -1370,7 +1378,7 @@ u3a_mark_noun(u3_noun som) c3_w* dog_w = u3a_to_ptr(som); c3_w new_w = u3a_mark_ptr(dog_w); - if ( 0 == new_w ) { + if ( 0 == new_w || 0xffffffff == new_w ) { // see u3a_mark_ptr() return siz_w; } else { @@ -1471,7 +1479,10 @@ u3a_sweep(void) (u3_noun)u3a_to_pom(u3a_outa(u3a_boxto(box_w))), ((u3a_noun *)(u3a_boxto(box_w)))->mug_w, box_u->use_w, box_u->eus_w); - // u3m_p("weak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); + //static int xuc_i = 0; + //if ( 2 != ++xuc_i && 3 != xuc_i ) { + // u3m_p("weak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); + //} } weq_w += box_u->siz_w; } diff --git a/n/h.c b/n/h.c index 3808c0408..8919f9d2b 100644 --- a/n/h.c +++ b/n/h.c @@ -634,7 +634,7 @@ u3h_walk(u3p(u3h_root) har_p, void (*fun_f)(u3_noun)) c3_w _ch_mark_buck(u3h_buck* hab_u) { - c3_w tot_w = 0; + c3_w tot_w = 0; c3_w i_w; for ( i_w = 0; i_w < hab_u->len_w; i_w++ ) { diff --git a/n/m.c b/n/m.c index d1259416e..d9db52f6d 100644 --- a/n/m.c +++ b/n/m.c @@ -869,11 +869,6 @@ u3m_soft_top(c3_w sec_w, // timer seconds /* Make sure the inner routine did not create garbage. */ if ( u3C.wag_w & u3o_debug_ram ) { - if ( u3_none != u3_Prof ) { - fprintf(stderr,"should be checking!\r\n"); - u3z(u3_Prof); - u3_Prof = u3_none; - } u3m_grab(pro, u3_none); } diff --git a/n/v.c b/n/v.c index 221edeb3a..aac70df2e 100644 --- a/n/v.c +++ b/n/v.c @@ -79,6 +79,7 @@ u3v_start(u3_noun now) { u3v_time(now); u3v_numb(); + u3A->sac = u3_nul; { c3_c* wen_c = u3r_string(u3A->wen); diff --git a/v/loop.c b/v/loop.c index 295b20c73..8103518f8 100644 --- a/v/loop.c +++ b/v/loop.c @@ -420,7 +420,6 @@ u3_lo_open(void) // // Assumption: there are no noun roots outside u3A. // - u3_Prof = u3_none; u3m_grab(u3_none); } #if 0 diff --git a/v/raft.c b/v/raft.c index 83d7cf182..6b87001a1 100644 --- a/v/raft.c +++ b/v/raft.c @@ -1691,6 +1691,198 @@ _raft_kick_all(u3_noun vir) } } +/* _raft_spac(): print n spaces. +*/ +void _raft_spac(c3_w n) +{ + for (; n > 0; n--) + (fprintf(stderr," ")); +} + +/* _raft_print_memory: print memory amount. cf u3a_print_memory(). +*/ +void +_raft_print_memory(c3_w wor_w) +{ + c3_w byt_w = (wor_w * 4); + c3_w gib_w = (byt_w / 1000000000); + c3_w mib_w = (byt_w % 1000000000) / 1000000; + c3_w kib_w = (byt_w % 1000000) / 1000; + c3_w bib_w = (byt_w % 1000); + + if ( gib_w ) { + (fprintf(stderr, "GB/%d.%03d.%03d.%03d\r\n", + gib_w, mib_w, kib_w, bib_w)); + } + else if ( mib_w ) { + (fprintf(stderr, "MB/%d.%03d.%03d\r\n", mib_w, kib_w, bib_w)); + } + else if ( kib_w ) { + (fprintf(stderr, "KB/%d.%03d\r\n", kib_w, bib_w)); + } + else { + (fprintf(stderr, "B/%d\r\n", bib_w)); + } +} + +/* _raft_prof_noun(): get memory usage, in words, of noun. RETAIN. +*/ +c3_w +_raft_prof_noun(u3p(u3h_root) hax, u3_noun non, c3_t dud) +{ + return 0; + /* + u3_weak got = u3h_git(hax, dud ? non & 0x7fffffff : non); + + if (u3_none != got) { + return 1; + } + else { + c3_w res; + + if (!(non & 0x80000000)) { + res = 1; + } + if (_(u3ud(non))) { + res = 3 + 3 + u3r_met(5, non); + } + else { + res = 3 + 2 + + _raft_prof_noun(hax, u3h(non), dud) + + _raft_prof_noun(hax, u3t(non), dud); + } + + u3h_put(hax, dud ? non & 0x7fffffff : non, res); + + return res; + } + */ +} + +/* _raft_prof(): print memory profile. RETAIN. +*/ +c3_w +_raft_prof(u3p(u3h_root) hax, c3_w den, u3_noun mas) +{ + c3_w tot_w = 0; + u3_noun h_mas, t_mas; + + if (c3n == u3r_cell(mas, &h_mas, &t_mas)) { + _raft_spac(den); + (fprintf(stderr, "mistyped mass\r\n")); + return tot_w; + } + if (c3y == h_mas) { + _raft_spac(den); + _raft_print_memory(_raft_prof_noun(hax, t_mas, 0)); + _raft_spac(den); + _raft_print_memory(_raft_prof_noun(hax, t_mas, 1)); + _raft_spac(den); + tot_w += u3a_mark_noun(t_mas); + _raft_print_memory(tot_w); + + /* The basic issue here is that t_mas is included in + * u3A->sac, so they can't both be roots in the normal + * sense. When we mark u3A->sac later on, we want t_mas + * to appear to appear unmarked, but its children should + * be already marked. + */ + if ( _(u3a_is_dog(t_mas)) ) { + u3a_box* box_u = u3a_botox(u3a_to_ptr(t_mas)); +#ifdef U3_MEMORY_DEBUG + if ( 1 == box_u->eus_w ) { + box_u->eus_w = 0xffffffff; + } + else { + box_u->eus_w -= 1; + } +#else + if ( -1 == (c3_w)box_u->siz_w ) { + box_u->siz_w = 0x80000000; + } + else { + box_u->siz_w -= 1; + } +#endif + } + + return tot_w; + } + else if (c3n == h_mas) { + u3_noun it_mas, tt_mas, pit_mas, qit_mas; + while (u3_nul != t_mas) + { + _raft_spac(den); + if (c3n == u3r_cell(t_mas, &it_mas, &tt_mas)) { + (fprintf(stderr, "mistyped mass list\r\n")); + return tot_w; + } + else if (c3n == u3r_cell(it_mas, &pit_mas, &qit_mas)) { + (fprintf(stderr, "mistyped mass list element\r\n")); + return tot_w; + } + else { + c3_c* pit_c = u3m_pretty(pit_mas); + (fprintf(stderr, "%s\r\n", pit_c)); + free(pit_c); + + tot_w += _raft_prof(hax, den+2, qit_mas); + + t_mas = tt_mas; + } + } + return tot_w; + } + else { + _raft_spac(den); + (fprintf(stderr, "mistyped mass head\r\n")); + u3m_p("mas",h_mas); + return tot_w; + } +} + +/* _raft_grab(): garbage collect, checking for profiling. RETAIN. +*/ +static void +_raft_grab(u3_noun ova) +{ + if ( u3_nul != u3A->sac ) { + c3_w usr_w = 0, ova_w = 0, sac_w = 0, utv_w = 0, utm_w = 0, wep_w = 0; + + usr_w = _raft_prof(u3_nul, 0, u3A->sac); + fprintf(stderr, "total userspace: "); + _raft_print_memory(usr_w); + + ova_w = u3a_mark_noun(ova); + fprintf(stderr, "effects list: "); + _raft_print_memory(ova_w); + + sac_w = u3a_mark_noun(u3A->sac); + fprintf(stderr, "space profile: "); + _raft_print_memory(sac_w); + + utv_w = u3v_mark(); + fprintf(stderr, "arvo stuff: "); + _raft_print_memory(utv_w); + + utm_w = u3m_mark(); + fprintf(stderr, "road stuff: "); + _raft_print_memory(utm_w); + + fprintf(stderr, "total marked: "); + _raft_print_memory(usr_w + ova_w + sac_w + utv_w + utm_w); + + wep_w = u3a_sweep(); + fprintf(stderr, "sweep: "); + _raft_print_memory(wep_w); + + u3z(u3A->sac); + u3A->sac = u3_nul; + } else { + // u3m_grab(ova, u3_none); + } +} + int FOO; /* u3_raft_work(): work. @@ -1803,6 +1995,8 @@ u3_raft_work(void) _raft_kick_all(vir); egg_u->did = c3y; egg_u->vir = 0; + + _raft_grab(ova); } } } diff --git a/v/reck.c b/v/reck.c index 2a955d6af..30a21d50a 100644 --- a/v/reck.c +++ b/v/reck.c @@ -66,138 +66,6 @@ _reck_lily(u3_noun fot, u3_noun txt, c3_l* tid_l) } } -/* _reck_spac(): print n spaces. -*/ -void _reck_spac(c3_w n) -{ - for (; n > 0; n--) - (fprintf(stderr," ")); -} - -/* _reck_print_memory: print memory amount. cf u3a_print_memory(). -*/ -void -_reck_print_memory(c3_w wor_w) -{ - c3_w byt_w = (wor_w * 4); - c3_w gib_w = (byt_w / 1000000000); - c3_w mib_w = (byt_w % 1000000000) / 1000000; - c3_w kib_w = (byt_w % 1000000) / 1000; - c3_w bib_w = (byt_w % 1000); - - if ( gib_w ) { - (fprintf(stderr, "GB/%d.%03d.%03d.%03d\r\n", - gib_w, mib_w, kib_w, bib_w)); - } - else if ( mib_w ) { - (fprintf(stderr, "MB/%d.%03d.%03d\r\n", mib_w, kib_w, bib_w)); - } - else if ( kib_w ) { - (fprintf(stderr, "KB/%d.%03d\r\n", kib_w, bib_w)); - } - else { - (fprintf(stderr, "B/%d\r\n", bib_w)); - } -} - -/* _reck_meme_noun(): get memory usage, in words, of noun. RETAIN. -*/ -c3_w -_reck_meme_noun(u3p(u3h_root) hax, u3_noun non, c3_t dud) -{ - return 0; - /* - u3_weak got = u3h_git(hax, dud ? non & 0x7fffffff : non); - - if (u3_none != got) { - return 1; - } - else { - c3_w res; - - if (!(non & 0x80000000)) { - res = 1; - } - if (_(u3ud(non))) { - res = 3 + 3 + u3r_met(5, non); - } - else { - res = 3 + 2 - + _reck_meme_noun(hax, u3h(non), dud) - + _reck_meme_noun(hax, u3t(non), dud); - } - - u3h_put(hax, dud ? non & 0x7fffffff : non, res); - - return res; - } - */ -} - -/* _reck_noun_grab(): get memory usage, in words, of noun from GC. RETAIN. - * XXX what about unmarking stuff? what's a GC cycle? -*/ -c3_w -_reck_noun_grab(u3_noun non) -{ - return u3a_mark_noun(non); -} - -/* _reck_meme_prof(): print memory profile. RETAIN. -*/ -c3_w -_reck_meme_prof(u3p(u3h_root) hax, c3_w den, u3_noun mas) -{ - c3_w tot_w = 0; - u3_noun h_mas, t_mas; - - if (c3n == u3r_cell(mas, &h_mas, &t_mas)) { - _reck_spac(den); - (fprintf(stderr, "mistyped mass\r\n")); - return tot_w; - } - if (c3y == h_mas) { - _reck_spac(den); - _reck_print_memory(_reck_meme_noun(hax, t_mas, false)); - _reck_spac(den); - _reck_print_memory(_reck_meme_noun(hax, t_mas, true)); - _reck_spac(den); - tot_w += _reck_noun_grab(t_mas); - _reck_print_memory(tot_w); - return tot_w; - } - else if (c3n == h_mas) { - u3_noun it_mas, tt_mas, pit_mas, qit_mas; - while (u3_nul != t_mas) - { - _reck_spac(den); - if (c3n == u3r_cell(t_mas, &it_mas, &tt_mas)) { - (fprintf(stderr, "mistyped mass list\r\n")); - return tot_w; - } - else if (c3n == u3r_cell(it_mas, &pit_mas, &qit_mas)) { - (fprintf(stderr, "mistyped mass list element\r\n")); - return tot_w; - } - else { - c3_c* pit_c = u3m_pretty(pit_mas); - (fprintf(stderr, "%s\r\n", pit_c)); - free(pit_c); - - tot_w += _reck_meme_prof(hax, den+2, qit_mas); - - t_mas = tt_mas; - } - } - return tot_w; - } - else { - _reck_spac(den); - (fprintf(stderr, "mistyped mass head\r\n")); - return tot_w; - } -} - /* _reck_kick_term(): apply terminal outputs. */ static u3_noun @@ -245,36 +113,7 @@ _reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav) case c3__mass: p_fav = u3t(fav); { - u3_Prof = u3k(p_fav); - //c3_w usr_w, utm_w, utv_w, ext_w, wep_w; - //uL(fprintf(uH, "memory profile:\r\n")); - - //// u3p(u3h_root) hax = u3h_new(); - - //usr_w = _reck_meme_prof(u3_nul, 0, p_fav); - //(fprintf(stderr, "total userspace: ")); - //_reck_print_memory(usr_w); - - //utm_w = u3m_mark(); - //(fprintf(stderr, "u3m stuff: ")); - //_reck_print_memory(utm_w); - - //utv_w = u3v_mark(); - //(fprintf(stderr, "u3v stuff: ")); - //_reck_print_memory(utv_w); - - //ext_w = u3a_mark_noun(pox) + u3a_mark_noun(fav); - //(fprintf(stderr, "extra stuff: ")); - //_reck_print_memory(ext_w); - - //(fprintf(stderr, "total memory: ")); - //_reck_print_memory(usr_w + utm_w + utv_w + ext_w); - - //wep_w = u3a_sweep(); - //(fprintf(stderr, "sweep memory: ")); - //_reck_print_memory(wep_w); - - //// u3h_free(hax); + u3A->sac = u3k(p_fav); u3z(pox); u3z(fav); return c3y; } break; @@ -400,7 +239,7 @@ _reck_kick_spec(u3_noun pox, u3_noun fav) u3z(pox); u3z(fav); return c3n; } else switch ( it_pox ) { - default: return c3n; + default: u3z(pox); u3z(fav); return c3n; case c3__http: { u3_noun pud = tt_pox; From 1edf15843f708863f2b627ad8c7232bd26957d2b Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Fri, 8 May 2015 21:22:11 -0400 Subject: [PATCH 03/12] added U3_CELLOC_TOGGLE --- i/n/a.h | 6 ++++++ n/a.c | 33 +++++++++++++++++---------------- v/raft.c | 7 +++++-- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/i/n/a.h b/i/n/a.h index 207c0e0de..fc8aa7ebd 100644 --- a/i/n/a.h +++ b/i/n/a.h @@ -8,6 +8,12 @@ */ # undef U3_MEMORY_DEBUG + /* U3_CELLOC_TOGGLE: enable toggling of the custum cell allocator + * via -g. This slightly slows down the cell allocator even when + * it's on. Note that toggling -g breaks the image. If + * U3_MEMORY_DEBUG is on, this should generally be on as well. + */ +# define U3_CELLOC_TOGGLE /** Constants. **/ diff --git a/n/a.c b/n/a.c index 3e4dc40a0..51ff2500c 100644 --- a/n/a.c +++ b/n/a.c @@ -561,9 +561,12 @@ u3a_malloc(size_t len_i) c3_w* u3a_celloc(void) { -#ifdef U3_MEMORY_DEBUG - return u3a_walloc(c3_wiseof(u3a_cell)); -#else +#ifdef U3_CELLOC_TOGGLE + if ( u3C.wag_w & u3o_debug_ram ) { + return u3a_walloc(c3_wiseof(u3a_cell)); + } +#endif + u3p(u3a_fbox) cel_p; if ( (u3R == &(u3H->rod_u)) || !(cel_p = u3R->all.cel_p) ) { @@ -577,7 +580,6 @@ u3a_celloc(void) return u3a_boxto(box_u); } -#endif } /* u3a_cfree(): free a cell. @@ -585,9 +587,12 @@ u3a_celloc(void) void u3a_cfree(c3_w* cel_w) { -#ifdef U3_MEMORY_DEBUG - return u3a_wfree(cel_w); -#else +#ifdef U3_CELLOC_TOGGLE + if ( u3C.wag_w & u3o_debug_ram ) { + return u3a_wfree(cel_w); + } +#endif + if ( u3R == &(u3H->rod_u) ) { return u3a_wfree(cel_w); } @@ -598,7 +603,6 @@ u3a_cfree(c3_w* cel_w) u3to(u3a_fbox, fre_p)->nex_p = u3R->all.cel_p; u3R->all.cel_p = fre_p; } -#endif } /* u3a_realloc(): aligned realloc in bytes. @@ -1335,10 +1339,10 @@ u3a_mark_ptr(void* ptr_v) use_ws -= 1; siz_w = 0; } - // else if ( 0x80000000 == (c3_w)use_ws ) { // see _raft_prof() - // use_ws = -1; - // siz_w = 0xffffffff; - // } + else if ( 0x80000000 == (c3_w)use_ws ) { // see _raft_prof() + use_ws = -1; + siz_w = 0xffffffff; + } else { use_ws = -1; siz_w = box_u->siz_w; @@ -1479,10 +1483,7 @@ u3a_sweep(void) (u3_noun)u3a_to_pom(u3a_outa(u3a_boxto(box_w))), ((u3a_noun *)(u3a_boxto(box_w)))->mug_w, box_u->use_w, box_u->eus_w); - //static int xuc_i = 0; - //if ( 2 != ++xuc_i && 3 != xuc_i ) { - // u3m_p("weak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); - //} + // u3m_p("weak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); } weq_w += box_u->siz_w; } diff --git a/v/raft.c b/v/raft.c index 6b87001a1..ca21c4905 100644 --- a/v/raft.c +++ b/v/raft.c @@ -1847,6 +1847,10 @@ static void _raft_grab(u3_noun ova) { if ( u3_nul != u3A->sac ) { + if ( !(u3C.wag_w & u3o_debug_ram) ) { + fprintf(stderr, "massing doesn't work without the -g flag\r\n"); + goto _raft_grab_end; + } c3_w usr_w = 0, ova_w = 0, sac_w = 0, utv_w = 0, utm_w = 0, wep_w = 0; usr_w = _raft_prof(u3_nul, 0, u3A->sac); @@ -1876,10 +1880,9 @@ _raft_grab(u3_noun ova) fprintf(stderr, "sweep: "); _raft_print_memory(wep_w); +_raft_grab_end: u3z(u3A->sac); u3A->sac = u3_nul; - } else { - // u3m_grab(ova, u3_none); } } From deff75f7f8c9e433ef29c7b51941618f9d549f6d Mon Sep 17 00:00:00 2001 From: chc4 Date: Sat, 9 May 2015 15:12:43 -0400 Subject: [PATCH 04/12] half-update readme Update a good portion of the readme, since the old one was horribly out of date and from 2013. I manually changed the path and ship name to match the old one, which might not have been the correct thing to do. It still needs a bit of work to make all the information correct. --- README.markdown | 189 +++++++++++++++++++++++++++++------------------- 1 file changed, 116 insertions(+), 73 deletions(-) diff --git a/README.markdown b/README.markdown index 0f02a0a80..d060900d3 100644 --- a/README.markdown +++ b/README.markdown @@ -96,33 +96,50 @@ or _ships_. When you run `bin/vere -c`, it automatically creates a 128-bit ship First you'll see a string of messages like: - vere: urbit home is /Users/cyarvin/Documents/src/u3/urb - loom: mapped 1024MB - time: ~2013.9.1..03.57.11..4935 - ames: on localhost, UDP 63908. + vere: urbit home is mypier + vere: hostname is cyarvin + loom: mapped 2048MB + boot: installed 190 jets + boot: loading /home/cyarvin/urbit/urb/urbit.pill + cv_make: loaded pill /home/cyarvin/urbit/urb/urbit.pill, as 8ddffb8 + cv_make: kernel 12e1ffdf, core 23b73cd + cv_jack: activating kernel 12e1ffdf + %post-start + cv_jack: activated + cv_start: time: ~2015.5.9..18.03.32..ba77 + +Next vere will generate a 2048 RSA key that will be used as your identity: + generating 2048-bit RSA pair... and then it'll pause a little, 'cause this is slow, and then - saving passcode in /Users/cyarvin/.urbit/~magsut-hopful.txt + saving passcode in sub/.urb/code.~malmel-ridnep (for real security, write it down and delete the file...) and, then, if the network gods are happy, your submarine will start pulling down Arvo files: - + /~machec-binnev-dordeb-sogduc--dosmul-sarrum-faplec-nidted/main/1/bin/ticket/hoon - + /~machec-binnev-dordeb-sogduc--dosmul-sarrum-faplec-nidted/main/1/bin/reset/hoon - + /~machec-binnev-dordeb-sogduc--dosmul-sarrum-faplec-nidted/main/1/bin/ye/hoon - + /~machec-binnev-dordeb-sogduc--dosmul-sarrum-faplec-nidted/main/1/bin/ls/hoon + [%bos ~zod ~hinfet-rovler-labheb-laddev--ladner-pillur-divmun-tamfur] + [%behn-init ~hinfet-rovler-labheb-laddev--ladner-pillur-divmun-tamfur] + ames: czar zod.urbit.org: ip .192.241.195.84 + kick: init: ~hinfet-rovler-labheb-laddev--ladner-pillur-divmun-tamfur + ames: on localhost, UDP 55659. + http: live (insecure) on 8081 + http: live ("secure") on 8444 + term: live on 10024 + ; ~zod |Tianming| is your neighbor + ; ~zod |Tianming| is your neighbor + -and the like. You'll see a couple pages of this stuff. Don't worry too much -about the details right now. Finally, you'll get the Arvo shell prompt (which -is also a Hoon REPL): +You will probably be stuck here for a while as your local submarine copies all of its files from the master carrier, `~zod`. This is normal. - ~machec-binnev-dordeb-sogduc--dosmul-sarrum-faplec-nidted/try=> +Once that is finished, you will be dropped into the main application, the `+dojo` shell (which is coincidentally also a Hoon REPL): + + ~hinfet-rovler-labheb-laddev--ladner-pillur-divmun-tamfur:dojo> If you would like to safely bring this ship back into port (End the Unix process), -just enter Control-D. +just enter Control-V to switch to the task manager, then Control-D. To re-launch your pier after creation run `bin/vere mypier` (exclude the `-c`) @@ -151,19 +168,18 @@ Let's say one of your ships is `~waclux-tomwyc` and its ticket is rendered in Hoon's syllabic base, `@p`.) A new life awaits you on the off-world colonies! To begin, just -type at the submarine prompt: +type at the `+dojo` prompt: - :begin ~waclux-tomwyc + :helm?begin -and follow the directions. When the script completes, hit return -and you'll be the `~waclux-tomwyc` you wanted to be. Now, when other user's see you in chat or look at your -Urbit social profile (a fasplan), they can learn whatever information you gave the :begin process. +and enter your ship name and ticket when prompted. When the script completes, hit return +and you'll begin re-cloning the files from `~zod` needed to boot the destroyer, after which you will become the `~waclux-tomwyc` you wanted to be. ###5. Play with Arvo If all went well, you now have a nice short prompt: - ~waclux-tomwyc/try=> + ~waclux-tomwyc:dojo> If all did not go well (send us another email), or you're just too impatient to wait for your destroyer, you have a big long @@ -175,29 +191,30 @@ exercises will still work. Let's try a few quick things to stretch your fingers. Type these command lines and you should see the matching results: - ~waclux-tomwyc/try=> "hello, world" + ~waclux-tomwyc:dojo> "hello, world" "hello, world" - - ~waclux-tomwyc/try=> (add 2 2) + + ~waclux-tomwyc:dojo> (add 2 2) 4 - ~waclux-tomwyc/try=> :hello %world - "hello, world." + ~waclux-tomwyc:dojo> +hello %world + 'hello, dlrow' - ~waclux-tomwyc/try=> :cat /=main=/bin/hello/hoon + ~waclux-tomwyc/try=> :cat /=home=/cat/hello/gate/hook :: XX make this work :: - :: /=main=/bin/hello/hoon + :::: /hook/gate/hello/cat + :: + /? 314 :: - |= * - |= [planet=@ta ~] - ^- bowl - :_ ~ :_ ~ - :- %% - !>("hello, {(trip planet)}.") + :::: + !: + |= [* [[txt=@tas ~] ~]] + :- %noun + (crip (weld "hello, " (flop (trip txt)))) What did you just do? -One, you used Arvo as a Hoon REPL to print the constant `"hello, +One, you used the Hoon REPL to print the constant `"hello, world"`, which is a fancy way to write the Nock noun [104 101 108 108 111 44 32 119 111 114 108 100 0] @@ -205,7 +222,7 @@ world"`, which is a fancy way to write the Nock noun Two, you called the Hoon `add` function to see that two plus two is four. Math seems to work the same on the off-world colonies. -Three, you ran the Arvo application `:hello` with the argument +Three, you ran the `+dojo` application `+hello` with the argument `%world`, which is just a fancy way to write the atom `431.316.168.567` (or, for non-Germans, `431,316,168,567`). You might recognize it better as `0x64.6c72.6f77` - the ASCII @@ -214,18 +231,19 @@ characters in LSB first order. (Is Urbit German? Sadly, no. But all our noun print formats are URL-safe, which dot is and comma isn't.) -And you (4) used the Arvo application :cat to print the Hoon file +And you (4) used the `+dojo` application `+cat` to print the Hoon file - /=main=/bin/hello/hoon + /=home=/cat/hello/gate/hook which, supposing your current date is ~2013.9.1..04.38.31..f259 + ~2015.5.9..18.03.32..ba77 -(ie, September 1, 2013 at 4:38:31 GMT/LS25 plus 0xf259/65536 -seconds), is equivalent to the global path +(ie, May 9, 2015 at 18:03:32 GMT/LS25 plus 0xba77/47735 seconds), is +equivalent to the global path - /~waclux-tomwyc/main/~2013.8.23..04.38.31..f259/bin/hello/hoon + /~waclux-tomwyc/home/~2015.5.9..18.03.32..ba77/cat/hello/gate/hook which anyone in Urbit can, see and even use - but we're getting ahead of ourselves. @@ -261,19 +279,18 @@ control. First, we'll quit out of an infinite loop with `^C`: - ~waclux-tomwyc/try=> :infinite + ~waclux-tomwyc/try=> |-($) When you hit return at the end of this line, Arvo will appear to hang. Do not be alarmed! This is not a bug - it means that we've started running our infinite loop before printing the next console prompt. Simply hit `^C`, and you'll see - ! intr + recover: dig: intr + intr + [various stack traces] ~waclux-tomwyc/try=> :infinite -(There may be some stacktrace stuff before the `! intr`, depending -on whether your kernel was compiled with debugging.) - Hit `^U` to delete the line and escape from infinity. Arvo is a deterministic OS; you interrupted it while processing an event that would never terminate. It returns to the state it was in @@ -296,21 +313,22 @@ current character - as in Unix. Try this by running - ~waclux-tomwyc/try=> :begin + ~waclux-tomwyc:dojo> +helm?begin - Do you have a ship and a ticket? yes + ~waclux-tomwyc:dojo: your ship: ~ -Then hit `^D` and you'll be back to the command prompt (which, -unlike in Unix, is not a task itself, but part of the OS). +Then hit `^D` and you'll be back to the command prompt (which is just +another program under Arvo) We don't always want to kill the prompting task. We often want to switch between tasks, or between tasks and the command line. Sort of like switching between windows, except in a command line. -We do this with `^X`. Try +We do this with `^X`. Try + :: XX this is wrong, only between apps(+dojo or +talk) now - ~waclux-tomwyc/try=> :begin + ~waclux-tomwyc:dojo> +helm?begin - Do you have a ship and a ticket? yes + ~waclux-tomwyc:dojo: your ship: ~ But hit `^X` instead of `^D`. You'll get a prompt again. Use it: @@ -331,35 +349,58 @@ Hit `^X` again: And finally, hit `^C` to kill the task. +Arvo has a simple task manager interface, allowing you see the +running commands, along with being able to spawn or kill programs. +Hitting `^V` will bring you to this interface, and running `-prog` +will kill that program while `+prog` will spawn a new one. +If you ever end up with a broken program that is spouting errors +and wish to restart it, do it from this interface. Even our shell +and REPL `+dojo` is just another program in this list! +This is the base view from Arvo as well. If you kill all your running +programs with `^D`, it will drop you into this interface. +Pressing `^D` from this view will also shutdown your ship gracefully, +instead of having to kill all programs first. + Lastly, Arvo is a single-level store. Since it's not the '70s anymore and disk is cheap, everything you do is saved for ever. (In fact, it's saved in two ways - as a memory image and an event log - so you, or the government if they haz your filez, can repeat every computation you've ever performed.) -If the current prompt is just the shell prompt, `^D` on an empty +If the current prompt is the task manager, `^D` on an empty line will log out - as in Unix: - ~waclux-tomwyc/try=> - oxford:~/urbit; pwd - /Users/cyarvin/urbit - oxford:~/urbit; echo "hello, world" + ~waclux-tomwyc# + cyarvin:~/urbit; pwd + /home/cyarvin/urbit + cyarvin:~/urbit; echo "hello, world" hello, world - oxford:~/urbit; + cyarvin:~/urbit; Then you can restart and be right back where you were - just run `bin/vere` without `-c`: - oxford:~/urbit; bin/vere mypier - vere: urbit home is /Users/cyarvin/urb - loom: loaded 9MB - time: ~2013.9.1..17.23.05..0cc1 - ames: on localhost, UDP 60342. - http: live on 8080 - rest: checkpoint to event 383 - rest: old 0v1c.gkr1o, new 0v10.m4gdu + cyarvin:~/urbit; bin/vere mypier + vere: urbit home is mypier + vere: hostname is cyarvin + loom: mapped 2048MB + protected loom + live: loaded: MB/172.933.120 + boot: installed 190 jets + cv_start: time: ~2015.5.9..19.03.45..a758 + raft: single-instance mode + raft: -> lead + sist: booting + rest: checkpoint to event 23.630 + rest: old 0vt.3iqg5, new 0v1j.moa0t + loaded passcode from mypier/.urb/code.~lacsep-bonnyr + ---------------- playback complete---------------- - waclux-tomwyc/try=> + ames: on localhost, UDP 46404. + http: live (insecure) on 8080 + http: live ("secure") on 8443 + term: live on 10023 + ~waclux-tomwyc:dojo, talk# Use your arrow keys and you'll see your history is still there. Arvo is indestructible and can be shut down however you like @@ -370,7 +411,7 @@ But don't try to operate the same ship on two Unix hosts at the same time. This will confuse everyone, including yourself. ####System administration - +:: XX FIX ME Sometimes we make changes to Hoon or Arvo (we never make changes to Nock) and you need to update your ship. @@ -410,17 +451,19 @@ every so often to get the latest Urbit source code. You'll need to run: before executing `bin/vere pier` again. -###6. Chat +###6. Talk Okay, fine. You're a long way from being an Arvo ninja. But - you're ready for the two most important uses of Urbit right now. One, coding. Two, chatting. -To start chatting, simply type +To start chatting, simply press `^X` to switch to the `:talk` app +(If you accidently killed it, no worries: start a new one by typing +`+talk` from the `^V` menu) - ~waclux-tomwyc/try=> :chat + ~waclux-tomwyc:talk() -and type `?` for the list of commands once `:chat` is running. +and type `;join /urbit-meta` to join our main chat room. -Most of us are hanging out on `:chat` regularly. We can answer any questions you might have and help you get oriented in this new environment. +Most of us are hanging out on `:talk` regularly. We can answer any questions you might have and help you get oriented in this new environment. From a4559fc7bbd501d81b69d629f9de7efadfe9b115 Mon Sep 17 00:00:00 2001 From: chc4 Date: Sun, 10 May 2015 21:12:51 -0400 Subject: [PATCH 05/12] Semi-update readme A bit more work. I'm pretty sure calling it `:dojo` is more appropriate than `+dojo` since it is neither a dog nor a cat, like how we call it `:talk` instead of `+talk`. I also rewrote some old sections, but not very well. Grep for "XX" to see what needs improvements... --- README.markdown | 91 +++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 53 deletions(-) diff --git a/README.markdown b/README.markdown index d060900d3..cd5d4cfdf 100644 --- a/README.markdown +++ b/README.markdown @@ -12,7 +12,8 @@ Urbit is a new programming and execution environment designed from scratch. Any resemblance to existing languages or operating systems is coincidental, cosmetic, or inevitable. -All of the source code is entirely in the public domain. +All of the source code is distributed under the MIT license, but is for all +intents and purposes in the public domain. Install ------------------- @@ -92,7 +93,7 @@ Run `bin/vere -c mypier` in the urbit directory, where `mypier` is a directory t A _pier_ is an Urbit virtual machine that hosts one or more Urbit identities, or _ships_. When you run `bin/vere -c`, it automatically creates a 128-bit ship, or `submarine`. Your name (a hash of a randomly-generated public key) will look something like: - ~machec-binnev-dordeb-sogduc--dosmul-sarrum-faplec-nidted + ~hinfet-rovler-labheb-laddev--ladner-pillur-divmun-tamfur First you'll see a string of messages like: @@ -114,7 +115,7 @@ Next vere will generate a 2048 RSA key that will be used as your identity: and then it'll pause a little, 'cause this is slow, and then - saving passcode in sub/.urb/code.~malmel-ridnep + saving passcode in mypier/.urb/code.~malmel-ridnep (for real security, write it down and delete the file...) and, then, if the network gods are happy, your submarine will start pulling @@ -134,7 +135,7 @@ down Arvo files: You will probably be stuck here for a while as your local submarine copies all of its files from the master carrier, `~zod`. This is normal. -Once that is finished, you will be dropped into the main application, the `+dojo` shell (which is coincidentally also a Hoon REPL): +Once that is finished, you will be dropped into the main application, the `:dojo` shell (which is coincidentally also a Hoon REPL): ~hinfet-rovler-labheb-laddev--ladner-pillur-divmun-tamfur:dojo> @@ -168,7 +169,7 @@ Let's say one of your ships is `~waclux-tomwyc` and its ticket is rendered in Hoon's syllabic base, `@p`.) A new life awaits you on the off-world colonies! To begin, just -type at the `+dojo` prompt: +type at the `:dojo` prompt: :helm?begin @@ -200,7 +201,7 @@ command lines and you should see the matching results: ~waclux-tomwyc:dojo> +hello %world 'hello, dlrow' - ~waclux-tomwyc/try=> :cat /=home=/cat/hello/gate/hook :: XX make this work + ~waclux-tomwyc:dojo> :cat /=home=/cat/hello/gate/hook :: XX make this work :: :::: /hook/gate/hello/cat :: @@ -222,7 +223,7 @@ world"`, which is a fancy way to write the Nock noun Two, you called the Hoon `add` function to see that two plus two is four. Math seems to work the same on the off-world colonies. -Three, you ran the `+dojo` application `+hello` with the argument +Three, you ran the `:dojo` application `+hello` with the argument `%world`, which is just a fancy way to write the atom `431.316.168.567` (or, for non-Germans, `431,316,168,567`). You might recognize it better as `0x64.6c72.6f77` - the ASCII @@ -231,13 +232,12 @@ characters in LSB first order. (Is Urbit German? Sadly, no. But all our noun print formats are URL-safe, which dot is and comma isn't.) -And you (4) used the `+dojo` application `+cat` to print the Hoon file +And you (4) used the `:dojo` application `+cat` to print the Hoon file /=home=/cat/hello/gate/hook which, supposing your current date is - ~2013.9.1..04.38.31..f259 ~2015.5.9..18.03.32..ba77 (ie, May 9, 2015 at 18:03:32 GMT/LS25 plus 0xba77/47735 seconds), is @@ -279,7 +279,7 @@ control. First, we'll quit out of an infinite loop with `^C`: - ~waclux-tomwyc/try=> |-($) + ~waclux-tomwyc:dojo> |-($) When you hit return at the end of this line, Arvo will appear to hang. Do not be alarmed! This is not a bug - it means that @@ -289,7 +289,7 @@ console prompt. Simply hit `^C`, and you'll see recover: dig: intr intr [various stack traces] - ~waclux-tomwyc/try=> :infinite + ~waclux-tomwyc:dojo> |-($) Hit `^U` to delete the line and escape from infinity. Arvo is a deterministic OS; you interrupted it while processing an event @@ -317,37 +317,39 @@ Try this by running ~waclux-tomwyc:dojo: your ship: ~ -Then hit `^D` and you'll be back to the command prompt (which is just +Then hit `^D` and you'll kill the current task, the command prompt (which is just another program under Arvo) We don't always want to kill the prompting task. We often want to switch between tasks, or between tasks and the command line. Sort of like switching between windows, except in a command line. -We do this with `^X`. Try - :: XX this is wrong, only between apps(+dojo or +talk) now +We do this with `^X`. - ~waclux-tomwyc:dojo> +helm?begin +Let's try an example: First, make sure you +have two apps running, like `:dojo` and `:talk`. Then, try: + :: XX this is wrong, only between apps(+dojo or +talk) now + :: this entire example is kinda lackluster now... + :: killing the current task kills dojo now, and you + :: cant have multiple dojo instances! + + ~waclux-tomwyc:dojo> :helm?begin ~waclux-tomwyc:dojo: your ship: ~ -But hit `^X` instead of `^D`. You'll get a prompt again. Use +But hit `^X` instead of `^D`. You'll get switched to the next app in line, in this case `:talk`. Use it: - ~waclux-tomwyc/try=> :begin + ~waclux-tomwyc:dojo> :helm?begin - ~waclux-tomwyc/try=> :hello %world - "hello, world." - ~waclux-tomwyc/try=> + ~waclux-tomwyc:talk(/urbit-meta) hello, world! Hit `^X` again: - ~waclux-tomwyc/try=> :begin + ~waclux-tomwyc:dojo> :helm?begin - ~waclux-tomwyc/try=> :hello %world - "hello, world." - Do you have a ship and a ticket? yes + ~waclux-tomwyc:dojo: your ship: ~ -And finally, hit `^C` to kill the task. +And finally, hit `^D` to kill the task. Arvo has a simple task manager interface, allowing you see the running commands, along with being able to spawn or kill programs. @@ -355,11 +357,10 @@ Hitting `^V` will bring you to this interface, and running `-prog` will kill that program while `+prog` will spawn a new one. If you ever end up with a broken program that is spouting errors and wish to restart it, do it from this interface. Even our shell -and REPL `+dojo` is just another program in this list! +and REPL `:dojo` is just another program in this list! + This is the base view from Arvo as well. If you kill all your running programs with `^D`, it will drop you into this interface. -Pressing `^D` from this view will also shutdown your ship gracefully, -instead of having to kill all programs first. Lastly, Arvo is a single-level store. Since it's not the '70s anymore and disk is cheap, everything you do is saved for ever. @@ -370,7 +371,7 @@ repeat every computation you've ever performed.) If the current prompt is the task manager, `^D` on an empty line will log out - as in Unix: - ~waclux-tomwyc# + ~waclux-tomwyc:dojo, talk# cyarvin:~/urbit; pwd /home/cyarvin/urbit cyarvin:~/urbit; echo "hello, world" @@ -411,34 +412,18 @@ But don't try to operate the same ship on two Unix hosts at the same time. This will confuse everyone, including yourself. ####System administration -:: XX FIX ME Sometimes we make changes to Hoon or Arvo (we never make changes to Nock) and you need to update your ship. -There are two steps to updating. You need to get the new files, -and you need to install them. To get them: +Luckily, Arvo has some special sauce that allows it the same carriers +you initially pulled your files from to push kernel update over-the-air. +You may notice this happening from time to time through mysterious messages +such as: - ~waclux-tomwyc/try=> :update - : /~waclux-tomwyc/arvo/2/hoon/hoon - : /~waclux-tomwyc/arvo/2/dill/hoon - : /~waclux-tomwyc/arvo/2/batz/hoon + [%merge-fine blah] :: XX make this an actual %merge-fine example -To install them (the simplest, slowest, most general way): - - ~waclux-tomwyc/try=> :reset - - %reset-start - %reset-parsed - %reset-compiled - %hoon-load - [%tang /~waclux-tomwyc/arvo/~2013.11.26..20.29.15..090f/zuse ~tirnux-latwex] - [%vane %a /~waclux-tomwyc/arvo/~2013.11.26..20.29.15..090f/ames ~tolryn-watret] - [%vane %b /~waclux-tomwyc/arvo/~2013.11.26..20.29.15..090f/batz ~donfex-ladsem] - [%vane %c /~waclux-tomwyc/arvo/~2013.11.26..20.29.15..090f/clay ~picsug-mitref] - [%vane %d /~waclux-tomwyc/arvo/~2013.11.26..20.29.15..090f/dill ~dilpex-laptug] - [%vane %e /~waclux-tomwyc/arvo/~2013.11.26..20.29.15..090f/eyre ~forbur-disben] - -All of your state, including running tasks, will be unchanged. +These updates can be applied without having to restart Arvo or any of its +`%vanes`. All of your state, including running tasks, will be unchanged. Sometimes the interpreter, called `vere` gets updated. In your urbit directory, back in Unixland, run: @@ -448,7 +433,7 @@ every so often to get the latest Urbit source code. You'll need to run: make clean; make -before executing `bin/vere pier` again. +before executing `bin/vere mypier` again. ###6. Talk From bcd3b98e1fb5e7dcd8aad5525f089e77efa5786b Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Mon, 11 May 2015 19:47:53 -0400 Subject: [PATCH 06/12] massing works without U3_MEMORY_DEBUG --- i/n/a.h | 2 +- n/a.c | 40 ++++++++++++++++++++++++++++++++++------ v/raft.c | 6 +++--- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/i/n/a.h b/i/n/a.h index fc8aa7ebd..060989991 100644 --- a/i/n/a.h +++ b/i/n/a.h @@ -52,7 +52,7 @@ /** Structures. **/ - /* u3_atom, u3_cell: logical atom and cell structures. + /* u3a_atom, u3a_cell: logical atom and cell structures. */ typedef struct { c3_w mug_w; diff --git a/n/a.c b/n/a.c index 51ff2500c..992e99cb2 100644 --- a/n/a.c +++ b/n/a.c @@ -1335,14 +1335,14 @@ u3a_mark_ptr(void* ptr_v) else { c3_assert(use_ws != 0); - if ( use_ws < 0 ) { - use_ws -= 1; - siz_w = 0; - } - else if ( 0x80000000 == (c3_w)use_ws ) { // see _raft_prof() + if ( 0x80000000 == (c3_w)use_ws ) { // see _raft_prof() use_ws = -1; siz_w = 0xffffffff; } + else if ( use_ws < 0 ) { + use_ws -= 1; + siz_w = 0; + } else { use_ws = -1; siz_w = box_u->siz_w; @@ -1472,6 +1472,13 @@ u3a_sweep(void) u3a_box* box_u = (void *)box_w; #ifdef U3_MEMORY_DEBUG + /* I suspect these printfs fail hilariously in the case + * of non-direct atoms. We shouldn't unconditionally run + * u3a_to_pom(). In general, the condition + * box_u->siz_w > u3a_mimimum is sufficient, but not necessary, + * for the box to represent an atom. The atoms between + * 2^31 and 2^32 are the exceptions. + */ if ( box_u->use_w != box_u->eus_w ) { if ( box_u->eus_w != 0 ) { if ( box_u->use_w == 0 ) { @@ -1483,6 +1490,7 @@ u3a_sweep(void) (u3_noun)u3a_to_pom(u3a_outa(u3a_boxto(box_w))), ((u3a_noun *)(u3a_boxto(box_w)))->mug_w, box_u->use_w, box_u->eus_w); + u3a_print_memory("weak (minimum)", box_u->siz_w); // u3m_p("weak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); } weq_w += box_u->siz_w; @@ -1495,6 +1503,7 @@ u3a_sweep(void) ? ((u3a_noun *)(u3a_boxto(box_w)))->mug_w : u3r_mug(u3a_to_pom(u3a_outa(u3a_boxto(box_w)))), box_u->use_w); + u3a_print_memory("leak (minimum)", box_u->siz_w); // u3m_p("leak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); leq_w += box_u->siz_w; } @@ -1513,7 +1522,26 @@ u3a_sweep(void) c3_ws use_ws = (c3_ws)box_u->use_w; if ( use_ws > 0 ) { - printf("leak %p\r\n", box_u); + printf("leak %p %x\r\n", + box_u, + ((u3a_noun *)(u3a_boxto(box_w)))->mug_w + ? ((u3a_noun *)(u3a_boxto(box_w)))->mug_w + : u3r_mug(u3a_to_pom(u3a_outa(u3a_boxto(box_w))))); + u3a_print_memory("leak (minimum)", box_u->siz_w); + +#if 0 + /* For those times when you've really just got to crack open + * the box and see what's inside + */ + { + int i; + for ( i = 0; i < box_u->siz_w; i++ ) { + printf("%08x ", (unsigned int)(((c3_w*)box_u)[i])); + } + printf("\r\n"); + } +#endif + leq_w += box_u->siz_w; box_u->use_w = 0; diff --git a/v/raft.c b/v/raft.c index ca21c4905..614ed31ff 100644 --- a/v/raft.c +++ b/v/raft.c @@ -1797,11 +1797,11 @@ _raft_prof(u3p(u3h_root) hax, c3_w den, u3_noun mas) box_u->eus_w -= 1; } #else - if ( -1 == (c3_w)box_u->siz_w ) { - box_u->siz_w = 0x80000000; + if ( -1 == (c3_w)box_u->use_w ) { + box_u->use_w = 0x80000000; } else { - box_u->siz_w -= 1; + box_u->use_w -= 1; } #endif } From 85d9cc87fb80ba6cd630380e328db06d817f423e Mon Sep 17 00:00:00 2001 From: chc4 Date: Tue, 12 May 2015 17:12:53 -0400 Subject: [PATCH 07/12] Readme cleanup Finishing touches. That travis-ci badge doesn't look like it was ever actually setup, and the build never really breaks anyways. Notable issues: - The +cat example doesn't work. At all. You can't even try to type the path without breaking :dojo. - The "Control Characters" example for ^X is a lot more lack-luster now. Instead of being able to spawn arbitrarily many console apps that wait for input, being able to kill and swap between them at will, you can only have one console app running under a :dojo instance and arbitrary other ^V app. This is bad, since if a reader is going through the file sequentially they may not have a program other than :dojo running, making it looks broken. I moved the ^V section to the top so they can hopefully put the pieces together... - Someone should really proofread this. Make sure I updated all the hostnames and shipnames, since I had to do that manually, and that everything read well. Dammit Jim I'm a programmer not a writer... --- README.markdown | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/README.markdown b/README.markdown index cd5d4cfdf..6bd7e050e 100644 --- a/README.markdown +++ b/README.markdown @@ -1,8 +1,6 @@ Urbit ===== -[![Build Status](https://travis-ci.org/urbit/urbit.png?branch=master)](https://travis-ci.org/urbit/urbit) - > Tlön is surely a labyrinth, but it is > a labyrinth devised by men, a labyrinth > destined to be deciphered by men. @@ -201,7 +199,7 @@ command lines and you should see the matching results: ~waclux-tomwyc:dojo> +hello %world 'hello, dlrow' - ~waclux-tomwyc:dojo> :cat /=home=/cat/hello/gate/hook :: XX make this work + ~waclux-tomwyc:dojo> +cat /=home=/cat/hello/gate/hook :: XX make this work :: :::: /hook/gate/hello/cat :: @@ -277,7 +275,19 @@ There are also some special control keys specific to Arvo. It's a good idea to learn these first so that you feel in, um, control. -First, we'll quit out of an infinite loop with `^C`: +First off, Arvo has a simple task manager interface, allowing you see the +running commands, along with being able to spawn or kill programs. + +Hitting `^V` will bring you to this interface, and running `-prog` +will kill that program while `+prog` will spawn a new one. +If you ever end up with a broken program that is spouting errors +and wish to restart it, do it from this interface. Even our shell +and REPL `:dojo` is just another program in this list! + +This is the base view from Arvo as well. If you kill all your running +programs, it will drop you into this interface. + +Next, we'll show you how we can quit out of an infinite loop with `^C`: ~waclux-tomwyc:dojo> |-($) @@ -317,8 +327,7 @@ Try this by running ~waclux-tomwyc:dojo: your ship: ~ -Then hit `^D` and you'll kill the current task, the command prompt (which is just -another program under Arvo) +Then hit `^D` and you'll kill the current task, the command prompt `:dojo`. We don't always want to kill the prompting task. We often want to switch between tasks, or between tasks and the command line. @@ -327,10 +336,6 @@ We do this with `^X`. Let's try an example: First, make sure you have two apps running, like `:dojo` and `:talk`. Then, try: - :: XX this is wrong, only between apps(+dojo or +talk) now - :: this entire example is kinda lackluster now... - :: killing the current task kills dojo now, and you - :: cant have multiple dojo instances! ~waclux-tomwyc:dojo> :helm?begin @@ -341,7 +346,7 @@ it: ~waclux-tomwyc:dojo> :helm?begin - ~waclux-tomwyc:talk(/urbit-meta) hello, world! + ~waclux-tomwyc:talk() hello, world! Hit `^X` again: @@ -351,17 +356,6 @@ Hit `^X` again: And finally, hit `^D` to kill the task. -Arvo has a simple task manager interface, allowing you see the -running commands, along with being able to spawn or kill programs. -Hitting `^V` will bring you to this interface, and running `-prog` -will kill that program while `+prog` will spawn a new one. -If you ever end up with a broken program that is spouting errors -and wish to restart it, do it from this interface. Even our shell -and REPL `:dojo` is just another program in this list! - -This is the base view from Arvo as well. If you kill all your running -programs with `^D`, it will drop you into this interface. - Lastly, Arvo is a single-level store. Since it's not the '70s anymore and disk is cheap, everything you do is saved for ever. (In fact, it's saved in two ways - as a memory image and an event @@ -420,7 +414,7 @@ you initially pulled your files from to push kernel update over-the-air. You may notice this happening from time to time through mysterious messages such as: - [%merge-fine blah] :: XX make this an actual %merge-fine example + ['merge succeeded' {}] These updates can be applied without having to restart Arvo or any of its `%vanes`. All of your state, including running tasks, will be unchanged. From 5c8fec270a4cefbab4577adf87429bbe44ad71cb Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Tue, 12 May 2015 17:18:34 -0400 Subject: [PATCH 08/12] reworked ++mass --- i/n/a.h | 2 +- n/a.c | 6 ++- v/raft.c | 138 ++++++++++++++++++++++++++++--------------------------- 3 files changed, 77 insertions(+), 69 deletions(-) diff --git a/i/n/a.h b/i/n/a.h index 060989991..d92e28ad4 100644 --- a/i/n/a.h +++ b/i/n/a.h @@ -13,7 +13,7 @@ * it's on. Note that toggling -g breaks the image. If * U3_MEMORY_DEBUG is on, this should generally be on as well. */ -# define U3_CELLOC_TOGGLE +# undef U3_CELLOC_TOGGLE /** Constants. **/ diff --git a/n/a.c b/n/a.c index 992e99cb2..9d248b81a 100644 --- a/n/a.c +++ b/n/a.c @@ -1478,6 +1478,10 @@ u3a_sweep(void) * box_u->siz_w > u3a_mimimum is sufficient, but not necessary, * for the box to represent an atom. The atoms between * 2^31 and 2^32 are the exceptions. + * + * Update: so, apparently u3.md is incorrect, and a pug is just + * an indirect atom. This code should be altered to handle + * that. */ if ( box_u->use_w != box_u->eus_w ) { if ( box_u->eus_w != 0 ) { @@ -1529,7 +1533,7 @@ u3a_sweep(void) : u3r_mug(u3a_to_pom(u3a_outa(u3a_boxto(box_w))))); u3a_print_memory("leak (minimum)", box_u->siz_w); -#if 0 +#if 1 /* For those times when you've really just got to crack open * the box and see what's inside */ diff --git a/v/raft.c b/v/raft.c index 614ed31ff..d4b0d7c71 100644 --- a/v/raft.c +++ b/v/raft.c @@ -1725,6 +1725,7 @@ _raft_print_memory(c3_w wor_w) } } +#if 0 /* _raft_prof_noun(): get memory usage, in words, of noun. RETAIN. */ c3_w @@ -1758,6 +1759,7 @@ _raft_prof_noun(u3p(u3h_root) hax, u3_noun non, c3_t dud) } */ } +#endif /* _raft_prof(): print memory profile. RETAIN. */ @@ -1767,77 +1769,83 @@ _raft_prof(u3p(u3h_root) hax, c3_w den, u3_noun mas) c3_w tot_w = 0; u3_noun h_mas, t_mas; - if (c3n == u3r_cell(mas, &h_mas, &t_mas)) { + if ( c3n == u3r_cell(mas, &h_mas, &t_mas) ) { _raft_spac(den); (fprintf(stderr, "mistyped mass\r\n")); return tot_w; } - if (c3y == h_mas) { + else if ( _(u3du(h_mas)) ) { _raft_spac(den); - _raft_print_memory(_raft_prof_noun(hax, t_mas, 0)); - _raft_spac(den); - _raft_print_memory(_raft_prof_noun(hax, t_mas, 1)); - _raft_spac(den); - tot_w += u3a_mark_noun(t_mas); - _raft_print_memory(tot_w); - - /* The basic issue here is that t_mas is included in - * u3A->sac, so they can't both be roots in the normal - * sense. When we mark u3A->sac later on, we want t_mas - * to appear to appear unmarked, but its children should - * be already marked. - */ - if ( _(u3a_is_dog(t_mas)) ) { - u3a_box* box_u = u3a_botox(u3a_to_ptr(t_mas)); -#ifdef U3_MEMORY_DEBUG - if ( 1 == box_u->eus_w ) { - box_u->eus_w = 0xffffffff; - } - else { - box_u->eus_w -= 1; - } -#else - if ( -1 == (c3_w)box_u->use_w ) { - box_u->use_w = 0x80000000; - } - else { - box_u->use_w -= 1; - } -#endif - } - - return tot_w; - } - else if (c3n == h_mas) { - u3_noun it_mas, tt_mas, pit_mas, qit_mas; - while (u3_nul != t_mas) - { - _raft_spac(den); - if (c3n == u3r_cell(t_mas, &it_mas, &tt_mas)) { - (fprintf(stderr, "mistyped mass list\r\n")); - return tot_w; - } - else if (c3n == u3r_cell(it_mas, &pit_mas, &qit_mas)) { - (fprintf(stderr, "mistyped mass list element\r\n")); - return tot_w; - } - else { - c3_c* pit_c = u3m_pretty(pit_mas); - (fprintf(stderr, "%s\r\n", pit_c)); - free(pit_c); - - tot_w += _raft_prof(hax, den+2, qit_mas); - - t_mas = tt_mas; - } - } + (fprintf(stderr, "mistyped mass head\r\n")); + u3m_p("h_mas", h_mas); return tot_w; } else { _raft_spac(den); - (fprintf(stderr, "mistyped mass head\r\n")); - u3m_p("mas",h_mas); - return tot_w; + + c3_c* lab_c = u3m_pretty(h_mas); + (fprintf(stderr, "%s: ", lab_c)); + free(lab_c); + + u3_noun it_mas, tt_mas; + + if ( c3n == u3r_cell(t_mas, &it_mas, &tt_mas) ) { + (fprintf(stderr, "mistyped mass tail\r\n")); + return tot_w; + } + else if ( c3y == it_mas ) { + tot_w += u3a_mark_noun(tt_mas); + _raft_print_memory(tot_w); + +#if 1 + /* The basic issue here is that tt_mas is included in + * u3A->sac, so they can't both be roots in the normal + * sense. When we mark u3A->sac later on, we want tt_mas + * to appear unmarked, but its children should be already + * marked. + */ + if ( _(u3a_is_dog(tt_mas)) ) { + u3a_box* box_u = u3a_botox(u3a_to_ptr(tt_mas)); +#ifdef U3_MEMORY_DEBUG + if ( 1 == box_u->eus_w ) { + box_u->eus_w = 0xffffffff; + } + else { + box_u->eus_w -= 1; + } +#else + if ( -1 == (c3_w)box_u->use_w ) { + box_u->use_w = 0x80000000; + } + else { + box_u->use_w += 1; + } +#endif + } +#endif + + return tot_w; + } + else if ( c3n == it_mas ) { + (fprintf(stderr, "\r\n")); + + while ( _(u3du(tt_mas)) ) { + tot_w += _raft_prof(hax, den+2, u3h(tt_mas)); + tt_mas = u3t(tt_mas); + } + + _raft_spac(den); + (fprintf(stderr, "--")); + _raft_print_memory(tot_w); + + return tot_w; + + } + else { + _raft_spac(den); + (fprintf(stderr, "mistyped (strange) mass tail\r\n")); + return tot_w; + } } } @@ -1847,12 +1855,9 @@ static void _raft_grab(u3_noun ova) { if ( u3_nul != u3A->sac ) { - if ( !(u3C.wag_w & u3o_debug_ram) ) { - fprintf(stderr, "massing doesn't work without the -g flag\r\n"); - goto _raft_grab_end; - } c3_w usr_w = 0, ova_w = 0, sac_w = 0, utv_w = 0, utm_w = 0, wep_w = 0; + fprintf(stderr, "\r\n"); usr_w = _raft_prof(u3_nul, 0, u3A->sac); fprintf(stderr, "total userspace: "); _raft_print_memory(usr_w); @@ -1880,7 +1885,6 @@ _raft_grab(u3_noun ova) fprintf(stderr, "sweep: "); _raft_print_memory(wep_w); -_raft_grab_end: u3z(u3A->sac); u3A->sac = u3_nul; } From 55a0bdf3e2848d0b54bbec79a4fa271a0cb0b675 Mon Sep 17 00:00:00 2001 From: chc4 Date: Tue, 12 May 2015 17:22:07 -0400 Subject: [PATCH 09/12] Small fix Typo, and make it clearer that the updates happen automagically instead of only being downloaded, with you having to apply them. --- README.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 6bd7e050e..5493b27ad 100644 --- a/README.markdown +++ b/README.markdown @@ -409,14 +409,14 @@ same time. This will confuse everyone, including yourself. Sometimes we make changes to Hoon or Arvo (we never make changes to Nock) and you need to update your ship. -Luckily, Arvo has some special sauce that allows it the same carriers +Luckily, Arvo has some special sauce that allows the same carrier you initially pulled your files from to push kernel update over-the-air. -You may notice this happening from time to time through mysterious messages +You may notice this happening automatically from time to time through mysterious messages such as: ['merge succeeded' {}] -These updates can be applied without having to restart Arvo or any of its +These updates will be applied without having to restart Arvo or any of its `%vanes`. All of your state, including running tasks, will be unchanged. Sometimes the interpreter, called `vere` gets updated. In your urbit directory, back in Unixland, run: From 55c3827fb476ca92eb8e57a9225f47f51c1c7876 Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Tue, 12 May 2015 17:39:45 -0400 Subject: [PATCH 10/12] removed -g from c++ compiling --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c001315d2..c94d85fdc 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ RM=rm -f CC=gcc CXX=g++ CXXFLAGS=$(CFLAGS) -CLD=g++ -g -L/usr/local/lib -L/opt/local/lib +CLD=g++ -O3 -L/usr/local/lib -L/opt/local/lib ifeq ($(OS),osx) COSFLAGS=-fno-diagnostics-fixit-info From 816205e708785fdbf58de2f88c9aeec8df9e04e0 Mon Sep 17 00:00:00 2001 From: vere Date: Wed, 13 May 2015 00:11:11 +0000 Subject: [PATCH 11/12] split out road memory data --- v/raft.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/v/raft.c b/v/raft.c index d4b0d7c71..4a82ebc28 100644 --- a/v/raft.c +++ b/v/raft.c @@ -1855,7 +1855,9 @@ static void _raft_grab(u3_noun ova) { if ( u3_nul != u3A->sac ) { - c3_w usr_w = 0, ova_w = 0, sac_w = 0, utv_w = 0, utm_w = 0, wep_w = 0; + c3_w usr_w = 0, ova_w = 0, sac_w = 0, utv_w = 0, utm_w = 0, wep_w = 0, + har_w = 0, das_w = 0, flu_w = 0, tax_w = 0, mer_w = 0, don_w = 0, + day_w = 0, car_w = 0; fprintf(stderr, "\r\n"); usr_w = _raft_prof(u3_nul, 0, u3A->sac); @@ -1874,8 +1876,40 @@ _raft_grab(u3_noun ova) fprintf(stderr, "arvo stuff: "); _raft_print_memory(utv_w); - utm_w = u3m_mark(); - fprintf(stderr, "road stuff: "); + har_w = u3h_mark(u3R->jed.har_p); + fprintf(stderr, " warm jet state: "); + _raft_print_memory(har_w); + + das_w = u3a_mark_noun(u3R->jed.das); + fprintf(stderr, " cold jet state: "); + _raft_print_memory(das_w); + + flu_w = u3a_mark_noun(u3R->ski.flu); + fprintf(stderr, " namespace: "); + _raft_print_memory(flu_w); + + tax_w = u3a_mark_noun(u3R->bug.tax); + fprintf(stderr, " trace stack list: "); + _raft_print_memory(tax_w); + + mer_w = u3a_mark_noun(u3R->bug.mer); + fprintf(stderr, " trace stack buffer: "); + _raft_print_memory(mer_w); + + don_w = u3a_mark_noun(u3R->pro.don); + fprintf(stderr, " profile battery list: "); + _raft_print_memory(don_w); + + day_w = u3a_mark_noun(u3R->pro.day); + fprintf(stderr, " profile doss: "); + _raft_print_memory(day_w); + + car_w = u3h_mark(u3R->cax.har_p); + fprintf(stderr, " memoization: "); + _raft_print_memory(car_w); + + utm_w = har_w + das_w + flu_w + tax_w + mer_w + don_w + day_w + car_w; + fprintf(stderr, "total road stuff: "); _raft_print_memory(utm_w); fprintf(stderr, "total marked: "); From 9b9fe1bfb4d8437fc85fff1501e8b6c672c807a0 Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Wed, 13 May 2015 18:23:20 -0400 Subject: [PATCH 12/12] plug memoization leak --- n/n.c | 5 ++++- v/raft.c | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/n/n.c b/n/n.c index ceed42d74..61af0fd41 100644 --- a/n/n.c +++ b/n/n.c @@ -86,7 +86,10 @@ _n_hint(u3_noun zep, } pro = _n_nock_on(u3k(bus), u3k(nex)); - u3z_save_2(c3__nock, bus, nex, pro); + if ( u3R != &(u3H->rod_u) ) { + u3z_save_2(c3__nock, bus, nex, pro); + } + u3z(bus); u3z(nex); return pro; diff --git a/v/raft.c b/v/raft.c index 4a82ebc28..72f65beba 100644 --- a/v/raft.c +++ b/v/raft.c @@ -1859,6 +1859,8 @@ _raft_grab(u3_noun ova) har_w = 0, das_w = 0, flu_w = 0, tax_w = 0, mer_w = 0, don_w = 0, day_w = 0, car_w = 0; + c3_assert( u3R == &(u3H->rod_u) ); + fprintf(stderr, "\r\n"); usr_w = _raft_prof(u3_nul, 0, u3A->sac); fprintf(stderr, "total userspace: "); @@ -1919,6 +1921,9 @@ _raft_grab(u3_noun ova) fprintf(stderr, "sweep: "); _raft_print_memory(wep_w); + u3h_free(u3R->cax.har_p); + u3R->cax.har_p = u3h_new(); + u3z(u3A->sac); u3A->sac = u3_nul; }