Skip to content

Commit

Permalink
cli: accept cache size args
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-levan committed Aug 23, 2023
1 parent 611fcc3 commit 22cebf6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 11 deletions.
6 changes: 2 additions & 4 deletions pkg/noun/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion pkg/noun/nock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) ) &&
Expand Down
2 changes: 2 additions & 0 deletions pkg/noun/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/noun/zave.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
11 changes: 9 additions & 2 deletions pkg/vere/lord.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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
Expand All @@ -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);
Expand Down
23 changes: 20 additions & 3 deletions pkg/vere/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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;
Expand All @@ -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': {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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];
Expand All @@ -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);
Expand All @@ -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) ) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/vere/vere.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 22cebf6

Please sign in to comment.