mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-24 23:44:56 +03:00
Fix some profiling stuff.
This commit is contained in:
parent
b3a64933bc
commit
81455138c3
2
Makefile
2
Makefile
@ -64,7 +64,7 @@ INCLUDE=i
|
||||
MDEFINES=-DU3_OS_$(OS) -DU3_OS_ENDIAN_$(ENDIAN) -D U3_LIB=\"$(LIB)\"
|
||||
|
||||
# NOTFORCHECKIN - restore -O3
|
||||
CFLAGS= $(COSFLAGS) -g -msse3 -ffast-math \
|
||||
CFLAGS= $(COSFLAGS) -O3 -msse3 -ffast-math \
|
||||
-funsigned-char \
|
||||
-I/usr/local/include \
|
||||
-I/opt/local/include \
|
||||
|
5
i/n/a.h
5
i/n/a.h
@ -345,6 +345,11 @@
|
||||
c3_w
|
||||
u3a_use(u3_noun som);
|
||||
|
||||
/* u3a_luse(): check refcount sanity.
|
||||
*/
|
||||
void
|
||||
u3a_luse(u3_noun som);
|
||||
|
||||
/* u3a_mark_ptr(): mark a pointer for gc. Produce size.
|
||||
*/
|
||||
c3_w
|
||||
|
15
n/a.c
15
n/a.c
@ -1195,6 +1195,21 @@ u3a_use(u3_noun som)
|
||||
}
|
||||
}
|
||||
|
||||
/* u3a_luse(): check refcount sanity.
|
||||
*/
|
||||
void
|
||||
u3a_luse(u3_noun som)
|
||||
{
|
||||
if ( 0 == u3a_use(som) ) {
|
||||
fprintf(stderr, "luse: insane %d 0x%x\r\n", som, som);
|
||||
abort();
|
||||
}
|
||||
if ( _(u3du(som)) ) {
|
||||
u3a_luse(u3h(som));
|
||||
u3a_luse(u3t(som));
|
||||
}
|
||||
}
|
||||
|
||||
/* u3a_mark_ptr(): mark a pointer for gc. Produce size if first mark.
|
||||
*/
|
||||
c3_w
|
||||
|
2
n/j.c
2
n/j.c
@ -701,7 +701,7 @@ _cj_mine(u3_noun cey, u3_noun cor)
|
||||
else {
|
||||
cup = u3nc(c3n, u3k(tab));
|
||||
}
|
||||
lab = u3k(u3h(u3t(u3t(cax))));
|
||||
lab = u3k(u3h(u3t(u3t(u3h(cax)))));
|
||||
u3z(cax);
|
||||
}
|
||||
}
|
||||
|
16
n/m.c
16
n/m.c
@ -1349,6 +1349,22 @@ _cm_signals(void)
|
||||
exit(1);
|
||||
}
|
||||
// signal(SIGINT, _loom_stop);
|
||||
|
||||
|
||||
// Block SIGPROF, so that if/when we reactivate it on the
|
||||
// main thread for profiling, we won't get hits in paralle
|
||||
// on other threads.
|
||||
{
|
||||
sigset_t set;
|
||||
|
||||
sigemptyset(&set);
|
||||
sigaddset(&set, SIGPROF);
|
||||
|
||||
if ( 0 != pthread_sigmask(SIG_BLOCK, &set, NULL) ) {
|
||||
perror("pthread_sigmask");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* _cm_init(): start the environment, with/without checkpointing.
|
||||
|
49
n/t.c
49
n/t.c
@ -95,7 +95,7 @@ _t_samp_process(u3_road* rod_u)
|
||||
|
||||
while ( u3_nul != don ) {
|
||||
u3_noun bat = u3h(don);
|
||||
u3_noun lab;
|
||||
u3_noun laj, lab;
|
||||
|
||||
// Find the label from this battery, surface allocated.
|
||||
//
|
||||
@ -107,11 +107,20 @@ _t_samp_process(u3_road* rod_u)
|
||||
if ( u3_none == (cax = u3j_find(bat)) ) {
|
||||
abort(); // probably a little drastic
|
||||
}
|
||||
lab = u3h(u3t(u3t(cax)));
|
||||
laj = u3h(u3t(u3t(u3h(cax))));
|
||||
#if 0
|
||||
fprintf(stderr, "laj %x, mug %x, use %d, jr %d\r\n",
|
||||
laj,
|
||||
u3r_mug(laj),
|
||||
u3a_use(laj),
|
||||
u3a_is_junior((&u3H->rod_u), laj));
|
||||
u3m_p("label", laj);
|
||||
#endif
|
||||
}
|
||||
u3R = &u3H->rod_u;
|
||||
|
||||
lab = u3a_take(lab);
|
||||
lab = u3a_take(laj);
|
||||
u3a_wash(laj);
|
||||
}
|
||||
|
||||
// Add the label to the traced label stack, trimming recursion.
|
||||
@ -136,10 +145,12 @@ _t_samp_process(u3_road* rod_u)
|
||||
pef = t_pef;
|
||||
}
|
||||
muf = u3k(u3t(u3h(pef)));
|
||||
u3z(lab);
|
||||
}
|
||||
}
|
||||
don = u3t(don);
|
||||
}
|
||||
rod_u = rod_u->par_u;
|
||||
}
|
||||
|
||||
// Lose the maps and save a pure label stack in original order.
|
||||
@ -157,18 +168,26 @@ _t_samp_process(u3_road* rod_u)
|
||||
pef = t_pef;
|
||||
}
|
||||
|
||||
// fprintf(stderr, "sample: stack length %d\r\n", u3kb_lent(u3k(pal)));
|
||||
return pal;
|
||||
}
|
||||
}
|
||||
|
||||
int SAM;
|
||||
|
||||
/* u3t_samp(): sample.
|
||||
*/
|
||||
void
|
||||
u3t_samp(void)
|
||||
{
|
||||
c3_w sam = SAM;
|
||||
|
||||
SAM++;
|
||||
|
||||
// Profile sampling, because it allocates on the home road,
|
||||
// only works on when we're not at home.
|
||||
//
|
||||
fprintf(stderr, "begin sample %d\r\n", sam);
|
||||
if ( &(u3H->rod_u) != u3R ) {
|
||||
u3a_road* rod_u;
|
||||
|
||||
@ -185,6 +204,7 @@ u3t_samp(void)
|
||||
}
|
||||
u3R = rod_u;
|
||||
}
|
||||
fprintf(stderr, "end sample %d\r\n", sam);
|
||||
}
|
||||
|
||||
/* u3t_come(): push on profile stack; return yes if active push. RETAIN.
|
||||
@ -215,6 +235,8 @@ u3t_flee(void)
|
||||
void
|
||||
u3t_damp(void)
|
||||
{
|
||||
u3m_p("day", u3R->pro.day);
|
||||
|
||||
if ( 0 != u3R->pro.day ) {
|
||||
u3_noun wol = u3do("pi-tell", u3R->pro.day);
|
||||
u3m_wall(wol);
|
||||
@ -230,7 +252,11 @@ u3t_damp(void)
|
||||
|
||||
/* _ct_sigaction(): profile sigaction callback.
|
||||
*/
|
||||
void _ct_sigaction(c3_i x_i) { u3t_samp(); }
|
||||
void _ct_sigaction(c3_i x_i)
|
||||
{
|
||||
// fprintf(stderr, "itimer!\r\n"); abort();
|
||||
u3t_samp();
|
||||
}
|
||||
|
||||
/* u3t_boot(): turn sampling on.
|
||||
*/
|
||||
@ -248,12 +274,19 @@ u3t_boot(void)
|
||||
{
|
||||
struct itimerval itm_v;
|
||||
struct sigaction sig_s;
|
||||
sigset_t set;
|
||||
|
||||
sig_s.__sigaction_u.__sa_handler = _ct_sigaction;
|
||||
sig_s.sa_mask = 0;
|
||||
sig_s.sa_flags = 0;
|
||||
sigaction(SIGPROF, &sig_s, 0);
|
||||
|
||||
sigemptyset(&set);
|
||||
sigaddset(&set, SIGPROF);
|
||||
if ( 0 != pthread_sigmask(SIG_UNBLOCK, &set, NULL) ) {
|
||||
perror("pthread_sigmask");
|
||||
}
|
||||
|
||||
itm_v.it_interval.tv_sec = 0;
|
||||
// itm_v.it_interval.tv_usec = 10000;
|
||||
itm_v.it_interval.tv_usec = 100000;
|
||||
@ -281,8 +314,13 @@ u3t_boff(void)
|
||||
#if defined(U3_OS_osx)
|
||||
struct sigaction sig_s;
|
||||
struct itimerval itm_v;
|
||||
sigset_t set;
|
||||
|
||||
printf("ct: end profiling.\r\n");
|
||||
sigemptyset(&set);
|
||||
sigaddset(&set, SIGPROF);
|
||||
if ( 0 != pthread_sigmask(SIG_BLOCK, &set, NULL) ) {
|
||||
perror("pthread_sigmask");
|
||||
}
|
||||
|
||||
itm_v.it_interval.tv_sec = 0;
|
||||
itm_v.it_interval.tv_usec = 0;
|
||||
@ -291,7 +329,6 @@ u3t_boff(void)
|
||||
setitimer(ITIMER_PROF, &itm_v, 0);
|
||||
sigaction(SIGPROF, &sig_s, 0);
|
||||
|
||||
u3t_damp();
|
||||
#elif defined(U3_OS_linux)
|
||||
// TODO: support profiling on linux
|
||||
#elif defined(U3_OS_bsd)
|
||||
|
16
v/loop.c
16
v/loop.c
@ -417,12 +417,24 @@ _lo_time(void)
|
||||
void
|
||||
u3_lo_open(void)
|
||||
{
|
||||
if ( u3C.wag_w & (u3o_debug_cpu | u3o_check_corrupt) ) {
|
||||
if ( u3C.wag_w & (u3o_debug_ram | u3o_check_corrupt) ) {
|
||||
//
|
||||
// Assumption: there are no noun roots outside u3A.
|
||||
//
|
||||
u3m_grab(u3_none);
|
||||
}
|
||||
#if 0
|
||||
if ( u3C.wag_w & u3o_debug_cpu ) {
|
||||
struct itimerval itm_u;
|
||||
|
||||
getitimer(ITIMER_VIRTUAL, &itm_u);
|
||||
fprintf(stderr, "tv_sec %d, tv_usec %d, value %d/%d\r\n",
|
||||
itm_u.it_interval.tv_sec,
|
||||
itm_u.it_interval.tv_usec,
|
||||
itm_u.it_value.tv_sec,
|
||||
itm_u.it_interval.tv_usec);
|
||||
}
|
||||
#endif
|
||||
_lo_time();
|
||||
}
|
||||
|
||||
@ -462,7 +474,7 @@ u3_lo_shut(c3_o inn)
|
||||
// u3_lo_grab("lo_exit", u3_none);
|
||||
// u3_loom_save(u3A->ent_d);
|
||||
// u3_loom_exit();
|
||||
u3t_boff();
|
||||
u3t_damp();
|
||||
u3_lo_exit();
|
||||
|
||||
exit(u3_Host.xit_i);
|
||||
|
2
v/main.c
2
v/main.c
@ -289,7 +289,6 @@ main(c3_i argc,
|
||||
|
||||
u3_ve_sysopt();
|
||||
|
||||
c3_assert(!(u3C.wag_w & u3o_debug_cpu));
|
||||
printf("~\n");
|
||||
printf("welcome.\n");
|
||||
printf("vere: urbit home is %s\n", u3_Host.dir_c);
|
||||
@ -303,7 +302,6 @@ main(c3_i argc,
|
||||
//
|
||||
srand(getpid());
|
||||
|
||||
c3_assert(!(u3C.wag_w & u3o_debug_cpu));
|
||||
// Instantiate process globals.
|
||||
{
|
||||
/* Boot the image and checkpoint. Set flags.
|
||||
|
Loading…
Reference in New Issue
Block a user