Merge pull request #1185 from urbit/hotfix

Hotfix
This commit is contained in:
ixv 2019-02-05 17:45:06 -08:00 committed by GitHub
commit 0ea480cad4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 1240 additions and 398 deletions

View File

@ -1 +1 @@
7aaf5fa815f93b01978f42663163f75d8175ad1c
6d6ec85d6aa9200d366d0998326726ef1965d092

View File

@ -26,10 +26,10 @@
c3_i
u3m_bail(c3_m how_m) __attribute__((noreturn));
/* u3m_init(): start the environment, with/without checkpointing.
/* u3m_init(): start the environment.
*/
void
u3m_init(c3_o chk_o);
u3m_init();
/* u3m_pave(): instantiate or activate image.
*/

View File

@ -86,7 +86,7 @@
/* u3t_trace_open(): opens the path for writing tracing information.
*/
void
u3t_trace_open(c3_c*);
u3t_trace_open();
/* u3t_trace_close(): closes the trace file. optional.
*/

View File

@ -565,6 +565,14 @@
c3_o vog; // did they vote for us?
} u3_rnam;
/* u3_trac: tracing information.
*/
typedef struct _u3_trac {
c3_w nid_w; // nock pid
FILE* fil_u; // trace file (json)
c3_w con_w; // trace counter
} u3_trac;
/* u3_opts: command line configuration.
*/
typedef struct _u3_opts {
@ -583,7 +591,7 @@
c3_c* gen_c; // -G, czar generator
c3_o gab; // -g, test garbage collection
c3_c* dns_c; // -H, ames bootstrap domain
c3_c* json_file_c; // -j, json trace
c3_o tra; // -j, json trace
c3_w kno_w; // -K, kernel version
c3_c* key_c; // -k, private key file
c3_o net; // -L, local-only networking
@ -625,7 +633,7 @@
c3_o liv; // if u3_no, shut down
c3_i xit_i; // exit code for shutdown
void* tls_u; // server SSL_CTX*
FILE* trace_file_u; // trace file to write to
u3_trac tra_u; // tracing information
} u3_host; // host == computer == process
# define u3L u3_Host.lup_u // global event loop

File diff suppressed because it is too large Load Diff

View File

@ -236,7 +236,7 @@ endforeach
incdir = include_directories('include/')
conf_data = configuration_data()
conf_data.set('URBIT_VERSION', '"0.7.1"')
conf_data.set('URBIT_VERSION', '"0.7.2"')
conf_data.set('U3_MEMORY_DEBUG', get_option('gc'))
conf_data.set('U3_CPU_DEBUG', get_option('prof'))
conf_data.set('U3_EVENT_TIME_DEBUG', get_option('event-time'))

View File

@ -165,9 +165,9 @@ u3e_fault(void* adr_v, c3_i ser_i)
/* _ce_image_open(): open or create image.
*/
static c3_o
_ce_image_open(u3e_image* img_u, c3_o nuu_o)
_ce_image_open(u3e_image* img_u)
{
c3_i mod_i = _(nuu_o) ? (O_RDWR | O_CREAT) : O_RDWR;
c3_i mod_i = O_RDWR | O_CREAT;
c3_c ful_c[8193];
snprintf(ful_c, 8192, "%s", u3P.dir_c);
@ -197,11 +197,7 @@ _ce_image_open(u3e_image* img_u, c3_o nuu_o)
c3_d pgs_d = (siz_d + (c3_d)((1 << (u3a_page + 2)) - 1)) >>
(c3_d)(u3a_page + 2);
if ( c3y == nuu_o ) {
if ( siz_d ) {
c3_assert(0);
return c3n;
}
if ( !siz_d ) {
return c3y;
}
else {
@ -817,7 +813,7 @@ u3e_save(void)
_ce_patch_free(pat_u);
}
/* u3e_live(): start the persistence system.
/* u3e_live(): start the checkpointing system.
*/
c3_o
u3e_live(c3_o nuu_o, c3_c* dir_c)
@ -832,29 +828,17 @@ u3e_live(c3_o nuu_o, c3_c* dir_c)
} else
#endif
{
/* Open and apply any patches.
*/
if ( _(nuu_o) ) {
if ( (c3n == _ce_image_open(&u3P.nor_u, c3y)) ||
(c3n == _ce_image_open(&u3P.sou_u, c3y)) )
{
printf("boot: image failed\r\n");
exit(1);
}
// Open image files.
//
if ( (c3n == _ce_image_open(&u3P.nor_u)) ||
(c3n == _ce_image_open(&u3P.sou_u)) )
{
printf("boot: image failed\r\n");
exit(1);
}
else {
u3_ce_patch* pat_u;
/* Open image files.
*/
{
if ( (c3n == _ce_image_open(&u3P.nor_u, c3n)) ||
(c3n == _ce_image_open(&u3P.sou_u, c3n)) )
{
fprintf(stderr, "boot: no image\r\n");
return u3e_live(c3y, dir_c);
}
}
/* Load any patch files; apply them to images.
*/
if ( 0 != (pat_u = _ce_patch_open()) ) {

View File

@ -1495,10 +1495,10 @@ _cm_signals(void)
}
}
/* u3m_init(): start the environment, with/without checkpointing.
/* u3m_init(): start the environment.
*/
void
u3m_init(c3_o chk_o)
u3m_init(void)
{
_cm_limits();
_cm_signals();
@ -1515,7 +1515,7 @@ u3m_init(c3_o chk_o)
map_v = mmap((void *)u3_Loom,
len_w,
_(chk_o) ? PROT_READ : (PROT_READ | PROT_WRITE),
(PROT_READ | PROT_WRITE),
(MAP_ANON | MAP_FIXED | MAP_PRIVATE),
-1, 0);
@ -1694,7 +1694,7 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c,
{
/* Activate the loom.
*/
u3m_init(nuu_o);
u3m_init();
/* Activate the storage system.
*/

View File

@ -3,7 +3,10 @@
** This file is in the public domain.
*/
#include "all.h"
#include "vere/vere.h"
#include <pthread.h>
#include <time.h>
#include <sys/stat.h>
static c3_o _ct_lop_o;
@ -298,43 +301,54 @@ u3t_flee(void)
u3z(don);
}
static FILE* trace_file_u = NULL;
static int nock_pid_i = 0;
/* u3t_trace_open(): opens a trace file and writes the preamble.
*/
void
u3t_trace_open(c3_c* trace_file_name)
u3t_trace_open()
{
printf("trace: tracing to %s\n", trace_file_name);
trace_file_u = fopen(trace_file_name, "w");
nock_pid_i = (int)getpid();
fprintf(trace_file_u, "[ ");
c3_c fil_c[2048];
snprintf(fil_c, 2048, "%s/.urb/put/trace", u3_Host.dir_c);
struct stat st;
if ( -1 == stat(fil_c, &st) ) {
mkdir(fil_c, 0700);
}
c3_c * wen_c = u3r_string(u3A->wen);
c3_c lif_c[2048];
snprintf(lif_c, 2048, "%s/%s.json", fil_c, wen_c);
free(wen_c);
u3_Host.tra_u.fil_u = fopen(lif_c, "w");
u3_Host.tra_u.nid_w = (int)getpid();
fprintf(u3_Host.tra_u.fil_u, "[ ");
// We have two "threads", the event processing and the nock stuff.
// tid 1 = event processing
// tid 2 = nock processing
fprintf(
trace_file_u,
fprintf(u3_Host.tra_u.fil_u,
"{\"name\": \"process_name\", \"ph\": \"M\", \"pid\": %d, \"args\": "
"{\"name\": \"urbit\"}},\n",
nock_pid_i);
fprintf(trace_file_u,
u3_Host.tra_u.nid_w);
fprintf(u3_Host.tra_u.fil_u,
"{\"name\": \"thread_name\", \"ph\": \"M\", \"pid\": %d, \"tid\": 1, "
"\"args\": {\"name\": \"Event Processing\"}},\n",
nock_pid_i);
fprintf(trace_file_u,
u3_Host.tra_u.nid_w);
fprintf(u3_Host.tra_u.fil_u,
"{\"name\": \"thread_sort_index\", \"ph\": \"M\", \"pid\": %d, "
"\"tid\": 1, \"args\": {\"sort_index\": 1}},\n",
nock_pid_i);
fprintf(trace_file_u,
u3_Host.tra_u.nid_w);
fprintf(u3_Host.tra_u.fil_u,
"{\"name\": \"thread_name\", \"ph\": \"M\", \"pid\": %d, \"tid\": 2, "
"\"args\": {\"name\": \"Nock\"}},\n",
nock_pid_i);
fprintf(trace_file_u,
u3_Host.tra_u.nid_w);
fprintf(u3_Host.tra_u.fil_u,
"{\"name\": \"thread_sort_index\", \"ph\": \"M\", \"pid\": %d, "
"\"tid\": 2, \"args\": {\"sort_index\": 2}},\n",
nock_pid_i);
u3_Host.tra_u.nid_w);
u3_Host.tra_u.con_w = 5;
}
/* u3t_trace_close(): closes a trace file. optional.
@ -342,11 +356,12 @@ u3t_trace_open(c3_c* trace_file_name)
void
u3t_trace_close()
{
if (!trace_file_u)
if (!u3_Host.tra_u.fil_u)
return;
// We don't terminate the JSON because of the file format.
fclose(trace_file_u);
fclose(u3_Host.tra_u.fil_u);
u3_Host.tra_u.con_w = 0;
}
/* u3t_trace_time(): microsecond clock
@ -365,7 +380,7 @@ c3_d u3t_trace_time()
c3_o
u3t_nock_trace_push(u3_noun lab)
{
if (!trace_file_u)
if (!u3_Host.tra_u.fil_u)
return c3n;
if ( (u3_nul == u3R->pro.trace) ||
@ -437,7 +452,7 @@ trace_pretty(u3_noun som)
void
u3t_nock_trace_pop()
{
if (!trace_file_u)
if (!u3_Host.tra_u.fil_u)
return;
u3_noun trace = u3R->pro.trace;
@ -452,16 +467,17 @@ u3t_nock_trace_pop()
if (duration > 33) {
c3_c* name = trace_pretty(lab);
fprintf(trace_file_u,
fprintf(u3_Host.tra_u.fil_u,
"{\"cat\": \"nock\", \"name\": \"%s\", \"ph\":\"%c\", \"pid\": %d, "
"\"tid\": 2, \"ts\": %" PRIu64 ", \"dur\": %" PRIu64 "}, \n",
name,
'X',
nock_pid_i,
u3_Host.tra_u.nid_w,
start_time,
duration);
free(name);
u3_Host.tra_u.con_w++;
}
u3z(trace);
@ -472,16 +488,17 @@ u3t_nock_trace_pop()
void
u3t_event_trace(const c3_c* name, c3_c type)
{
if (!trace_file_u)
if (!u3_Host.tra_u.fil_u)
return;
fprintf(trace_file_u,
fprintf(u3_Host.tra_u.fil_u,
"{\"cat\": \"event\", \"name\": \"%s\", \"ph\":\"%c\", \"pid\": %d, "
"\"tid\": 1, \"ts\": %" PRIu64 ", \"id\": \"0x100\"}, \n",
name,
type,
nock_pid_i,
u3_Host.tra_u.nid_w,
u3t_trace_time());
u3_Host.tra_u.con_w++;
}
extern FILE*

View File

@ -102,6 +102,9 @@ u3v_start(u3_noun now)
printf("arvo: time: %s\n", wen_c);
free(wen_c);
}
if ( u3C.wag_w & u3o_trace )
u3t_trace_open();
}
/* u3v_wish(): text expression with cache.

View File

@ -5,7 +5,7 @@
static void
_setup(void)
{
u3m_init(c3y);
u3m_init();
u3m_pave(c3y, c3n);
}

View File

@ -26,7 +26,7 @@ main(int argc, char* argv[])
static void
_setup(void)
{
u3m_init(c3y);
u3m_init();
u3m_pave(c3y, c3n);
}

View File

@ -254,7 +254,7 @@ main(int argc, char *argv[])
printf("hello, world: len %dMB\n", (1 << U3_OS_LoomBits) >> 18);
// _test_words();
u3m_init(c3n);
u3m_init();
u3m_pave(c3y, c3n);
// u3j_boot();

View File

@ -83,6 +83,7 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.qui = c3n;
u3_Host.ops_u.rep = c3n;
u3_Host.ops_u.tex = c3n;
u3_Host.ops_u.tra = c3n;
u3_Host.ops_u.veb = c3n;
u3_Host.ops_u.kno_w = DefaultKernel;
@ -91,7 +92,7 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.nam_c = 0;
while ( -1 != (ch_i=getopt(argc, argv,
"G:B:K:A:H:w:u:j:e:E:f:F:k:m:p:LabcCdgqstvxPDRS")) ) {
"G:B:K:A:H:w:u:e:E:f:F:k:m:p:LjabcCdgqstvxPDRS")) ) {
switch ( ch_i ) {
case 'B': {
@ -131,10 +132,6 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.url_c = strdup(optarg);
break;
}
case 'j': {
u3_Host.ops_u.json_file_c = strdup(optarg);
break;
}
case 'x': {
u3_Host.ops_u.tex = c3y;
break;
@ -170,6 +167,7 @@ _main_getopt(c3_i argc, c3_c** argv)
return c3y;
}
case 'L': { u3_Host.ops_u.net = c3n; break; }
case 'j': { u3_Host.ops_u.tra = c3y; break; }
case 'a': { u3_Host.ops_u.abo = c3y; break; }
case 'b': { u3_Host.ops_u.bat = c3y; break; }
case 'c': { u3_Host.ops_u.nuu = c3y; break; }
@ -656,9 +654,11 @@ main(c3_i argc,
/* Set tracing flag
*/
if ( u3_Host.ops_u.json_file_c ) {
if ( _(u3_Host.ops_u.tra) ) {
u3C.wag_w |= u3o_trace;
u3t_trace_open(u3_Host.ops_u.json_file_c);
u3_Host.tra_u.nid_w = 0;
u3_Host.tra_u.fil_u = NULL;
u3_Host.tra_u.con_w = 0;
}
}
u3m_boot(u3_Host.ops_u.nuu,

View File

@ -2,6 +2,7 @@
**
*/
#include <uv.h>
#include <sys/stat.h>
#include "all.h"
#include "vere/vere.h"
@ -1868,7 +1869,14 @@ _raft_grab(u3_noun rus)
c3_c* wen_c = u3r_string(u3A->wen);
c3_c nam_c[2048];
snprintf(nam_c, 2048, "%s/.urb/put/%s-mass.txt", u3_Host.dir_c, wen_c);
snprintf(nam_c, 2048, "%s/.urb/put/mass", u3_Host.dir_c);
struct stat st;
if ( -1 == stat(nam_c, &st) ) {
mkdir(nam_c, 0700);
}
snprintf(nam_c, 2048, "%s/%s.txt", nam_c, wen_c);
fil_u = fopen(nam_c, "w");
fprintf(fil_u, "%s\r\n", wen_c);
@ -2044,6 +2052,11 @@ _raft_pump(u3_noun ovo)
void
u3_raft_chip(void)
{
if ( (u3C.wag_w & u3o_trace) && (u3_Host.tra_u.con_w >= 100000) ) {
u3t_trace_close();
u3t_trace_open();
}
u3_weak rus = _raft_poke();
_raft_crop();
@ -2061,6 +2074,10 @@ u3_raft_chip(void)
u3z(rus);
}
if ( 0 == (u3A->ent_d % 1000ULL) ) {
u3m_reclaim();
}
}
/* u3_raft_play(): synchronously process events.

View File

@ -208,40 +208,68 @@ u3_sist_nil(const c3_c* key_c)
/* _sist_suck(): past failure.
*/
static void
_sist_suck(u3_noun ovo, u3_noun gon)
_sist_suck(c3_d evt_d, u3_noun ovo, u3_noun gon)
{
uL(fprintf(uH, "sing: ovum failed!\n"));
fprintf(stderr, "sing: ovum failed!\r\n");
{
c3_c* hed_c = u3r_string(u3h(u3t(ovo)));
uL(fprintf(uH, "fail %s\n", hed_c));
fprintf(stderr, "sing: fail: %s event %lld mug %u\r\n",
hed_c, evt_d, u3r_mug(ovo));
free(hed_c);
}
u3_lo_punt(2, u3kb_flop(u3k(u3t(gon))));
// u3_loom_exit();
#if 1
u3_lo_exit();
{
u3_noun why;
u3x_cell(gon, &why, 0);
u3m_p("sist: why", why);
}
exit(1);
#else
u3z(ovo); u3z(gon);
u3_lo_punt(2, u3kb_flop(u3k(u3t(gon))));
#if 1
{
c3_c fil_c[2048];
snprintf(fil_c, 2048, "%s/.urb/put/failed-%lld.jam", u3_Host.dir_c, evt_d);
u3_noun pat = u3qe_jam(ovo);
fprintf(stderr, "sing: saving failed event\r\n");
u3_walk_save(fil_c, u3_nul, pat, 0, u3_nul);
}
#endif
#if 1
{
fprintf(stderr, "sing: saving checkpoint\r\n");
c3_d old_d = u3A->ent_d;
u3A->ent_d = evt_d - 1ULL;
u3e_save();
u3A->ent_d = old_d;
}
#endif
#if 1
u3_lo_bail();
#endif
}
/* _sist_sing(): replay ovum from the past, time already set.
*/
static void
_sist_sing(u3_noun ovo)
_sist_sing(c3_d evt_d, u3_noun ovo)
{
u3t_event_trace("Running", 'b');
u3_noun gon = u3m_soft(0, u3v_poke, u3k(ovo));
u3t_event_trace("Running", 'e');
{
u3_noun hed, tal;
u3x_cell(gon, &hed, &tal);
if ( u3_blip != hed ) {
_sist_suck(ovo, gon);
_sist_suck(evt_d, ovo, gon);
}
else {
u3_noun vir, cor;
@ -1075,7 +1103,7 @@ _sist_rest()
fprintf(stderr, "replay: skipped veer\n");
}
else {
_sist_sing(u3k(ovo));
_sist_sing(lar_u.ent_d, u3k(ovo));
fputc('.', stderr);
}
@ -1083,6 +1111,17 @@ _sist_rest()
xno_w++;
#if 1
// save a checkpoint every 100K events
//
if ( 0 == (xno_w % 100000) ) {
c3_d old_d = u3A->ent_d;
u3A->ent_d = lar_u.ent_d;
u3e_save();
u3A->ent_d = old_d;
}
#endif
if ( 0 == (xno_w % 1000) ) {
uL(fprintf(uH, "{%d}\n", xno_w));
// u3_lo_grab("rest", rou, u3_none);
@ -1090,6 +1129,10 @@ _sist_rest()
u3z(ven);
cur_d += c3_wiseof(len_w) + len_w + c3_wiseof(lar_u);
if ( 0 == (xno_w % 1000) ) {
u3m_reclaim();
}
}
fputc('\r', stderr);
fputc('\n', stderr);