hwwang 6 months ago
parent a6e464db44
commit 73da853ad4

@ -20,7 +20,6 @@
#define MODULE_DEFAULT_REQUEST_RESPONSE_SIZE (PAGE_SIZE)
#define MODULE_MAX_ARGUMENT_COUNT 16
#define MODULE_MAX_ARGUMENT_SIZE 64
#define MODULE_MAX_NAME_LENGTH 32
@ -79,15 +78,7 @@ struct module {
/* Entry Function to invoke serverless function */
mod_main_fn_t main;
//struct module *next_module; /* the next module in the chain */
/* the left and right children module in the tree */
struct module *left_module;
struct module *right_module;
/* parent module or not?*/
bool is_parent;
struct module *next_module; /* the next module in the chain */
};
/*************************

@ -225,8 +225,7 @@ sandbox_mem_print_perf(struct sandbox *sandbox)
uint64_t blocked_us = sandbox->blocked_duration / runtime_processor_speed_MHz;
uint64_t returned_us = sandbox->returned_duration / runtime_processor_speed_MHz;
//if (sandbox->module->next_module == NULL) {
if(sandbox->module->is_parent) {
if (sandbox->module->next_module == NULL) {
uint64_t total_time = (sandbox->completion_timestamp - sandbox->request_arrival_timestamp) / runtime_processor_speed_MHz;
bool miss_deadline = sandbox->completion_timestamp > sandbox->absolute_deadline ? true : false;
uint64_t delayed_us = (sandbox->completion_timestamp - sandbox->absolute_deadline)

@ -19,8 +19,7 @@
const int JSON_MAX_ELEMENT_COUNT = 16;
const int JSON_MAX_ELEMENT_SIZE = 1024;
DEQUE_PROTOTYPE(Treequeue,struct module *)
static struct deque_Treequeue *tree_queue;
/*************************
* Private Static Inline *
************************/
@ -375,29 +374,7 @@ module_new_from_json(char *file_name)
int module_count = 0;
char *request_headers = NULL;
char *reponse_headers = NULL;
/* struct module *tail_module = NULL;
deque_init_Treequeue(tree_queue, total_tokens);
assert(tokens[0].type == JSMN_OBJECT);
while (deque_is_empty_Treequeue(tree_queue))
{
Node *current = dequeue(&queue);
if (is_parent) {
current->left = getNextNode();
enqueue(&queue, current->left);
}
if (is_parent) {
current->right = getNextNode();
enqueue(&queue, current->right);
}
}
}*/
struct module **nodes = malloc(JSON_MAX_ELEMENT_COUNT * sizeof(struct module*));
if (nodes == NULL) {
fprintf(stderr, "Memory allocation failed for nodes array\n");
}
struct module *tail_module = NULL;
for (int i = 0; i < total_tokens; i++) {
assert(tokens[i].type == JSMN_OBJECT);
@ -477,18 +454,7 @@ module_new_from_json(char *file_name)
} else {
panic("Expected active key to be a JSON boolean, was %s\n", val);
}
}else if(strcmp(key,"is_parent") == 0)
{
assert(tokens[i + j + 1].type == JSMN_PRIMITIVE);
if (val[0] == 't') {
is_tail_module = true;
} else if (val[0] == 'f') {
is_tail_module = false;
} else {
panic("Expected is-parent key to be a JSON boolean, was %s\n", val);
}
}
/*else if (strcmp(key, "tail-module") == 0) {
} else if (strcmp(key, "tail-module") == 0) {
assert(tokens[i + j + 1].type == JSMN_PRIMITIVE);
if (val[0] == 't') {
is_tail_module = true;
@ -497,7 +463,7 @@ module_new_from_json(char *file_name)
} else {
panic("Expected tail_module key to be a JSON boolean, was %s\n", val);
}
}*/else if (strcmp(key, "relative-deadline-us") == 0) {
} else if (strcmp(key, "relative-deadline-us") == 0) {
int64_t buffer = strtoll(val, NULL, 10);
if (buffer < 0 || buffer > (int64_t)RUNTIME_RELATIVE_DEADLINE_US_MAX)
panic("Relative-deadline-us must be between 0 and %ld, was %ld\n",
@ -602,16 +568,15 @@ module_new_from_json(char *file_name)
if (module == NULL) goto module_new_err;
assert(module);
if(is_tail_module) module->is_parent = true;
nodes[i] = module;
// if (tail_module != NULL) { tail_module->next_module = module; }
// tail_module = module;
// tail_module->next_module = NULL;
// /* if this is the tail module, reset tail_module to NULL to build another new chain */
// if (is_tail_module) {
// tail_module = NULL;
// }
if (tail_module != NULL) { tail_module->next_module = module; }
tail_module = module;
tail_module->next_module = NULL;
/* if this is the tail module, reset tail_module to NULL to build another new chain */
if (is_tail_module) {
tail_module = NULL;
}
module_set_http_info(module, request_count, request_headers, request_content_type,
response_count, reponse_headers, response_content_type);
@ -623,13 +588,6 @@ module_new_from_json(char *file_name)
}
if (module_count == 0) panic("%s contained no active modules\n", file_name);
for (int i = 0; i <= module_count; i++) {
int left_index = 2 * i + 1;
int right_index = 2 * i + 2;
if (left_index <= module_count) nodes[i]->left_module = nodes[left_index];
if (right_index <= module_count) nodes[i]->right_module = nodes[right_index];
}
free(nodes);
#ifdef LOG_MODULE_LOADING
debuglog("Loaded %d module%s!\n", module_count, module_count > 1 ? "s" : "");
#endif

Loading…
Cancel
Save