add workload counter for each worker thread

main
xiaosuGW 3 years ago
parent 42e3628a10
commit 66b20d20c0

@ -22,3 +22,5 @@ void local_runqueue_delete(struct sandbox *);
bool local_runqueue_is_empty();
struct sandbox *local_runqueue_get_next();
void local_runqueue_initialize(struct local_runqueue_config *config);
void local_workload_add();
void local_workload_complete();

@ -46,9 +46,9 @@ sandbox_receive_request(struct sandbox *sandbox)
if (recved < 0) {
if (errno == EAGAIN) {
uint64_t block_time = __getcycles() - system_start_timestamp;
mem_log("time %lu blocked, request id:%d name %s obj=%p remaining slack %lu\n", block_time,
sandbox->id, sandbox->module->name, sandbox, sandbox->remaining_slack);
//uint64_t block_time = __getcycles() - system_start_timestamp;
//mem_log("time %lu blocked, request id:%d name %s obj=%p remaining slack %lu\n", block_time,
// sandbox->id, sandbox->module->name, sandbox, sandbox->remaining_slack);
scheduler_block();
continue;
} else {

@ -41,6 +41,7 @@ sandbox_set_as_error(struct sandbox *sandbox, sandbox_state_t last_state)
case SANDBOX_RUNNING: {
sandbox->running_duration += duration_of_last_state;
local_runqueue_delete(sandbox);
local_workload_complete();
break;
}
default: {

@ -35,6 +35,7 @@ sandbox_set_as_returned(struct sandbox *sandbox, sandbox_state_t last_state)
sandbox->total_time = now - sandbox->enqueue_timestamp;
sandbox->running_duration += duration_of_last_state;
local_runqueue_delete(sandbox);
local_workload_complete();
sandbox_free_linear_memory(sandbox);
break;
}

@ -33,6 +33,7 @@ sandbox_set_as_runnable(struct sandbox *sandbox, sandbox_state_t last_state)
case SANDBOX_INITIALIZED: {
sandbox->initializing_duration += duration_of_last_state;
local_runqueue_add(sandbox);
local_workload_add();
break;
}
case SANDBOX_BLOCKED: {

@ -21,9 +21,9 @@ sandbox_set_as_running(struct sandbox *sandbox, sandbox_state_t last_state)
switch (last_state) {
case SANDBOX_RUNNABLE: {
uint64_t start_execution = now - system_start_timestamp;
uint64_t last = sandbox->last_update_timestamp;
uint64_t last_rs = sandbox->remaining_slack;
//uint64_t start_execution = now - system_start_timestamp;
//uint64_t last = sandbox->last_update_timestamp;
//uint64_t last_rs = sandbox->remaining_slack;
sandbox->remaining_slack -= (now - sandbox->last_update_timestamp);
sandbox->last_update_timestamp = now;
sandbox->runnable_duration += duration_of_last_state;

@ -84,9 +84,9 @@ scheduler_srsf_get_next()
if (global_remaining_slack < local_remaining_slack) {
if (global_request_scheduler_remove_if_earlier(&request, local_remaining_slack) == 0) {
uint64_t pop_time = __getcycles() - system_start_timestamp;
mem_log("time %lu remove from GQ, request id:%d name %s remaining slack %lu\n", pop_time,
request->id, request->module->name, request->remaining_slack);
//uint64_t pop_time = __getcycles() - system_start_timestamp;
//mem_log("time %lu remove from GQ, request id:%d name %s remaining slack %lu\n", pop_time,
// request->id, request->module->name, request->remaining_slack);
assert(request != NULL);
struct sandbox *global = sandbox_allocate(request);

@ -123,9 +123,9 @@ current_sandbox_start(void)
memcpy(pre_func_output, sandbox->request_response_data + sandbox->request_length, output_length);
uint64_t enqueue_timestamp = __getcycles();
uint64_t current_rs = enqueue_timestamp - system_start_timestamp;
mem_log("time %lu request id:%d executing, name:%s remaining slack %lu\n", current_rs,
sandbox->id, sandbox->module->name, sandbox->remaining_slack);
//uint64_t current_rs = enqueue_timestamp - system_start_timestamp;
//mem_log("time %lu request id:%d executing, name:%s remaining slack %lu\n", current_rs,
// sandbox->id, sandbox->module->name, sandbox->remaining_slack);
struct sandbox_request *sandbox_request =
sandbox_request_allocate(next_module, false, sandbox->request_length,
next_module->name, sandbox->client_socket_descriptor,

@ -11,6 +11,7 @@ static struct local_runqueue_config local_runqueue;
__thread uint32_t local_runqueue_count = 0;
#endif
__thread uint32_t local_workload_count = 0;
/* Initializes a concrete implementation of the sandbox request scheduler interface */
void
local_runqueue_initialize(struct local_runqueue_config *config)
@ -67,3 +68,19 @@ local_runqueue_get_next()
assert(local_runqueue.get_next_fn != NULL);
return local_runqueue.get_next_fn();
};
/**
* The worker thread gets a new request, add the workload counter by 1
*/
void
local_workload_add() {
local_workload_count++;
}
/**
* One request is complete on the worker thread, and decrease the workload counter by 1
*/
void
local_workload_complete() {
local_workload_count--;
}

@ -85,9 +85,9 @@ worker_thread_main(void *argument)
next_sandbox = scheduler_get_next();
if (next_sandbox != NULL) {
uint64_t start_execution = __getcycles() - system_start_timestamp;
mem_log("time %lu pop from GQ, request id:%d name %s obj=%p remaining slack %lu last_update_time %lu \n", start_execution,
next_sandbox->id, next_sandbox->module->name, next_sandbox, next_sandbox->remaining_slack, next_sandbox->last_update_timestamp);
//uint64_t start_execution = __getcycles() - system_start_timestamp;
//mem_log("time %lu pop from GQ, request id:%d name %s obj=%p remaining slack %lu last_update_time %lu \n", start_execution,
// next_sandbox->id, next_sandbox->module->name, next_sandbox, next_sandbox->remaining_slack, next_sandbox->last_update_timestamp);
scheduler_switch_to(next_sandbox);
}

Loading…
Cancel
Save