correct queuing time and total time for chain function

main
xiaosuGW 3 years ago
parent 17141a07aa
commit 5dbbf31ba5

@ -166,7 +166,9 @@ sandbox_print_perf(struct sandbox *sandbox)
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; uint32_t total_time_us = sandbox->total_time / runtime_processor_speed_MHz;
uint32_t queued_us = (sandbox->allocation_timestamp - sandbox->request_arrival_timestamp) uint32_t execution_time_ms = (sandbox->completion_timestamp - sandbox->start_execution_timestamp)
/ runtime_processor_speed_MHz;
uint32_t queued_us = (sandbox->allocation_timestamp - sandbox->enqueue_timestamp)
/ runtime_processor_speed_MHz; / runtime_processor_speed_MHz;
uint32_t initializing_us = sandbox->initializing_duration / 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 runnable_us = sandbox->runnable_duration / runtime_processor_speed_MHz;
@ -179,9 +181,9 @@ sandbox_print_perf(struct sandbox *sandbox)
* 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,%u,%u,%u,%u,%u,%u,%u,%u,%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_us, total_time_us, queued_us, initializing_us, runnable_us,
running_us, blocked_us, returned_us, sandbox->linear_memory_size); running_us, blocked_us, returned_us, execution_time_ms, sandbox->linear_memory_size);
fflush(runtime_sandbox_perf_log); fflush(runtime_sandbox_perf_log);
} }

@ -21,6 +21,7 @@ struct sandbox_request {
int socket_descriptor; int socket_descriptor;
struct sockaddr socket_address; struct sockaddr socket_address;
uint64_t request_arrival_timestamp; /* cycles */ uint64_t request_arrival_timestamp; /* cycles */
uint64_t enqueue_timestamp; /* cycles */
uint64_t absolute_deadline; /* cycles */ uint64_t absolute_deadline; /* cycles */
char * previous_function_output; char * previous_function_output;
ssize_t output_length; ssize_t output_length;
@ -70,8 +71,8 @@ sandbox_request_log_allocation(struct sandbox_request *sandbox_request)
static inline struct sandbox_request * static inline struct sandbox_request *
sandbox_request_allocate(struct module *module, bool request_from_outside, ssize_t request_length, sandbox_request_allocate(struct module *module, bool request_from_outside, ssize_t request_length,
char *arguments, int socket_descriptor, const struct sockaddr *socket_address, char *arguments, int socket_descriptor, const struct sockaddr *socket_address,
uint64_t request_arrival_timestamp, uint64_t admissions_estimate, uint64_t request_arrival_timestamp, uint64_t enqueue_timestamp,
char *previous_function_output, ssize_t output_length) uint64_t admissions_estimate, char *previous_function_output, ssize_t output_length)
{ {
struct sandbox_request *sandbox_request = (struct sandbox_request *)malloc(sizeof(struct sandbox_request)); struct sandbox_request *sandbox_request = (struct sandbox_request *)malloc(sizeof(struct sandbox_request));
assert(sandbox_request); assert(sandbox_request);
@ -85,6 +86,7 @@ sandbox_request_allocate(struct module *module, bool request_from_outside, ssize
sandbox_request->socket_descriptor = socket_descriptor; sandbox_request->socket_descriptor = socket_descriptor;
memcpy(&sandbox_request->socket_address, socket_address, sizeof(struct sockaddr)); memcpy(&sandbox_request->socket_address, socket_address, sizeof(struct sockaddr));
sandbox_request->request_arrival_timestamp = request_arrival_timestamp; sandbox_request->request_arrival_timestamp = request_arrival_timestamp;
sandbox_request->enqueue_timestamp = enqueue_timestamp;
sandbox_request->absolute_deadline = request_arrival_timestamp + module->relative_deadline; sandbox_request->absolute_deadline = request_arrival_timestamp + module->relative_deadline;
sandbox_request->previous_function_output = previous_function_output; sandbox_request->previous_function_output = previous_function_output;
sandbox_request->output_length = output_length; sandbox_request->output_length = output_length;

@ -96,7 +96,7 @@ sandbox_send_response(struct sandbox *sandbox)
/* Capture Timekeeping data for end-to-end latency */ /* Capture Timekeeping data for end-to-end latency */
uint64_t end_time = __getcycles(); uint64_t end_time = __getcycles();
sandbox->total_time = end_time - sandbox->request_arrival_timestamp; sandbox->total_time = end_time - sandbox->enqueue_timestamp;
int rc; int rc;
int sent = 0; int sent = 0;

@ -30,6 +30,7 @@ sandbox_set_as_initialized(struct sandbox *sandbox, struct sandbox_request *sand
sandbox->admissions_estimate = sandbox_request->admissions_estimate; sandbox->admissions_estimate = sandbox_request->admissions_estimate;
sandbox->request_arrival_timestamp = sandbox_request->request_arrival_timestamp; sandbox->request_arrival_timestamp = sandbox_request->request_arrival_timestamp;
sandbox->enqueue_timestamp = sandbox_request->enqueue_timestamp;
sandbox->allocation_timestamp = allocation_timestamp; sandbox->allocation_timestamp = allocation_timestamp;
sandbox->state = SANDBOX_SET_AS_INITIALIZED; sandbox->state = SANDBOX_SET_AS_INITIALIZED;

@ -32,7 +32,7 @@ sandbox_set_as_returned(struct sandbox *sandbox, sandbox_state_t last_state)
switch (last_state) { switch (last_state) {
case SANDBOX_RUNNING: { case SANDBOX_RUNNING: {
sandbox->response_timestamp = now; sandbox->response_timestamp = now;
sandbox->total_time = now - sandbox->request_arrival_timestamp; sandbox->total_time = now - sandbox->enqueue_timestamp;
sandbox->running_duration += duration_of_last_state; sandbox->running_duration += duration_of_last_state;
local_runqueue_delete(sandbox); local_runqueue_delete(sandbox);
sandbox_free_linear_memory(sandbox); sandbox_free_linear_memory(sandbox);

@ -50,6 +50,8 @@ struct sandbox {
struct arch_context ctxt; /* register context for context switch. */ struct arch_context ctxt; /* register context for context switch. */
uint64_t request_arrival_timestamp; /* Timestamp when request is received */ uint64_t request_arrival_timestamp; /* Timestamp when request is received */
uint64_t enqueue_timestamp; /* Timestamp when sandbox request is enqueued */
uint64_t start_execution_timestamp; /* Timestamp when sandbox starts execution */
uint64_t allocation_timestamp; /* Timestamp when sandbox is allocated */ uint64_t allocation_timestamp; /* Timestamp when sandbox is allocated */
uint64_t response_timestamp; /* Timestamp when response is sent */ uint64_t response_timestamp; /* Timestamp when response is sent */
uint64_t completion_timestamp; /* Timestamp when sandbox runs to completion */ uint64_t completion_timestamp; /* Timestamp when sandbox runs to completion */
@ -67,6 +69,7 @@ struct sandbox {
uint64_t absolute_deadline; uint64_t absolute_deadline;
uint64_t total_time; /* From Request to Response */ uint64_t total_time; /* From Request to Response */
uint64_t execution_time; /* From running to response */
/* /*
* Unitless estimate of the instantaneous fraction of system capacity required to run the request * Unitless estimate of the instantaneous fraction of system capacity required to run the request

@ -61,9 +61,11 @@ current_sandbox_disable_preemption(struct sandbox *sandbox)
void void
current_sandbox_start(void) current_sandbox_start(void)
{ {
uint64_t start_execution_timestamp = __getcycles();
struct sandbox *sandbox = current_sandbox_get(); struct sandbox *sandbox = current_sandbox_get();
assert(sandbox != NULL); assert(sandbox != NULL);
assert(sandbox->state == SANDBOX_RUNNING); assert(sandbox->state == SANDBOX_RUNNING);
sandbox->start_execution_timestamp = start_execution_timestamp;
char *error_message = ""; char *error_message = "";
@ -109,11 +111,13 @@ current_sandbox_start(void)
ssize_t output_length = sandbox->request_response_data_length - sandbox->request_length; ssize_t output_length = sandbox->request_response_data_length - sandbox->request_length;
char * pre_func_output = (char *) malloc(output_length); char * pre_func_output = (char *) malloc(output_length);
memcpy(pre_func_output, sandbox->request_response_data + sandbox->request_length, output_length); memcpy(pre_func_output, sandbox->request_response_data + sandbox->request_length, output_length);
uint64_t enqueue_timestamp = __getcycles();
struct sandbox_request *sandbox_request = struct sandbox_request *sandbox_request =
sandbox_request_allocate(next_module, false, sandbox->request_length, sandbox_request_allocate(next_module, false, sandbox->request_length,
next_module->name, sandbox->client_socket_descriptor, next_module->name, sandbox->client_socket_descriptor,
(const struct sockaddr *)&sandbox->client_address, (const struct sockaddr *)&sandbox->client_address,
sandbox->request_arrival_timestamp, true, pre_func_output, output_length); sandbox->request_arrival_timestamp, enqueue_timestamp,
true, pre_func_output, output_length);
/* reset the request id to the same as the current request id */ /* reset the request id to the same as the current request id */
sandbox_request->id = sandbox->id; sandbox_request->id = sandbox->id;
/* Add to the Global Sandbox Request Scheduler */ /* Add to the Global Sandbox Request Scheduler */

@ -179,7 +179,8 @@ listener_thread_main(void *dummy)
struct sandbox_request *sandbox_request = struct sandbox_request *sandbox_request =
sandbox_request_allocate(module, true, 0, module->name, client_socket, sandbox_request_allocate(module, true, 0, module->name, client_socket,
(const struct sockaddr *)&client_address, (const struct sockaddr *)&client_address,
request_arrival_timestamp, work_admitted, NULL, 0); request_arrival_timestamp, request_arrival_timestamp,
work_admitted, NULL, 0);
/* Add to the Global Sandbox Request Scheduler */ /* Add to the Global Sandbox Request Scheduler */
global_request_scheduler_add(sandbox_request); global_request_scheduler_add(sandbox_request);

@ -225,7 +225,7 @@ runtime_configure()
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,function,state,deadline,actual,queued,initializing,runnable,"
"running,blocked,returned,memory\n"); "running,blocked,returned,execution,memory\n");
fflush(runtime_sandbox_perf_log); fflush(runtime_sandbox_perf_log);
} else { } else {
printf("\tSandbox Performance Log: Disabled\n"); printf("\tSandbox Performance Log: Disabled\n");

@ -1,6 +1,6 @@
include Makefile.inc include Makefile.inc
TESTS=fibonacci empty work work1k work10k work100k work1m forever filesys sockserver sockclient empty TESTS=fibonacci big_fibonacci empty work work1k work10k work100k work1m forever filesys sockserver sockclient empty
TESTSRT=$(TESTS:%=%_rt) TESTSRT=$(TESTS:%=%_rt)

Loading…
Cancel
Save