refactor: streamline perf log logic

master
Sean McBride 4 years ago
parent 8b0358c336
commit e4f0bcf8f7

@ -155,22 +155,17 @@ sandbox_print_perf(struct sandbox *sandbox)
/* If the log was not defined by an environment variable, early out */ /* If the log was not defined by an environment variable, early out */
if (runtime_sandbox_perf_log == NULL) return; if (runtime_sandbox_perf_log == NULL) return;
uint32_t total_time_us = sandbox->total_time / runtime_processor_speed_MHz; uint64_t queued_duration = sandbox->allocation_timestamp - sandbox->request_arrival_timestamp;
uint32_t queued_us = (sandbox->allocation_timestamp - sandbox->request_arrival_timestamp)
/ runtime_processor_speed_MHz;
uint32_t initializing_us = sandbox->initializing_duration / runtime_processor_speed_MHz;
uint32_t runnable_us = sandbox->runnable_duration / runtime_processor_speed_MHz;
uint32_t running_us = sandbox->running_duration / runtime_processor_speed_MHz;
uint32_t blocked_us = sandbox->blocked_duration / runtime_processor_speed_MHz;
uint32_t returned_us = sandbox->returned_duration / runtime_processor_speed_MHz;
/* /*
* Assumption: A sandbox is never able to free pages. If linear memory management * Assumption: A sandbox is never able to free pages. If linear memory management
* becomes more intelligent, then peak linear memory size needs to be tracked * becomes more intelligent, then peak linear memory size needs to be tracked
* seperately from current linear memory size. * seperately from current linear memory size.
*/ */
fprintf(runtime_sandbox_perf_log, "%lu,%s():%d,%s,%u,%u,%u,%u,%u,%u,%u,%u,%u\n", sandbox->id, fprintf(runtime_sandbox_perf_log, "%lu,%s,%d,%s,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%u,%u\n", sandbox->id,
sandbox->module->name, sandbox->module->port, sandbox_state_stringify(sandbox->state), sandbox->module->name, sandbox->module->port, sandbox_state_stringify(sandbox->state),
sandbox->module->relative_deadline_us, total_time_us, queued_us, initializing_us, runnable_us, sandbox->module->relative_deadline, sandbox->total_time, queued_duration,
running_us, blocked_us, returned_us, sandbox->linear_memory_size); sandbox->initializing_duration, sandbox->runnable_duration, sandbox->running_duration,
sandbox->blocked_duration, sandbox->returned_duration, runtime_processor_speed_MHz,
sandbox->linear_memory_size);
} }

@ -224,8 +224,8 @@ runtime_configure()
printf("\tSandbox Performance Log: %s\n", runtime_sandbox_perf_log_path); printf("\tSandbox Performance Log: %s\n", runtime_sandbox_perf_log_path);
runtime_sandbox_perf_log = fopen(runtime_sandbox_perf_log_path, "w"); runtime_sandbox_perf_log = fopen(runtime_sandbox_perf_log_path, "w");
if (runtime_sandbox_perf_log == NULL) { perror("sandbox perf log"); } if (runtime_sandbox_perf_log == NULL) { perror("sandbox perf log"); }
fprintf(runtime_sandbox_perf_log, "id,function,state,deadline,actual,queued,initializing,runnable," fprintf(runtime_sandbox_perf_log, "id,module,port,state,deadline,actual,queued,initializing,runnable,"
"running,blocked,returned,memory\n"); "running,blocked,returned,proc_MHz,memory\n");
} else { } else {
printf("\tSandbox Performance Log: Disabled\n"); printf("\tSandbox Performance Log: Disabled\n");
} }

@ -101,6 +101,8 @@ runtime_initialize(void)
/* Configure Signals */ /* Configure Signals */
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, runtime_cleanup); signal(SIGTERM, runtime_cleanup);
signal(SIGINT, runtime_cleanup);
signal(SIGQUIT, runtime_cleanup);
http_parser_settings_initialize(); http_parser_settings_initialize();
admissions_control_initialize(); admissions_control_initialize();

Loading…
Cancel
Save