Merge pull request #1188 from urbit/ccr-mass

implements |mass on cc-release, fixes leaks
This commit is contained in:
Joe Bryan 2019-02-07 14:03:13 -05:00 committed by GitHub
commit e83f883db6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 415 additions and 123 deletions

View File

@ -9,13 +9,18 @@ node_js:
# email: false
before_install:
# try to get pill early, so configuration errors will be quickly caught
#
- cd .travis
- bash get-brass-pill.sh
- cd ..
- wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip
- unzip ninja-linux.zip
- sudo mv ninja /usr/bin/
install:
# pwd: ~/urbit
- pip3 install --user -I meson==0.44.1
- pip3 install --user -I meson
script:
- meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true

15
.travis/get-brass-pill.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -euo pipefail
set -x
if [ ! -f ./pin-brass-pill.txt ]; then
echo "missing .travis/pin-brass-pill.txt"
exit 1
fi
PILL_NAME=$(cat ./pin-brass-pill.txt | tr -d [:space:])
wget https://bootstrap.urbit.org/$PILL_NAME -O brass.pill && exit 0
echo "$PILL_NAME download failed"
exit 1

View File

@ -1 +0,0 @@
6d6ec85d6aa9200d366d0998326726ef1965d092

View File

@ -0,0 +1 @@
urbit-0.7.2.brass.pill

View File

@ -6,10 +6,7 @@ var Urbit = runner.Urbit;
var ERROR = runner.ERROR;
var actions = runner.actions
var hash = fs.readFileSync('./pin-arvo-commit.txt', 'utf-8').slice(0, 10)
var pill = 'https://bootstrap.urbit.org/git-' + hash + '.pill'
var args = ['-u', pill, '-cgPSF', 'zod', 'zod'];
var args = ['-cgSF', 'zod', '-B', 'brass.pill', 'zod'];
var urbit = new Urbit(args);
// vere hangs (always?) with run in travis-ci with -P

View File

@ -324,6 +324,7 @@ softfloat3_dep = dependency('softfloat3', version: '>=3.0.0', fallback: ['softfl
# XX temporary, should only be needed in vere
#
libh2o_dep = dependency('libh2o', version: '>=0.13.3', fallback: ['libh2o', 'libh2o_dep'])
libuv_dep = dependency('libuv', version: '>=1.8.0', fallback:['libuv', 'libuv_dep'])
noun_deps = [argon2_dep,
@ -335,7 +336,8 @@ noun_deps = [argon2_dep,
secp256k1_dep,
sigsegv_dep,
softfloat3_dep,
libh2o_dep]
libh2o_dep,
libuv_dep]
libnoun = static_library('noun',
sources: [noun_src, jets_all_src],
@ -350,7 +352,6 @@ libnoun = static_library('noun',
#
libent_dep = dependency('libent', version: '>=0.2.1', fallback: ['libent', 'libent_dep'])
libsni_dep = dependency('libsni', version: '>=0.5.0', fallback: ['libsni', 'libsni_dep'])
libuv_dep = dependency('libuv', version: '>=1.8.0', fallback:['libuv', 'libuv_dep'])
libwhereami_dep = dependency('libwhereami', version: '>=1.0.0', fallback: ['whereami', 'libwhereami_dep'])
vere_deps = [curl_dep,

View File

@ -834,7 +834,7 @@ u3j_boot(c3_o nuu_o)
}
u3R->jed.hot_p = u3h_new();
jax_l = _cj_install(u3D.ray_u, 1, (c3_l) (long long) u3D.dev_u[0].par_u, u3_nul, u3D.dev_u);
fprintf(stderr, "boot: installed %d jets\n", jax_l);
fprintf(stderr, "boot: installed %d jets\r\n", jax_l);
}
/* _cj_soft(): kick softly by arm axis.

View File

@ -561,6 +561,8 @@ u3_king_commence()
//
sag_w = u3C.wag_w;
u3C.wag_w |= u3o_hashless;
u3C.wag_w &= ~u3o_debug_ram;
u3C.wag_w &= ~u3o_check_corrupt;
u3m_boot_pier();
{

View File

@ -107,6 +107,9 @@ _pier_disk_shutdown(u3_pier* pir_u)
static void
_pier_work_shutdown(u3_pier* pir_u)
{
u3_lord* god_u = pir_u->god_u;
u3_newt_write(&god_u->inn_u, u3ke_jam(u3nc(c3__exit, 0)), 0);
}
/* _pier_insert(): insert raw event.
@ -1581,6 +1584,7 @@ u3_pier_exit(void)
fprintf(stderr, "pier: exit\r\n");
_pier_work_save(pir_u);
_pier_work_shutdown(pir_u);
uv_stop(u3L);
}
}

View File

@ -131,8 +131,8 @@ _reck_kick_term(u3_pier* pir_u, u3_noun pox, c3_l tid_l, u3_noun fav)
case c3__mass: p_fav = u3t(fav);
{
u3A->sac = u3k(p_fav);
// XX GC the full king state
//
u3z(pox); u3z(fav); return c3y;
} break;
}

View File

@ -68,12 +68,214 @@
** == == ::
*/
/* _serf_space(): print n spaces.
*/
void _serf_space(FILE* fil_u, c3_w n)
{
for (; n > 0; n--)
(fprintf(fil_u," "));
}
/* _serf_print_memory(): print memory amount.
**
** Helper for _serf_prof(), just an un-captioned u3a_print_memory().
*/
void
_serf_print_memory(FILE* fil_u, 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(fil_u, "GB/%d.%03d.%03d.%03d\r\n",
gib_w, mib_w, kib_w, bib_w));
}
else if ( mib_w ) {
(fprintf(fil_u, "MB/%d.%03d.%03d\r\n", mib_w, kib_w, bib_w));
}
else if ( kib_w ) {
(fprintf(fil_u, "KB/%d.%03d\r\n", kib_w, bib_w));
}
else {
(fprintf(fil_u, "B/%d\r\n", bib_w));
}
}
/* _serf_prof(): print memory profile. RETAIN.
*/
c3_w
_serf_prof(FILE* fil_u, 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) ) {
_serf_space(fil_u, den);
fprintf(fil_u, "mistyped mass\r\n");
return tot_w;
}
else if ( _(u3du(h_mas)) ) {
_serf_space(fil_u, den);
fprintf(fil_u, "mistyped mass head\r\n");
{
c3_c* lab_c = u3m_pretty(h_mas);
fprintf(fil_u, "h_mas: %s", lab_c);
free(lab_c);
}
return tot_w;
}
else {
_serf_space(fil_u, den);
{
c3_c* lab_c = u3m_pretty(h_mas);
fprintf(fil_u, "%s: ", lab_c);
free(lab_c);
}
u3_noun it_mas, tt_mas;
if ( c3n == u3r_cell(t_mas, &it_mas, &tt_mas) ) {
fprintf(fil_u, "mistyped mass tail\r\n");
return tot_w;
}
else if ( c3y == it_mas ) {
tot_w += u3a_mark_noun(tt_mas);
_serf_print_memory(fil_u, 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(fil_u, "\r\n");
while ( _(u3du(tt_mas)) ) {
tot_w += _serf_prof(fil_u, den+2, u3h(tt_mas));
tt_mas = u3t(tt_mas);
}
_serf_space(fil_u, den);
fprintf(fil_u, "--");
_serf_print_memory(fil_u, tot_w);
return tot_w;
}
else {
_serf_space(fil_u, den);
fprintf(fil_u, "mistyped (strange) mass tail\r\n");
return tot_w;
}
}
}
/* _serf_grab(): garbage collect, checking for profiling. RETAIN.
*/
static void
_serf_grab(u3_noun sac, u3_noun ovo, u3_noun vir)
{
if ( u3_nul == sac) {
if ( u3C.wag_w & (u3o_debug_ram | u3o_check_corrupt) ) {
u3m_grab(sac, ovo, vir, u3_none);
}
}
else {
c3_w usr_w = 0, man_w = 0, sac_w = 0, ova_w = 0, vir_w = 0;
FILE* fil_u;
#ifdef U3_MEMORY_LOG
{
u3_noun wen = u3dc("scot", c3__da, u3k(u3A->now));
c3_c* wen_c = u3r_string(wen);
c3_c nam_c[2048];
snprintf(nam_c, 2048, "%s/.urb/put/mass", u3P.dir_c);
struct stat st;
if ( -1 == stat(nam_c, &st) ) {
mkdir(nam_c, 0700);
}
c3_c man_c[2048];
snprintf(man_c, 2048, "%s/%s.txt", nam_c, wen_c);
fil_u = fopen(man_c, "w");
fprintf(fil_u, "%s\r\n", wen_c);
free(wen_c);
u3z(wen);
}
#else
{
fil_u = stderr;
}
#endif
c3_assert( u3R == &(u3H->rod_u) );
fprintf(fil_u, "\r\n");
usr_w = _serf_prof(fil_u, 0, sac);
u3a_print_memory(fil_u, "total userspace", usr_w);
man_w = u3m_mark(fil_u);
sac_w = u3a_mark_noun(sac);
u3a_print_memory(fil_u, "space profile", sac_w);
ova_w = u3a_mark_noun(ovo);
u3a_print_memory(fil_u, "event", ova_w);
vir_w = u3a_mark_noun(vir);
u3a_print_memory(fil_u, "effects", vir_w);
u3a_print_memory(fil_u, "total marked", usr_w + man_w + sac_w + ova_w + vir_w);
u3a_print_memory(fil_u, "sweep", u3a_sweep());
#ifdef U3_MEMORY_LOG
{
fclose(fil_u);
}
#endif
}
}
/* _serf_fail(): failure stub.
*/
static void
_serf_fail(void* vod_p, const c3_c* wut_c)
{
// fprintf(stderr, "serf: fail: %s\r\n", wut_c);
fprintf(stderr, "serf: fail: %s\r\n", wut_c);
exit(1);
}
@ -116,10 +318,10 @@ _serf_send_complete(u3_noun vir)
static void
_serf_lame(c3_d evt_d, u3_noun ovo, u3_noun why, u3_noun tan)
{
/* XX: the next crud will contain the original event.
*/
u3z(ovo);
// %crud will be sent on the original wire.
//
_serf_send_replace(evt_d, u3nc(u3k(u3h(ovo)), u3nt(c3__crud, why, tan)));
u3z(ovo);
}
/* _serf_sure(): event succeeded, report completion.
@ -127,12 +329,75 @@ _serf_lame(c3_d evt_d, u3_noun ovo, u3_noun why, u3_noun tan)
static void
_serf_sure(u3_noun ovo, u3_noun vir, u3_noun cor)
{
u3z(ovo);
u3z(u3A->roc);
u3A->roc = cor;
// single-home
//
// XX revise when real keys are supported
// XX dispatch on evt_d, wire, or card tag?
//
if ( c3__boot == u3h(u3t(ovo)) ) {
// ovo=[%boot *]
// vir=[[wire %init @p] ~]
// fec=[%init @p]
//
u3_noun fec = u3t(u3h(vir));
c3_assert( c3__init == u3h(fec) );
c3_assert( u3_none == u3A->our );
u3A->our = u3k(u3t(fec));
u3A->fak = ( c3__fake == u3h(u3t(u3t(ovo))) ) ? c3y : c3n;
{
u3_noun nam = u3dc("scot", 'p', u3k(u3A->our));
c3_c* nam_c = u3r_string(nam);
fprintf(stderr, "boot: ship: %s%s\r\n", nam_c,
(c3y == u3A->fak) ? " (fake)" : "");
free(nam_c);
u3z(nam);
}
}
u3_noun sac = u3_nul;
// intercept |mass
//
{
u3_noun riv = vir;
c3_w i_w = 0;
while ( u3_nul != riv ) {
u3_noun fec = u3t(u3h(riv));
// assumes a max of one %mass effect per event
//
if ( c3__mass == u3h(fec) ) {
// save a copy of the %mass data
//
sac = u3k(u3t(fec));
// replace the %mass data with ~
//
// For efficient transmission to king.
//
riv = u3kb_weld(u3qb_scag(i_w, vir),
u3nc(u3nt(u3k(u3h(u3h(riv))), c3__mass, u3_nul),
u3qb_slag(1 + i_w, vir)));
u3z(vir);
vir = riv;
break;
}
riv = u3t(riv);
i_w++;
}
}
_serf_grab(sac, ovo, vir);
_serf_send_complete(vir);
u3z(sac); u3z(ovo);
}
/* _serf_poke_live(): apply event.
@ -142,25 +407,24 @@ _serf_poke_live(c3_d evt_d, // event number
c3_l mug_l, // mug of state
u3_noun job) // event date
{
u3_noun now = u3k(u3h(job));
u3_noun ovo = u3k(u3t(job));
u3_noun now, ovo, gon;
c3_assert(evt_d == u3V.evt_d + 1ULL);
if ( 0 != mug_l ) {
c3_assert(u3r_mug(u3A->roc) == mug_l);
}
u3z(job);
{
u3_noun gon;
u3x_cell(job, &now, &ovo);
if ( mug_l ) {
c3_assert(u3r_mug(u3A->roc) == mug_l);
}
u3z(u3A->now);
u3A->now = u3k(now);
u3z(u3A->now);
u3A->now = now;
u3A->ent_d = evt_d;
// XX why is this set before u3v_poke?
//
u3A->ent_d = evt_d;
#ifdef U3_EVENT_TIME_DEBUG
{
struct timeval b4, f2, d0;
gettimeofday(&b4, 0);
@ -169,11 +433,13 @@ _serf_poke_live(c3_d evt_d, // event number
fprintf(stderr, "serf: %s (%lld) live\r\n", txt_c, evt_d);
}
}
#endif
gon = u3m_soft(0, u3v_poke, u3k(ovo));
gon = u3m_soft(0, u3v_poke, u3k(ovo));
#ifdef U3_EVENT_TIME_DEBUG
{
c3_c* txt_c = u3r_string(u3h(u3t(ovo)));
c3_w ms_w;
c3_w clr_w;
@ -188,60 +454,36 @@ _serf_poke_live(c3_d evt_d, // event number
(int) (d0.tv_usec % 1000) / 10));
}
free(txt_c);
}
#endif
if ( u3_blip != u3h(gon) ) {
//
// event rejected
//
u3_noun why = u3k(u3h(gon));
u3_noun tan = u3k(u3t(gon));
if ( u3_blip != u3h(gon) ) {
// event rejected
//
u3_noun why, tan;
u3x_cell(gon, &why, &tan);
u3z(gon);
_serf_lame(evt_d, ovo, why, tan);
}
else {
// event accepted
//
u3V.evt_d = evt_d;
{
// vir/(list ovum) list of effects
// cor/arvo arvo core
//
u3_noun vir = u3k(u3h(u3t(gon)));
u3_noun cor = u3k(u3t(u3t(gon)));
u3k(ovo); u3k(why); u3k(tan);
u3z(gon); u3z(job);
// single-home
//
// XX revise when real keys are supported
// XX dispatch on evt_d, wire, or card tag?
//
if ( c3__boot == u3h(u3t(ovo)) ) {
// ovo=[%boot *]
// vir=[[wire %init @p] ~]
// fec=[%init @p]
//
u3_noun fec = u3t(u3h(vir));
_serf_lame(evt_d, ovo, why, tan);
}
else {
// event accepted
//
// XX reconcile/dedupe with u3A->ent_d
//
u3V.evt_d = evt_d;
// vir/(list ovum) list of effects
// cor/arvo arvo core
//
u3_noun vir, cor;
u3x_trel(gon, 0, &vir, &cor);
c3_assert( c3__init == u3h(fec) );
c3_assert( u3_none == u3A->our );
u3k(ovo); u3k(vir); u3k(cor);
u3z(gon); u3z(job);
u3A->our = u3k(u3t(fec));
u3A->fak = ( c3__fake == u3h(u3t(u3t(ovo))) ) ? c3y : c3n;
{
u3_noun nam = u3dc("scot", 'p', u3k(u3A->our));
c3_c* nam_c = u3r_string(nam);
fprintf(stderr, "boot: ship: %s%s\r\n", nam_c,
(c3y == u3A->fak) ? " (fake)" : "");
free(nam_c);
u3z(nam);
}
}
_serf_sure(ovo, vir, cor);
}
}
_serf_sure(ovo, vir, cor);
}
}
@ -250,6 +492,8 @@ _serf_poke_live(c3_d evt_d, // event number
static u3_noun
_serf_boot_fire(u3_noun eve)
{
// XX virtualize? use u3v_boot?
//
u3_noun cor = u3n_nock_on(eve, u3nt(2, u3nc(0, 3), u3nc(0, 2)));
u3_noun pro;
@ -266,31 +510,37 @@ _serf_poke_boot(c3_d evt_d,
c3_l mug_l,
u3_noun job)
{
u3A->roe = u3nc(job, u3A->roe);
c3_assert(evt_d == u3V.evt_d + 1ULL);
u3V.evt_d = evt_d;
u3A->roe = u3nc(job, u3A->roe);
fprintf(stderr, "serf: (%lld)| boot\r\n", evt_d);
if ( evt_d == 5 ) {
u3_noun eve = u3kb_flop(u3A->roe);
u3_noun pru;
if ( 5 == evt_d ) {
u3_noun eve, pru;
eve = u3kb_flop(u3A->roe);
u3A->roe = 0;
fprintf(stderr, "serf: (5)| pill: %x\r\n", u3r_mug(eve));
pru = u3m_soft(0, _serf_boot_fire, eve);
if ( u3h(pru) != 0 ) {
if ( u3_blip != u3h(pru) ) {
fprintf(stderr, "boot failed\r\n");
exit(1);
}
fprintf(stderr, "serf: (5)| core: %x\r\n", u3r_mug(u3t(pru)));
u3A->roc = u3k(u3t(pru));
// XX set u3A->evt_d ?
//
u3A->roc = u3k(u3t(pru));
u3z(pru);
}
_serf_send(u3nq(c3__done,
u3i_chubs(1, &evt_d),
0,
@ -331,53 +581,71 @@ _serf_poke(void* vod_p, u3_noun mat)
goto error;
}
else {
u3_noun p_jar, q_jar, r_jar;
switch ( u3h(jar) ) {
case c3__work: {
if ( (c3n == u3r_qual(jar, 0, &p_jar, &q_jar, &r_jar)) ||
(c3n == u3ud(p_jar)) ||
(u3r_met(6, p_jar) != 1) ||
(c3n == u3ud(q_jar)) ||
(u3r_met(5, q_jar) > 1) )
{
goto error;
}
_serf_poke_work(u3r_chub(0, p_jar),
u3r_word(0, q_jar),
u3k(r_jar));
break;
}
case c3__exit: {
if ( (c3n == u3r_cell(jar, 0, &p_jar)) ||
(c3n == u3ud(p_jar)) ||
(u3r_met(3, p_jar) > 1) )
{
goto error;
}
_serf_poke_exit(u3k(p_jar));
break;
}
case c3__save: {
if ( (c3n == u3r_cell(jar, 0, &p_jar)) ||
(c3n == u3ud(p_jar)) ) {
goto error;
}
fprintf(stderr, "serf: save\r\n");
u3e_save();
break;
}
default: {
goto error;
}
case c3__work: {
u3_noun evt, mug, job;
c3_d evt_d;
c3_l mug_l;
if ( (c3n == u3r_qual(jar, 0, &evt, &mug, &job)) ||
(c3n == u3ud(evt)) ||
(1 != u3r_met(6, evt)) ||
(c3n == u3ud(mug)) ||
(1 < u3r_met(5, mug)) )
{
goto error;
}
evt_d = u3r_chub(0, evt);
mug_l = u3r_word(0, mug);
u3k(job);
u3z(jar);
return _serf_poke_work(evt_d, mug_l, job);
}
case c3__exit: {
u3_noun cod;
c3_w cod_w;
if ( (c3n == u3r_cell(jar, 0, &cod)) ||
(c3n == u3ud(cod)) ||
(1 < u3r_met(3, cod)) )
{
goto error;
}
cod_w = u3r_word(0, cod);
u3z(jar);
return _serf_poke_exit(cod_w);
}
case c3__save: {
u3_noun sap;
if ( (c3n == u3r_cell(jar, 0, &sap)) ||
(c3n == u3ud(sap)) )
{
goto error;
}
fprintf(stderr, "serf: save\r\n");
u3z(jar);
return u3e_save();
}
}
return;
}
error: {
u3z(jar);
_serf_fail(0, "bad jar");
}
u3z(jar);
}
/* u3_serf_boot(): send startup message to manager.