Commit f1d03e81 authored by Kevin Modzelewski's avatar Kevin Modzelewski Committed by Kevin Modzelewski

Helper for pinning down where time in a stattimer happens

If you define INVESTIGATE_STAT_TIMER to the name of the timer you want
to investigate, we will set an itimer that raises a SIGTRAP if you are
in that particular timer, but ignores the signal otherwise.  There's no
tooling on top of it, but just running that inside gdb is already helpful.
parent cf2c2828
......@@ -362,6 +362,15 @@ static void handle_sigprof(int signum) {
sigprof_pending++;
}
//#define INVESTIGATE_STAT_TIMER "us_timer_chosen_cf_body_jitted"
#ifdef INVESTIGATE_STAT_TIMER
static uint64_t* stat_counter = Stats::getStatCounter(INVESTIGATE_STAT_TIMER);
static void handle_sigprof_investigate_stattimer(int signum) {
if (StatTimer::getCurrentCounter() == stat_counter)
raise(SIGTRAP);
}
#endif
static void handle_sigint(int signum) {
assert(signum == SIGINT);
// TODO: this should set a flag saying a KeyboardInterrupt is pending.
......@@ -475,6 +484,14 @@ void initCodegen() {
setitimer(ITIMER_PROF, &prof_timer, NULL);
#endif
#ifdef INVESTIGATE_STAT_TIMER
struct itimerval prof_timer;
prof_timer.it_value.tv_sec = prof_timer.it_interval.tv_sec = 0;
prof_timer.it_value.tv_usec = prof_timer.it_interval.tv_usec = 1000;
signal(SIGPROF, handle_sigprof_investigate_stattimer);
setitimer(ITIMER_PROF, &prof_timer, NULL);
#endif
// There are some parts of llvm that are only configurable through command line args,
// so construct a fake argc/argv pair and pass it to the llvm command line machinery:
std::vector<const char*> llvm_args = { "fake_name" };
......
......@@ -50,6 +50,12 @@ StatTimer* StatTimer::createStack(StatTimer& timer) {
timer.pushTopLevel(at_time);
return prev_stack;
}
uint64_t* StatTimer::getCurrentCounter() {
if (stack)
return stack->_statcounter;
return NULL;
}
#endif
std::unordered_map<uint64_t*, std::string>* Stats::names;
......
......@@ -206,6 +206,8 @@ public:
static StatTimer* createStack(StatTimer& timer);
static StatTimer* swapStack(StatTimer* s);
static uint64_t* getCurrentCounter();
static void assertActive() { ASSERT(stack && !stack->isPaused(), ""); }
};
class ScopedStatTimer {
......
......@@ -2021,7 +2021,7 @@ void setattrGeneric(Box* obj, BoxedString* attr, Box* val, SetattrRewriteArgs* r
}
extern "C" void setattr(Box* obj, BoxedString* attr, Box* attr_val) {
STAT_TIMER(t0, "us_timer_slowpath_setsattr", 10);
STAT_TIMER(t0, "us_timer_slowpath_setattr", 10);
static StatCounter slowpath_setattr("slowpath_setattr");
slowpath_setattr.log();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment