hwwang 4 months ago
parent 8ae955fbfc
commit 0f9b75d784

@ -13,6 +13,7 @@
extern uint64_t system_start_timestamp; extern uint64_t system_start_timestamp;
lock_t lock; lock_t lock;
#define OUTPUT_BUFER_SIZE 1024*5
__thread struct sandbox *worker_thread_current_sandbox = NULL; __thread struct sandbox *worker_thread_current_sandbox = NULL;
__thread struct sandbox_context_cache local_sandbox_context_cache = { __thread struct sandbox_context_cache local_sandbox_context_cache = {
@ -225,6 +226,7 @@ current_sandbox_start(void)
cur_request_id = (char *)malloc(key_len); cur_request_id = (char *)malloc(key_len);
assert(cur_request_id); assert(cur_request_id);
snprintf(cur_request_id, key_len, "%s%lu", next_module_node->name, sandbox->id); snprintf(cur_request_id, key_len, "%s%lu", next_module_node->name, sandbox->id);
debuglog("the cur_request_id is %s\n", cur_request_id);
uint32_t ret_value_len; uint32_t ret_value_len;
LOCK_LOCK(&lock); LOCK_LOCK(&lock);
//printf("锁住了\n"); //printf("锁住了\n");
@ -281,8 +283,8 @@ current_sandbox_start(void)
goto err; goto err;
} }
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);
//printf("这是合并sandbox_request模块工作结果 the ID %lu %s pre_func_output is %s\n", sandbox->id, sandbox->module->name, pre_func_output); debuglog("这是合并sandbox_request模块工作结果 the ID %lu %s pre_func_output is %s\n", sandbox->id, sandbox->module->name, pre_func_output);
ssize_t new_output_length = sandbox_request->output_length + output_length + 2; ssize_t new_output_length = sandbox_request->output_length + output_length + 1;
char *new_output = (char *)malloc(new_output_length); char *new_output = (char *)malloc(new_output_length);
if (!new_output) { if (!new_output) {
fprintf(stderr, "Failed to allocate memory for the new output: %s\n", strerror(errno)); fprintf(stderr, "Failed to allocate memory for the new output: %s\n", strerror(errno));
@ -297,7 +299,7 @@ current_sandbox_start(void)
} }
assert(new_output); assert(new_output);
sandbox_request->previous_function_output = new_output; sandbox_request->previous_function_output = new_output;
//printf("这是合并sandbox_request 模块工作结果 the ID %lu %s new_output is %s\n", sandbox->id, sandbox->module->name, new_output); debuglog("这是合并sandbox_request 模块工作结果 the ID %lu %s new_output is %s\n", sandbox->id, sandbox->module->name, new_output);
free(pre_func_output); free(pre_func_output);
pre_func_output = NULL; pre_func_output = NULL;
sandbox_request->output_length = new_output_length; sandbox_request->output_length = new_output_length;

@ -633,20 +633,24 @@ module_new_from_json(char *file_name)
for (int i = 0; i < module_count; i++) { for (int i = 0; i < module_count; i++) {
assert(nodes[i]); assert(nodes[i]);
uint32_t count = nodes[i]->next_module_count; uint32_t next_module_count = nodes[i]->next_module_count;
if (count == 0) continue; if (next_module_count == 0) continue;
nodes[i]->next_module = (struct module**) malloc(count * sizeof(struct module*)); nodes[i]->next_module = (struct module**) malloc( next_module_count * sizeof(struct module*));
if (nodes[i]->next_module == NULL) panic("Failed to allocate memory for next_module"); if (nodes[i]->next_module == NULL) panic("Failed to allocate memory for next_module");
for (int next_module_mem = 0; next_module_mem < next_module_count; next_module_mem++) nodes[i]->next_module[next_module_mem] = NULL;
for (int j = 0; j < count; j++) { for (int j = 0; j < next_module_count; j++) {
for (int m = i + 1; m < module_count; m++) { for (int m = i + 1; m < module_count; m++) {
if (strncmp(nodes[i]->next_module_names[j], nodes[m]->name, MODULE_MAX_NAME_LENGTH) == 0) { if (strncmp(nodes[i]->next_module_names[j], nodes[m]->name, MODULE_MAX_NAME_LENGTH) == 0) {
assert(nodes[m]); assert(nodes[m]);
uint32_t precount = nodes[m]->pre_module_count; uint32_t precount = nodes[m]->pre_module_count;
assert(precount);
if (nodes[m]->pre_module == NULL) { if (nodes[m]->pre_module == NULL) {
nodes[m]->pre_module = (struct module**) malloc(precount * sizeof(struct module*)); nodes[m]->pre_module = (struct module**) malloc(precount * sizeof(struct module*));
if (nodes[m]->pre_module == NULL) panic("Failed to allocate memory for pre_module"); if (nodes[m]->pre_module == NULL) panic("Failed to allocate memory for pre_module");
for (int k = 0; k < precount; k++) {
nodes[m]->pre_module[k] = NULL;
}
} }
nodes[i]->next_module[j] = nodes[m]; nodes[i]->next_module[j] = nodes[m];
int preflag = 0; int preflag = 0;

@ -0,0 +1,368 @@
{
"active": true,
"name": "resize1",
"path": "resize_wasm.so",
"port": 10000,
"relative-deadline-us": 78574,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp1",
"path": "C-Image-Manip_wasm.so",
"port": 10001,
"relative-deadline-us": 78574,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "cifar10_1",
"path": "cifar10_wasm.so",
"port": 10002,
"relative-deadline-us": 78574,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
"tail-module": true
},
{
"active": true,
"name": "resize2",
"path": "resize_wasm.so",
"port": 10003,
"relative-deadline-us": 192762,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp2",
"path": "C-Image-Manip_wasm.so",
"port": 10004,
"relative-deadline-us": 192762,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "cifar10_2",
"path": "cifar10_wasm.so",
"port": 10005,
"relative-deadline-us": 192762,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
"tail-module": true
},
{
"active": true,
"name": "resize3",
"path": "resize_wasm.so",
"port": 10006,
"relative-deadline-us": 16346,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp3",
"path": "C-Image-Manip_wasm.so",
"port": 10007,
"relative-deadline-us": 16346,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "cifar10_3",
"path": "cifar10_wasm.so",
"port": 10008,
"relative-deadline-us": 16346,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
"tail-module": true
},
{
"active": true,
"name": "resize4",
"path": "resize_wasm.so",
"port": 10009,
"relative-deadline-us": 47824,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp4",
"path": "C-Image-Manip_wasm.so",
"port": 10010,
"relative-deadline-us": 47824,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "cifar10_4",
"path": "cifar10_wasm.so",
"port": 10011,
"relative-deadline-us": 47824,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
"tail-module": true
},
{
"active": true,
"name": "resize5",
"path": "resize_wasm.so",
"port": 10012,
"relative-deadline-us": 392870,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp5",
"path": "C-Image-Manip_wasm.so",
"port": 10013,
"relative-deadline-us": 392870,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "cifar10_5",
"path": "cifar10_wasm.so",
"port": 10014,
"relative-deadline-us": 392870,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
"tail-module": true
},
{
"active": true,
"name": "resize6",
"path": "resize_wasm.so",
"port": 10015,
"relative-deadline-us": 963810,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp6",
"path": "C-Image-Manip_wasm.so",
"port": 10016,
"relative-deadline-us": 963810,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "cifar10_6",
"path": "cifar10_wasm.so",
"port": 10017,
"relative-deadline-us": 963810,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
"tail-module": true
},
{
"active": true,
"name": "resize7",
"path": "resize_wasm.so",
"port": 10018,
"relative-deadline-us": 81730,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp7",
"path": "C-Image-Manip_wasm.so",
"port": 10019,
"relative-deadline-us": 81730,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "cifar10_7",
"path": "cifar10_wasm.so",
"port": 10020,
"relative-deadline-us": 81730,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
"tail-module": true
},
{
"active": true,
"name": "resize8",
"path": "resize_wasm.so",
"port": 10021,
"relative-deadline-us": 239120,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/jpeg",
"http-req-size": 1024000,
"http-resp-headers": [],
"http-resp-size": 1024000,
"http-resp-content-type": "image/png"
},
{
"active": true,
"name": "png2bmp8",
"path": "C-Image-Manip_wasm.so",
"port": 10022,
"relative-deadline-us": 239120,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/png",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "image/bmp"
},
{
"active": true,
"name": "cifar10_8",
"path": "cifar10_wasm.so",
"port": 10023,
"relative-deadline-us": 239120,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
"tail-module": true
},

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save