From d8aed4d4afa365fcec2d0123d2c699073b706cee Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 22 Jun 2020 17:21:59 -0700 Subject: [PATCH 1/8] noun: add functions to count size of noun Adds a few functions to count the size of nouns in the current road. Since this marks the nouns (high bit of refcount), you need to "discount" them immediately after to unmark them. Parallel functions exist for the counting the size of a hashtable. It would nice to hook this up to a hint, but these are useful to have available to run in the debugger or by inserting callsites as necessary. It's also possible to hook them up to the +jam jet gated on a special value. --- pkg/urbit/include/noun/allocate.h | 18 ++++ pkg/urbit/include/noun/hashtable.h | 10 ++ pkg/urbit/noun/allocate.c | 150 +++++++++++++++++++++++++++ pkg/urbit/noun/hashtable.c | 160 +++++++++++++++++++++++++++++ 4 files changed, 338 insertions(+) diff --git a/pkg/urbit/include/noun/allocate.h b/pkg/urbit/include/noun/allocate.h index 0afff6721..934b70328 100644 --- a/pkg/urbit/include/noun/allocate.h +++ b/pkg/urbit/include/noun/allocate.h @@ -465,6 +465,24 @@ c3_w u3a_mark_road(FILE* fil_u); + /* u3a_count_noun(): count size of noun. + */ + c3_w + u3a_count_noun(u3_noun som); + + /* u3a_discount_noun(): clean up after counting a noun. + */ + c3_w + u3a_discount_noun(u3_noun som); + + /* u3a_count_ptr(): count a pointer for gc. Produce size. */ + c3_w + u3a_count_ptr(void* ptr_v); + + /* u3a_discount_ptr(): discount a pointer for gc. Produce size. */ + c3_w + u3a_discount_ptr(void* ptr_v); + /* u3a_idle(): measure free-lists in [rod_u] */ c3_w diff --git a/pkg/urbit/include/noun/hashtable.h b/pkg/urbit/include/noun/hashtable.h index 793519d52..a6457ad95 100644 --- a/pkg/urbit/include/noun/hashtable.h +++ b/pkg/urbit/include/noun/hashtable.h @@ -139,6 +139,16 @@ c3_w u3h_mark(u3p(u3h_root) har_p); + /* u3h_count(): count hashtable for gc. + */ + c3_w + u3h_count(u3p(u3h_root) har_p); + + /* u3h_discount(): discount hashtable for gc. + */ + c3_w + u3h_discount(u3p(u3h_root) har_p); + /* u3h_walk_with(): traverse hashtable with key, value fn and data * argument; RETAINS. */ diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index 13706bba2..ea44ef168 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -1721,6 +1721,156 @@ u3a_mark_noun(u3_noun som) } } +/* u3a_count_noun(): count size of pointer. +*/ +c3_w +u3a_count_ptr(void* ptr_v) +{ + if ( _(u3a_is_north(u3R)) ) { + if ( !((ptr_v >= u3a_into(u3R->rut_p)) && + (ptr_v < u3a_into(u3R->hat_p))) ) + { + return 0; + } + } + else { + if ( !((ptr_v >= u3a_into(u3R->hat_p)) && + (ptr_v < u3a_into(u3R->rut_p))) ) + { + return 0; + } + } + { + u3a_box* box_u = u3a_botox(ptr_v); + c3_w siz_w; + + c3_ws use_ws = (c3_ws)box_u->use_w; + + if ( use_ws == 0 ) { + fprintf(stderr, "%p is bogus\r\n", ptr_v); + siz_w = 0; + } + else { + c3_assert(use_ws != 0); + + if ( use_ws < 0 ) { + siz_w = 0; + } + else { + use_ws = -use_ws; + siz_w = box_u->siz_w; + } + box_u->use_w = (c3_w)use_ws; + } + return siz_w; + } +} + +/* u3a_count_noun(): count size of noun. +*/ +c3_w +u3a_count_noun(u3_noun som) +{ + c3_w siz_w = 0; + + while ( 1 ) { + if ( _(u3a_is_senior(u3R, som)) ) { + return siz_w; + } + else { + c3_w* dog_w = u3a_to_ptr(som); + c3_w new_w = u3a_count_ptr(dog_w); + + if ( 0 == new_w ) { + return siz_w; + } + else { + siz_w += new_w; + if ( _(u3du(som)) ) { + siz_w += u3a_count_noun(u3h(som)); + som = u3t(som); + } + else return siz_w; + } + } + } +} + +/* u3a_discount_ptr(): clean up after counting a pointer. +*/ +c3_w +u3a_discount_ptr(void* ptr_v) +{ + if ( _(u3a_is_north(u3R)) ) { + if ( !((ptr_v >= u3a_into(u3R->rut_p)) && + (ptr_v < u3a_into(u3R->hat_p))) ) + { + return 0; + } + } + else { + if ( !((ptr_v >= u3a_into(u3R->hat_p)) && + (ptr_v < u3a_into(u3R->rut_p))) ) + { + return 0; + } + } + u3a_box* box_u = u3a_botox(ptr_v); + c3_w siz_w; + + c3_ws use_ws = (c3_ws)box_u->use_w; + + if ( use_ws == 0 ) { + fprintf(stderr, "%p is bogus\r\n", ptr_v); + siz_w = 0; + } + else { + c3_assert(use_ws != 0); + + if ( use_ws < 0 ) { + use_ws = -use_ws; + siz_w = box_u->siz_w; + } + else { + siz_w = 0; + } + box_u->use_w = (c3_w)use_ws; + } + + return siz_w; +} + +/* u3a_discount_noun(): clean up after counting a noun. +*/ +c3_w +u3a_discount_noun(u3_noun som) +{ + c3_w siz_w = 0; + + while ( 1 ) { + if ( _(u3a_is_senior(u3R, som)) ) { + return siz_w; + } + else { + c3_w* dog_w = u3a_to_ptr(som); + c3_w new_w = u3a_discount_ptr(dog_w); + + if ( 0 == new_w ) { + return siz_w; + } + else { + siz_w += new_w; + if ( _(u3du(som)) ) { + siz_w += u3a_discount_noun(u3h(som)); + som = u3t(som); + } + else return siz_w; + } + } + } +} + + /* u3a_print_memory: print memory amount. */ void diff --git a/pkg/urbit/noun/hashtable.c b/pkg/urbit/noun/hashtable.c index 95a6f0d4e..3eb7152be 100644 --- a/pkg/urbit/noun/hashtable.c +++ b/pkg/urbit/noun/hashtable.c @@ -941,3 +941,163 @@ u3h_mark(u3p(u3h_root) har_p) return tot_w; } + +/* _ch_count_buck(): count bucket for gc. +*/ +c3_w +_ch_count_buck(u3h_buck* hab_u) +{ + c3_w tot_w = 0; + c3_w i_w; + + for ( i_w = 0; i_w < hab_u->len_w; i_w++ ) { + tot_w += u3a_count_noun(u3h_slot_to_noun(hab_u->sot_w[i_w])); + } + tot_w += u3a_count_ptr(hab_u); + + return tot_w; +} + +/* _ch_count_node(): count node for gc. +*/ +c3_w +_ch_count_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; + + lef_w -= 5; + + for ( i_w = 0; i_w < len_w; i_w++ ) { + c3_w sot_w = han_u->sot_w[i_w]; + + if ( _(u3h_slot_is_noun(sot_w)) ) { + u3_noun kev = u3h_slot_to_noun(sot_w); + + tot_w += u3a_count_noun(kev); + } + else { + void* hav_v = u3h_slot_to_node(sot_w); + + if ( 0 == lef_w ) { + tot_w += _ch_count_buck(hav_v); + } else { + tot_w += _ch_count_node(hav_v, lef_w); + } + } + } + + tot_w += u3a_count_ptr(han_u); + + return tot_w; +} + +/* u3h_count(): count hashtable for gc. +*/ +c3_w +u3h_count(u3p(u3h_root) har_p) +{ + c3_w tot_w = 0; + u3h_root* har_u = u3to(u3h_root, har_p); + c3_w i_w; + + for ( i_w = 0; i_w < 64; i_w++ ) { + c3_w sot_w = har_u->sot_w[i_w]; + + if ( _(u3h_slot_is_noun(sot_w)) ) { + u3_noun kev = u3h_slot_to_noun(sot_w); + + tot_w += u3a_count_noun(kev); + } + else if ( _(u3h_slot_is_node(sot_w)) ) { + u3h_node* han_u = u3h_slot_to_node(sot_w); + + tot_w += _ch_count_node(han_u, 25); + } + } + + tot_w += u3a_count_ptr(har_u); + + return tot_w; +} + +/* _ch_discount_buck(): discount bucket for gc. +*/ +c3_w +_ch_discount_buck(u3h_buck* hab_u) +{ + c3_w tot_w = 0; + c3_w i_w; + + for ( i_w = 0; i_w < hab_u->len_w; i_w++ ) { + tot_w += u3a_discount_noun(u3h_slot_to_noun(hab_u->sot_w[i_w])); + } + tot_w += u3a_discount_ptr(hab_u); + + return tot_w; +} + +/* _ch_discount_node(): discount node for gc. +*/ +c3_w +_ch_discount_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; + + lef_w -= 5; + + for ( i_w = 0; i_w < len_w; i_w++ ) { + c3_w sot_w = han_u->sot_w[i_w]; + + if ( _(u3h_slot_is_noun(sot_w)) ) { + u3_noun kev = u3h_slot_to_noun(sot_w); + + tot_w += u3a_discount_noun(kev); + } + else { + void* hav_v = u3h_slot_to_node(sot_w); + + if ( 0 == lef_w ) { + tot_w += _ch_discount_buck(hav_v); + } else { + tot_w += _ch_discount_node(hav_v, lef_w); + } + } + } + + tot_w += u3a_discount_ptr(han_u); + + return tot_w; +} + +/* u3h_discount(): discount hashtable for gc. +*/ +c3_w +u3h_discount(u3p(u3h_root) har_p) +{ + c3_w tot_w = 0; + u3h_root* har_u = u3to(u3h_root, har_p); + c3_w i_w; + + for ( i_w = 0; i_w < 64; i_w++ ) { + c3_w sot_w = har_u->sot_w[i_w]; + + if ( _(u3h_slot_is_noun(sot_w)) ) { + u3_noun kev = u3h_slot_to_noun(sot_w); + + tot_w += u3a_discount_noun(kev); + } + else if ( _(u3h_slot_is_node(sot_w)) ) { + u3h_node* han_u = u3h_slot_to_node(sot_w); + + tot_w += _ch_discount_node(han_u, 25); + } + } + + tot_w += u3a_discount_ptr(har_u); + + return tot_w; +} From fa6748a7e1a8789374c77322e586b6612cab893c Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 22 Jun 2020 18:53:32 -0700 Subject: [PATCH 2/8] jets: cap memo cache and remove peek, play, and fond jets With these changes, about 90% less memory and 15% less time is needed to compile hoon.hoon. The produced noun is within 3% of the same size, which suggests this results in little if any duplication. These are three of the four most commonly hit +ut jets. The other is +nest, which cannot be un-memoized without taking much longer to compile (it didn't finish in my test). These four jets combined for 2.3 million out of the 2.4 million cache entries, the other +ut jets combine for less than 100k, and literal ~+ accounted for about 50k entries. This also caps the memo cache at 50k entries. Even with these jets not memoized, the memo cache grows to 357k entries and 122 MB. Capping at 50k entries has no effect on time and reduces memory usage of the hash table to about 25MB. Entries are reclaimed with the clock algorithm, which seems to be sufficient for this use. --- pkg/urbit/jets/f/ut_fond.c | 34 ---------------------------------- pkg/urbit/jets/f/ut_peek.c | 34 ---------------------------------- pkg/urbit/jets/f/ut_play.c | 31 ------------------------------- pkg/urbit/jets/tree.c | 21 --------------------- pkg/urbit/noun/manage.c | 2 +- 5 files changed, 1 insertion(+), 121 deletions(-) delete mode 100644 pkg/urbit/jets/f/ut_fond.c delete mode 100644 pkg/urbit/jets/f/ut_peek.c delete mode 100644 pkg/urbit/jets/f/ut_play.c diff --git a/pkg/urbit/jets/f/ut_fond.c b/pkg/urbit/jets/f/ut_fond.c deleted file mode 100644 index 588b89931..000000000 --- a/pkg/urbit/jets/f/ut_fond.c +++ /dev/null @@ -1,34 +0,0 @@ -/* j/6/find.c -** -*/ -#include "all.h" - -u3_noun -u3wfu_fond(u3_noun cor) -{ - u3_noun sut, way, hyp, van; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &way, - u3x_sam_3, &hyp, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } - else { - c3_m fun_m = 141 + c3__fond + ((!!u3r_at(u3qfu_van_vet, van)) << 8); - u3_noun key = u3z_key_3(fun_m, sut, way, hyp); - u3_weak pro = u3z_find(key); - - if ( u3_none != pro ) { - u3z(key); - return pro; - } - else { - pro = u3n_nock_on(u3k(cor), u3k(u3x_at(u3x_bat, cor))); - return u3z_save(key, pro); - } - } -} - diff --git a/pkg/urbit/jets/f/ut_peek.c b/pkg/urbit/jets/f/ut_peek.c deleted file mode 100644 index cd9ba3178..000000000 --- a/pkg/urbit/jets/f/ut_peek.c +++ /dev/null @@ -1,34 +0,0 @@ -/* j/6/peek.c -** -*/ -#include "all.h" - -u3_noun -u3wfu_peek(u3_noun cor) -{ - u3_noun sut, way, axe, van; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &way, - u3x_sam_3, &axe, - u3x_con, &van, - 0)) || - (c3n == u3ud(axe)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } - else { - c3_m fun_m = 141 + c3__peek + ((!!u3r_at(u3qfu_van_vet, van)) << 8); - u3_noun key = u3z_key_3(fun_m, sut, way, axe); - u3_weak pro = u3z_find(key); - - if ( u3_none != pro ) { - u3z(key); - return pro; - } - else { - pro = u3n_nock_on(u3k(cor), u3k(u3x_at(u3x_bat, cor))); - return u3z_save(key, pro); - } - } -} diff --git a/pkg/urbit/jets/f/ut_play.c b/pkg/urbit/jets/f/ut_play.c deleted file mode 100644 index a11b0fae7..000000000 --- a/pkg/urbit/jets/f/ut_play.c +++ /dev/null @@ -1,31 +0,0 @@ -/* j/6/play.c -** -*/ -#include "all.h" - -u3_noun -u3wfu_play(u3_noun cor) -{ - u3_noun sut, gen, van; - - if ( (c3n == u3r_mean(cor, u3x_sam, &gen, u3x_con, &van, 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } - else { - c3_m fun_m = 141 + c3__play; - u3_noun vrf = u3r_at(u3qfu_van_vrf, van); - u3_noun key = u3z_key_3(fun_m, vrf, sut, gen); - u3_weak pro = u3z_find(key); - - if ( u3_none != pro ) { - u3z(key); - return pro; - } - else { - pro = u3n_nock_on(u3k(cor), u3k(u3x_at(u3x_bat, cor))); - return u3z_save(key, pro); - } - } -} diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index d25b06ead..b3a5dcd1e 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -477,11 +477,6 @@ static c3_c* _141_pen_loot_ha[] = { "d83e5e47f712870aba815d79943d287cbefdc00640409464b30bf755115d4a1a", 0 }; - static u3j_harm _141_pen__ut_fond_a[] = {{".2", u3wfu_fond}, {}}; - static c3_c* _141_pen__ut_fond_ha[] = { - "0da0cc79c938eb06515a5cc24a17b82cd60a50c0f1a02e2c68e5d1cf71c96054", - 0 - }; static u3j_harm _141_pen__ut_fish_a[] = {{".2", u3wfu_fish}, {}}; static c3_c* _141_pen__ut_fish_ha[] = { "2fd315436f48351002d9aa8c137649ca95b01fd57dba09db53d7235f84a284bf", @@ -516,16 +511,6 @@ static c3_c* _141_pen_loot_ha[] = { { "nest-in", 7, 0, _141_pen__ut_nest_in_d, _141_pen__ut_nest_in_ha }, {} }; - static u3j_harm _141_pen__ut_peek_a[] = {{".2", u3wfu_peek}, {}}; - static c3_c* _141_pen__ut_peek_ha[] = { - "904ff7359e89d1886f884c4409f104269cdb8dfb4683f116ff00bc98a4720df7", - 0 - }; - static u3j_harm _141_pen__ut_play_a[] = {{".2", u3wfu_play}, {}}; - static c3_c* _141_pen__ut_play_ha[] = { - "bdc5c072632f7133b4c64c465b1b214d7465b0c1163842b121b7369aba1b9b03", - 0 - }; static u3j_harm _141_pen__ut_rest_a[] = {{".2", u3wfu_rest}, {}}; static c3_c* _141_pen__ut_rest_ha[] = { "2e2d15f3efca0a4bf8ce08cca48c54d1d5a7204e2b0525137f59c3e7b037d2fd", @@ -535,14 +520,11 @@ static c3_c* _141_pen_loot_ha[] = { static u3j_core _141_pen__ut_d[] = { { "crop", 7, _141_pen__ut_crop_a, 0, _141_pen__ut_crop_ha }, - { "fond", 7, _141_pen__ut_fond_a, 0, _141_pen__ut_fond_ha }, { "fish", 7, _141_pen__ut_fish_a, 0, _141_pen__ut_fish_ha }, { "fuse", 7, _141_pen__ut_fuse_a, 0, _141_pen__ut_fuse_ha }, { "mint", 7, _141_pen__ut_mint_a, 0, _141_pen__ut_mint_ha }, { "mull", 7, _141_pen__ut_mull_a, 0, _141_pen__ut_mull_ha }, { "nest", 7, 0, _141_pen__ut_nest_d, _141_pen__ut_nest_ha }, - { "peek", 7, _141_pen__ut_peek_a, 0, _141_pen__ut_peek_ha }, - { "play", 7, _141_pen__ut_play_a, 0, _141_pen__ut_play_ha }, { "rest", 7, _141_pen__ut_rest_a, 0, _141_pen__ut_rest_ha }, {} }; @@ -575,7 +557,6 @@ static u3j_hood _141_pen__ut_ho[] = { { "fine", 49086 }, { "fire", 4 }, { "fish", 6006 }, - { "fond", 12283 }, { "fund", 6014 }, // XX +funk is not part of +ut, and this hook appears to be unused // remove from here and the +ut hint @@ -591,8 +572,6 @@ static u3j_hood _141_pen__ut_ho[] = { { "mull", 24020 }, { "nest", 92 }, { "peel", 1526 }, - { "play", 3006 }, - { "peek", 1532 }, { "repo", 22 }, { "rest", 6102 }, { "tack", 6007 }, diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index 663d16c29..b4c1968cb 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -496,7 +496,7 @@ _pave_south(c3_w* mem_w, c3_w siz_w, c3_w len_w) static void _pave_parts(void) { - u3R->cax.har_p = u3h_new(); + u3R->cax.har_p = u3h_new_cache(50000); u3R->jed.war_p = u3h_new(); u3R->jed.cod_p = u3h_new(); u3R->jed.han_p = u3h_new(); From 6c3b7aeef50d3e4888310e972503796c9ccda08a Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 22 Jun 2020 19:11:40 -0700 Subject: [PATCH 3/8] jam: add commented-out functionality to count size of atom This is a convenient way to count memory usage of noun by simplying running `(jam 1.337 noun-1 noun-2 ... ~)`. This should be a hint, but for debugging this is sufficient. --- pkg/urbit/jets/e/jam.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/pkg/urbit/jets/e/jam.c b/pkg/urbit/jets/e/jam.c index 2ce9faa78..1abf18a5b 100644 --- a/pkg/urbit/jets/e/jam.c +++ b/pkg/urbit/jets/e/jam.c @@ -6,6 +6,40 @@ u3_noun u3qe_jam(u3_atom a) { +#if 0 + if (c3y == u3du(a) && 1337 == u3h(a)) { + c3_w siz_w, tot_w = 0; + u3_noun som; + for ( som = u3t(a); c3y == u3du(som); som = u3t(som) ) { + siz_w = u3a_count_noun(u3h(som)); + tot_w += siz_w; + if ( 0 == siz_w ) { + u3l_log("item: B/0\r\n"); + } + else { + u3a_print_memory(stderr, "item", siz_w); + } + } + if ( u3_blip != som ) { + u3l_log("forgot to terminate list!\r\n"); + } + c3_w mem_w = u3h_count(u3R->cax.har_p); + + for ( som = u3t(a); c3y == u3du(som); som = u3t(som) ) u3a_discount_noun(u3h(som)); + u3h_discount(u3R->cax.har_p); + + u3a_print_memory(stderr, "total", tot_w); + u3a_print_memory(stderr, "memoization cache", mem_w); + u3h_root* har_u = u3to(u3h_root, u3R->cax.har_p); + u3l_log("memoization entries: %d\r\n", har_u->use_w); + c3_w diff = (u3R->hat_p < u3R->cap_p) ? + (u3R->cap_p - u3R->hat_p) : + (u3R->hat_p - u3R->cap_p); + u3a_print_memory(stderr, "unused free", diff); + return tot_w; + } +#endif + c3_w bit_w, *sal_w; c3_w* wor_w = u3s_jam_fib(a, &bit_w); c3_w len_w = bit_w >> 5; From 71fa03457cff302b254cac52247f13cf7cb6681d Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 24 Jun 2020 13:42:51 -0700 Subject: [PATCH 4/8] jets: restore fond/play/peek hooks --- pkg/urbit/jets/tree.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/urbit/jets/tree.c b/pkg/urbit/jets/tree.c index b3a5dcd1e..f92ca5a48 100644 --- a/pkg/urbit/jets/tree.c +++ b/pkg/urbit/jets/tree.c @@ -557,6 +557,7 @@ static u3j_hood _141_pen__ut_ho[] = { { "fine", 49086 }, { "fire", 4 }, { "fish", 6006 }, + { "fond", 12283 }, { "fund", 6014 }, // XX +funk is not part of +ut, and this hook appears to be unused // remove from here and the +ut hint @@ -572,6 +573,8 @@ static u3j_hood _141_pen__ut_ho[] = { { "mull", 24020 }, { "nest", 92 }, { "peel", 1526 }, + { "play", 3006 }, + { "peek", 1532 }, { "repo", 22 }, { "rest", 6102 }, { "tack", 6007 }, From 361e41e78d5e065412cada2aff7e90d334c3325b Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 24 Jun 2020 17:08:50 -0700 Subject: [PATCH 5/8] noun: add -C to control memo cache size --- pkg/urbit/daemon/main.c | 13 ++++++++++--- pkg/urbit/include/vere/vere.h | 1 + pkg/urbit/noun/manage.c | 3 ++- pkg/urbit/vere/pier.c | 7 +++++-- pkg/urbit/worker/main.c | 4 +++- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/pkg/urbit/daemon/main.c b/pkg/urbit/daemon/main.c index 02f69acf8..657d1c2ac 100644 --- a/pkg/urbit/daemon/main.c +++ b/pkg/urbit/daemon/main.c @@ -93,10 +93,11 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.tex = c3n; u3_Host.ops_u.tra = c3n; u3_Host.ops_u.veb = c3n; + u3_Host.ops_u.hap_w = 50000; u3_Host.ops_u.kno_w = DefaultKernel; while ( -1 != (ch_i=getopt(argc, argv, - "G:J:B:K:A:H:I:w:u:e:F:k:p:LljacdgqstvxPDRS")) ) + "G:J:B:K:A:H:I:C:w:u:e:F:k:p:LljacdgqstvxPDRS")) ) { switch ( ch_i ) { case 'J': { @@ -123,6 +124,12 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.jin_c = strdup(optarg); break; } + case 'C': { + if ( c3n == _main_readw(optarg, 1000000000, &u3_Host.ops_u.hap_w) ) { + return c3n; + } + break; + } case 'e': { u3_Host.ops_u.eth_c = strdup(optarg); break; @@ -367,9 +374,9 @@ u3_ve_usage(c3_i argc, c3_c** argv) "where ship_name is a @p phonetic representation of an urbit address\n", "without the leading '~', and options is some subset of the following:\n", "\n", - // XX find a way to re-enable - // "-A dir Use dir for initial galaxy sync\n", + "-A dir Use dir for initial clay sync\n", "-B pill Bootstrap from this pill\n", + "-C limit Set memo cache max size; 0 means uncapped\n", "-c pier Create a new urbit in pier/\n", "-D Recompute from events\n", "-d Daemon mode; implies -t\n", diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index f8e545219..41a539b80 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -559,6 +559,7 @@ c3_o gab; // -g, test garbage collection c3_c* dns_c; // -H, ames bootstrap domain c3_c* jin_c; // -I, inject raw event + c3_w hap_w; // -C, cap memo cache c3_c* lit_c; // -J, ivory (fastboot) kernel c3_o tra; // -j, json trace c3_w kno_w; // -K, kernel version diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index b4c1968cb..f5127be74 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -10,6 +10,7 @@ #include #include "all.h" +#include "vere/vere.h" // XX stack-overflow recovery should be gated by -a // @@ -496,7 +497,7 @@ _pave_south(c3_w* mem_w, c3_w siz_w, c3_w len_w) static void _pave_parts(void) { - u3R->cax.har_p = u3h_new_cache(50000); + u3R->cax.har_p = u3h_new_cache(u3_Host.ops_u.hap_w); u3R->jed.war_p = u3h_new(); u3R->jed.cod_p = u3h_new(); u3R->jed.han_p = u3h_new(); diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index fff3f1558..0c5b11442 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -1039,11 +1039,12 @@ _pier_work_create(u3_pier* pir_u) /* spawn new process and connect to it */ { - c3_c* arg_c[5]; + c3_c* arg_c[6]; c3_c* bin_c = u3_Host.wrk_c; c3_c* pax_c = pir_u->pax_c; c3_c key_c[256]; c3_c wag_c[11]; + c3_c hap_c[11]; c3_i err_i; sprintf(key_c, "%" PRIx64 ":%" PRIx64 ":%" PRIx64 ":%" PRIx64 "", @@ -1053,12 +1054,14 @@ _pier_work_create(u3_pier* pir_u) pir_u->key_d[3]); sprintf(wag_c, "%u", pir_u->wag_w); + sprintf(hap_c, "%u", u3_Host.ops_u.hap_w); arg_c[0] = bin_c; // executable arg_c[1] = pax_c; // path to checkpoint directory arg_c[2] = key_c; // disk key arg_c[3] = wag_c; // runtime config - arg_c[4] = 0; + arg_c[4] = hap_c; // hash table size + arg_c[5] = 0; uv_pipe_init(u3L, &god_u->inn_u.pyp_u, 0); uv_pipe_init(u3L, &god_u->out_u.pyp_u, 0); diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index d3148773b..064029a6c 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -1015,8 +1015,9 @@ main(c3_i argc, c3_c* argv[]) c3_c* dir_c = argv[1]; c3_c* key_c = argv[2]; c3_c* wag_c = argv[3]; + c3_c* hap_c = argv[4]; - c3_assert(4 == argc); + c3_assert(5 == argc); memset(&u3V, 0, sizeof(u3V)); memset(&u3_Host.tra_u, 0, sizeof(u3_Host.tra_u)); @@ -1035,6 +1036,7 @@ main(c3_i argc, c3_c* argv[]) */ { sscanf(wag_c, "%" SCNu32, &u3C.wag_w); + sscanf(hap_c, "%" SCNu32, &u3_Host.ops_u.hap_w); } /* load pier directory From f9d02263eeee9d7b356f79b05642d2987e5ddf22 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 24 Jun 2020 17:11:46 -0700 Subject: [PATCH 6/8] jets: use appropriate macro --- pkg/urbit/jets/e/jam.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/urbit/jets/e/jam.c b/pkg/urbit/jets/e/jam.c index 1abf18a5b..9b0502d0d 100644 --- a/pkg/urbit/jets/e/jam.c +++ b/pkg/urbit/jets/e/jam.c @@ -32,10 +32,7 @@ u3qe_jam(u3_atom a) u3a_print_memory(stderr, "memoization cache", mem_w); u3h_root* har_u = u3to(u3h_root, u3R->cax.har_p); u3l_log("memoization entries: %d\r\n", har_u->use_w); - c3_w diff = (u3R->hat_p < u3R->cap_p) ? - (u3R->cap_p - u3R->hat_p) : - (u3R->hat_p - u3R->cap_p); - u3a_print_memory(stderr, "unused free", diff); + u3a_print_memory(stderr, "unused free", u3a_open(u3R)); return tot_w; } #endif From 627df6d41ffead77fb4c6211a799afd4fc651bdd Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 24 Jun 2020 18:36:40 -0700 Subject: [PATCH 7/8] ci: add travis as trusted user --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6fbfc591e..0a575fc1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ jobs: nix: 2.3.6 before_install: - git lfs pull + - echo "trusted-users = root travis" | sudo tee -a /etc/nix/nix.conf && sudo pkill nix-daemon install: - nix-env -iA cachix -f https://cachix.org/api/v1/install script: From cbb80e9e7d1cfa320df23ec7eb3fcf3698a89cbf Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 24 Jun 2020 19:09:03 -0700 Subject: [PATCH 8/8] vere: bump version to 0.10.6 --- pkg/urbit/configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/configure b/pkg/urbit/configure index ebf59d23d..9b518592e 100755 --- a/pkg/urbit/configure +++ b/pkg/urbit/configure @@ -2,7 +2,7 @@ set -e -URBIT_VERSION="0.10.5" +URBIT_VERSION="0.10.6" deps=" \ curl gmp sigsegv argon2 ed25519 ent h2o scrypt sni uv murmur3 secp256k1 \