diff --git a/pkg/noun/manage.c b/pkg/noun/manage.c index e706379c50..726444081a 100644 --- a/pkg/noun/manage.c +++ b/pkg/noun/manage.c @@ -474,10 +474,8 @@ u3m_mark(FILE* fil_u) static void _pave_parts(void) { - // TODO: pass `u3_Host.ops_u.hap_w` into `noun` library as an argument and use - // as size of memo cache. - u3R->cax.har_p = u3h_new_cache(50000); // transient - u3R->cax.per_p = u3h_new_cache(5000); // persistent + u3R->cax.har_p = u3h_new_cache(u3C.hap_w); // transient + u3R->cax.per_p = u3h_new_cache(u3C.per_w); // persistent u3R->jed.war_p = u3h_new(); u3R->jed.cod_p = u3h_new(); u3R->jed.han_p = u3h_new(); diff --git a/pkg/noun/nock.c b/pkg/noun/nock.c index 1ca6d52065..e495920e06 100644 --- a/pkg/noun/nock.c +++ b/pkg/noun/nock.c @@ -2634,7 +2634,8 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) o = *top; if ( ( u3z_memo_toss == u3h(o) ) ? ( &(u3H->rod_u) != u3R ) - : ( 0 == u3R->ski.gul ) ) { // prevents userspace from persistence + // : ( 0 == u3R->ski.gul ) ) { // prevents userspace from persistence + : ( 1 ) ) { // prevents userspace from persistence u3z_save_m(u3h(o), 144 + c3__nock, u3t(o), x); } else if ( ( u3z_memo_keep == u3h(o) ) && diff --git a/pkg/noun/options.h b/pkg/noun/options.h index 1bd65320fc..9eb3e35c9c 100644 --- a/pkg/noun/options.h +++ b/pkg/noun/options.h @@ -25,6 +25,8 @@ size_t wor_i; // loom word-length (<= u3a_words) c3_w tos_w; // loom toss skip-length + c3_w hap_w; // transient memoization cache size + c3_w per_w; // persistent memoization cache size void (*stderr_log_f)(c3_c*); // errors from c code void (*slog_f)(u3_noun); // function pointer for slog void (*sign_hold_f)(void); // suspend system signal regime diff --git a/pkg/noun/zave.c b/pkg/noun/zave.c index 4a7131f01b..a3b2228c9f 100644 --- a/pkg/noun/zave.c +++ b/pkg/noun/zave.c @@ -63,6 +63,7 @@ u3z_find(u3z_cid cid, u3_noun key) while ( 1 ) { u3_weak got = u3h_get(_har(rod_u, cid), key); if ( u3_none != got ) { + fprintf(stderr, "\r\nHIT MY BOY!\r\n"); return got; } if ( 0 == rod_u->kid_p ) { diff --git a/pkg/vere/lord.c b/pkg/vere/lord.c index cf1dfcfba9..114fad8504 100644 --- a/pkg/vere/lord.c +++ b/pkg/vere/lord.c @@ -1160,10 +1160,11 @@ u3_lord_init(c3_c* pax_c, c3_w wag_w, c3_d key_d[4], u3_lord_cb cb_u) // spawn new process and connect to it // { - c3_c* arg_c[11]; + c3_c* arg_c[12]; c3_c key_c[256]; c3_c wag_c[11]; c3_c hap_c[11]; + c3_c per_c[11]; c3_c cev_c[11]; c3_c lom_c[11]; c3_c tos_c[11]; @@ -1177,12 +1178,16 @@ u3_lord_init(c3_c* pax_c, c3_w wag_w, c3_d key_d[4], u3_lord_cb cb_u) sprintf(wag_c, "%u", god_u->wag_w); + // XX hap_w sprintf(hap_c, "%u", u3_Host.ops_u.hap_w); + sprintf(per_c, "%u", u3_Host.ops_u.per_w); + sprintf(lom_c, "%u", u3_Host.ops_u.lom_y); sprintf(tos_c, "%u", u3C.tos_w); + // XX arg_c[0] = god_u->bin_c; // executable arg_c[1] = "serf"; // protocol arg_c[2] = god_u->pax_c; // path to checkpoint directory @@ -1208,7 +1213,9 @@ u3_lord_init(c3_c* pax_c, c3_w wag_w, c3_d key_d[4], u3_lord_cb cb_u) } arg_c[9] = tos_c; - arg_c[10] = NULL; + arg_c[10] = per_c; + arg_c[11] = NULL; + uv_pipe_init(u3L, &god_u->inn_u.pyp_u, 0); uv_timer_init(u3L, &god_u->out_u.tim_u); diff --git a/pkg/vere/main.c b/pkg/vere/main.c index f83d656e98..c35b7ff2e4 100644 --- a/pkg/vere/main.c +++ b/pkg/vere/main.c @@ -183,6 +183,9 @@ _main_init(void) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.puf_c = "jam"; u3_Host.ops_u.hap_w = 50000; + u3C.hap_w = u3_Host.ops_u.hap_w; + u3_Host.ops_u.per_w = 50000; + u3C.per_w = u3_Host.ops_u.per_w; u3_Host.ops_u.kno_w = DefaultKernel; u3_Host.ops_u.sap_w = 120; /* aka 2 minutes */ @@ -247,6 +250,7 @@ _main_getopt(c3_i argc, c3_c** argv) { "loom", required_argument, NULL, c3__loom }, { "local", no_argument, NULL, 'L' }, { "lite-boot", no_argument, NULL, 'l' }, + { "keep-cache-limit", required_argument, NULL, 'M' }, { "replay-to", required_argument, NULL, 'n' }, { "profile", no_argument, NULL, 'P' }, { "ames-port", required_argument, NULL, 'p' }, @@ -279,7 +283,7 @@ _main_getopt(c3_i argc, c3_c** argv) }; while ( -1 != (ch_i=getopt_long(argc, argv, - "A:B:C:DF:G:H:I:J:K:LPRSX:Y:Z:ab:c:de:gi:jk:ln:p:qr:stu:vw:x", + "A:B:C:DF:G:H:I:J:K:LM:PRSX:Y:Z:ab:c:de:gi:jk:ln:p:qr:stu:vw:x", lop_u, &lid_i)) ) { switch ( ch_i ) { @@ -342,7 +346,7 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } else { u3_Host.ops_u.sap_w = arg_w * 60; - if ( 0 == u3_Host.ops_u.sap_w) + if ( 0 == u3_Host.ops_u.sap_w ) return c3n; } break; @@ -365,6 +369,7 @@ _main_getopt(c3_i argc, c3_c** argv) if ( c3n == _main_readw(optarg, 1000000000, &u3_Host.ops_u.hap_w) ) { return c3n; } + u3C.hap_w = u3_Host.ops_u.hap_w; break; } case 'c': { @@ -412,6 +417,13 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.key_c = _main_repath(optarg); break; } + case 'M': { + if ( c3n == _main_readw(optarg, 1000000000, &u3_Host.ops_u.per_w) ) { + return c3n; + } + u3C.per_w = u3_Host.ops_u.per_w; + break; + } case 'n': { u3_Host.ops_u.til_c = strdup(optarg); break; @@ -764,6 +776,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-L, --local Local networking only\n", " --loom Set loom to binary exponent (31 == 2GB)\n" "-l, --lite-boot Most-minimal startup\n", + "-M, --keep-cache-limit LIMIT Set persistent memo cache max size; 0 means default\n", "-n, --replay-to NUMBER Replay up to event\n", "-P, --profile Profiling\n", "-p, --ames-port PORT Set the ames port to bind to\n", @@ -1075,6 +1088,8 @@ _cw_serf_commence(c3_i argc, c3_c* argv[]) exit(1); } + // XX use named arguments and getopt + c3_d eve_d = 0; uv_loop_t* lup_u = u3_Host.lup_u = uv_default_loop(); c3_c* dir_c = argv[2]; @@ -1086,6 +1101,7 @@ _cw_serf_commence(c3_i argc, c3_c* argv[]) c3_c* eve_c = argv[7]; c3_c* eph_c = argv[8]; c3_c* tos_c = argv[9]; + c3_c* per_c = argv[10]; c3_w tos_w; _cw_init_io(lup_u); @@ -1110,7 +1126,8 @@ _cw_serf_commence(c3_i argc, c3_c* argv[]) // XX check return // sscanf(wag_c, "%" SCNu32, &u3C.wag_w); - sscanf(hap_c, "%" SCNu32, &u3_Host.ops_u.hap_w); + sscanf(hap_c, "%" SCNu32, &u3C.hap_w); + sscanf(per_c, "%" SCNu32, &u3C.per_w); sscanf(lom_c, "%" SCNu32, &lom_w); if ( 1 != sscanf(tos_c, "%" SCNu32, &u3C.tos_w) ) { diff --git a/pkg/vere/vere.h b/pkg/vere/vere.h index cef16810b6..2bf976c1dd 100644 --- a/pkg/vere/vere.h +++ b/pkg/vere/vere.h @@ -263,7 +263,7 @@ c3_o abo; // -a, abort aggressively c3_c* pil_c; // -B, bootstrap from c3_c* bin_c; // -b, http server bind ip - c3_w hap_w; // -C, cap memo cache + c3_w hap_w; // -C, cap transient memo cache c3_o dry; // -D, dry compute, no checkpoint c3_o dem; // -d, daemon c3_c* eth_c; // -e, ethereum node url @@ -281,6 +281,7 @@ c3_o lit; // -l, lite mode c3_y lom_y; // loom bex c3_y lut_y; // urth-loom bex + c3_w per_w; // -M, cap persistent memo cache c3_c* til_c; // -n, play till eve_d c3_o pro; // -P, profile c3_s per_s; // http port