From e4f0bcf8f72a0ae678ce37869600acfbf814fea5 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 4 Jun 2021 00:42:36 +0000 Subject: [PATCH] refactor: streamline perf log logic --- runtime/include/sandbox_functions.h | 17 ++++++----------- runtime/src/main.c | 4 ++-- runtime/src/runtime.c | 2 ++ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/runtime/include/sandbox_functions.h b/runtime/include/sandbox_functions.h index f64db9f..529f20f 100644 --- a/runtime/include/sandbox_functions.h +++ b/runtime/include/sandbox_functions.h @@ -155,22 +155,17 @@ sandbox_print_perf(struct sandbox *sandbox) /* If the log was not defined by an environment variable, early out */ if (runtime_sandbox_perf_log == NULL) return; - uint32_t total_time_us = sandbox->total_time / runtime_processor_speed_MHz; - 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; + uint64_t queued_duration = sandbox->allocation_timestamp - sandbox->request_arrival_timestamp; /* * 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 * 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->relative_deadline_us, total_time_us, queued_us, initializing_us, runnable_us, - running_us, blocked_us, returned_us, sandbox->linear_memory_size); + sandbox->module->relative_deadline, sandbox->total_time, queued_duration, + sandbox->initializing_duration, sandbox->runnable_duration, sandbox->running_duration, + sandbox->blocked_duration, sandbox->returned_duration, runtime_processor_speed_MHz, + sandbox->linear_memory_size); } diff --git a/runtime/src/main.c b/runtime/src/main.c index e2101ce..1404eee 100644 --- a/runtime/src/main.c +++ b/runtime/src/main.c @@ -224,8 +224,8 @@ runtime_configure() printf("\tSandbox Performance Log: %s\n", runtime_sandbox_perf_log_path); runtime_sandbox_perf_log = fopen(runtime_sandbox_perf_log_path, "w"); if (runtime_sandbox_perf_log == NULL) { perror("sandbox perf log"); } - fprintf(runtime_sandbox_perf_log, "id,function,state,deadline,actual,queued,initializing,runnable," - "running,blocked,returned,memory\n"); + fprintf(runtime_sandbox_perf_log, "id,module,port,state,deadline,actual,queued,initializing,runnable," + "running,blocked,returned,proc_MHz,memory\n"); } else { printf("\tSandbox Performance Log: Disabled\n"); } diff --git a/runtime/src/runtime.c b/runtime/src/runtime.c index 7b061fc..be2df92 100644 --- a/runtime/src/runtime.c +++ b/runtime/src/runtime.c @@ -101,6 +101,8 @@ runtime_initialize(void) /* Configure Signals */ signal(SIGPIPE, SIG_IGN); signal(SIGTERM, runtime_cleanup); + signal(SIGINT, runtime_cleanup); + signal(SIGQUIT, runtime_cleanup); http_parser_settings_initialize(); admissions_control_initialize();