修改打印的bug,添加图片测试脚本

sledge_graph
hwwang 6 months ago
parent 4b2a905e92
commit a66ea1bc25

2
.gitignore vendored

@ -56,6 +56,8 @@ runtime/tests/tmp/
runtime/tests/**/*.csv
runtime/tests/**/*.txt
runtime/tests/**/*.xlsx
runtime/tests/test_data
runtime/tests/*.log
# Swap Files
*.swp

@ -10,10 +10,10 @@ PAGE_SIZE := $(shell getconf PAGESIZE)
# Compiler Settings
CC=clang
# CC_OPTIONS = -O3 -flto -g -pthread -D_GNU_SOURCE
CC_OPTIONS = -O3 -flto -g -pthread -D_GNU_SOURCE
# CC_OPTIONS for Debugging
CC_OPTIONS = -O0 -g -pthread -D_GNU_SOURCE
# CC_OPTIONS = -O0 -g -pthread -D_GNU_SOURCE
# CFI Sanitizer
# CC_OPTIONS = -O0 -g -pthread -D_GNU_SOURCE -flto -fvisibility=default -fsanitize=cfi

@ -242,7 +242,7 @@ sandbox_mem_print_perf(struct sandbox *sandbox)
* becomes more intelligent, then peak linear memory size needs to be tracked
* seperately from current linear memory size.
*/
mem_log("%d,%u,%s():%d,%s,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%u\n", worker_thread_idx, sandbox->id,
mem_log("%d,%lu,%s():%d,%s,%u,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%u\n", worker_thread_idx, 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);

@ -178,33 +178,34 @@ listener_thread_main(void *dummy)
continue;
}
/* get total estimated execution time */
uint64_t estimated_execution_time = 0;
int front = 0, rear = 0;
struct module **queue = malloc(QUEUE_SIZE * sizeof(struct module*));
if (queue == NULL) {
panic("Failed to allocate listen.c queue memory for queue");
}
queue[rear++] = module;
while (rear != front)
{
struct module *current_module = queue[front++];
estimated_execution_time += admission_info_get_percentile(&current_module->admissions_info);
for (int i = 0; i < current_module->next_module_count; i++) {
if (current_module->next_module[i] != NULL && !current_module->next_module[i]->runtime_visited)
{
queue[rear++] = current_module->next_module[i];
current_module->next_module[i]->runtime_visited = true;
}
}
/*Recover the flags of the module here, so that it can be accessed next time.*/
uint64_t estimated_execution_time = 0;
int front = 0, rear = 0;
struct module *queue[QUEUE_SIZE] = {NULL};
queue[rear++] = module;
while (rear != front)
{
struct module *current_module = queue[front++];
estimated_execution_time += admission_info_get_percentile(&current_module->admissions_info);
for (int i = 0; i < current_module->next_module_count; i++) {
if (current_module->next_module[i] != NULL && !current_module->next_module[i]->runtime_visited)
{
queue[rear++] = current_module->next_module[i];
current_module->next_module[i]->runtime_visited = true;
}
}
assert(rear <= QUEUE_SIZE);
assert(front <= QUEUE_SIZE);
}
/*Recover the flags of the module here, so that it can be accessed next time.*/
for (int i = 0; i < QUEUE_SIZE; i++) {
if (queue[i] != NULL) {
struct module *current_module = queue[i];
current_module->runtime_visited = false;
assert(rear <= QUEUE_SIZE);
assert(front <= QUEUE_SIZE);
}
free(queue);
}
}
/* Adding system start timestamp to avoid negative remaining slack in the following update. They are all cycles */
uint64_t remaining_slack = system_start_timestamp + module->relative_deadline - estimated_execution_time;
uint64_t remaining_slack = system_start_timestamp + module->relative_deadline - estimated_execution_time;
/* Allocate a Sandbox Request */
struct sandbox_request *sandbox_request =

@ -2,7 +2,7 @@ include Makefile.inc
#TESTS=fibonacci fibonacci2 fibonacci3 big_fibonacci C-Image-Manip empty work work1k work10k work100k work1m forever filesys sockserver sockclient empty
TESTS=fibonacci big_fibonacci C-Image-Manip empty work work1k work10k work100k work1m forever filesys sockserver sockclient empty
TESTS2=fibonacciadd mem
TESTS2=fibonacciadd mem work3
TESTSRT=$(TESTS:%=%_rt)
TESTSRT2=$(TESTS2:%=%_rt)

@ -1,2 +1,2 @@
sudo chsh -s /bin/bash hai
sudo chsh -s /bin/bash weihao

@ -37,7 +37,8 @@ cd $project_path/runtime/bin
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/mulitple_linear_chain.json
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_multiple_image_processing.json
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_multiple_image_processing3.json
LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_multiple_image_processing4.json
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_multiple_image_processing4.json
LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_multiple_image_processing_graph.json
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/my_fibonacci.json
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_sodresize.json
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/my_sodresize.json

@ -0,0 +1,30 @@
#!/bin/bash
function usage {
echo "$0 [cpu-log]"
exit 1
}
chmod 400 ./id_rsa
path="/home/weihao/sledge/sledge_tree/runtime/tests"
#test single 5k c5 50% max RPS (500)
f1="5k_single_50.txt"
server_log_file="execution_single_5k_50.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_rps.sh $f1 120 50 5k.jpg 10000 2>&1 &
pid1=$!
wait -f $pid1
$path/kill_sledge.sh
#test single 5k c5 60% max RPS
f1="5k_single_60.txt"
server_log_file="execution_single_5k_60.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_rps.sh $f1 120 60 5k.jpg 10000 2>&1 &
pid1=$!
wait -f $pid1
$path/kill_sledge.sh

@ -0,0 +1,88 @@
{
"active": true,
"name": "resize1",
"path": "resize_wasm.so",
"port": 10000,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 0,
"next_modules": ["png2bmp1", "lpd_wasm1"],
"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": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["cifar10_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": "lpd_wasm1",
"path": "lpd_wasm.so",
"port": 10002,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 2,
"pre_module_count": 1,
"next_modules": ["work1"],
"http-req-headers": [],
"http-req-content-type": "image/bmp",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 4096000,
"http-resp-content-type": "text/plain",
"tail-module": true
},
{
"active": true,
"name": "cifar10_1",
"path": "cifar10_wasm.so",
"port": 10003,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["work1"],
"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": "work1",
"path": "work3_wasm.so",
"port": 10004,
"relative-deadline-us": 16346,
"argsize": 1,
"priority": 1,
"pre_module_count": 2,
"next_modules": [],
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 4096000,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain",
"tail-module": true
},

@ -14,6 +14,8 @@ rps=$3
image=$4
port=$5
#hey -disable-compression -disable-keepalive -disable-redirects -c 1 -q $rps -z $duration\s -cpus 1 -t 0 -m GET -D "$image" "http://10.10.1.1:$port"
hey -disable-compression -disable-keepalive -disable-redirects -c 8 -q 50 -z $duration\s -t 0 -m GET -D "$image" "http://10.10.1.1:$port" > $output
echo "hey test"
hey -disable-compression -disable-keepalive -disable-redirects -c 5 -q $rps -z $duration\s -t 0 -m GET -D "$image" "http://10.16.109.192:$port" > $output
#loadtest -c 5 --rps $rps -t $duration --method GET --data @$image "http://10.16.109.192:$port" > $output
#hey -disable-compression -disable-keepalive -disable-redirects -c 8 -q 50 -z $duration\s -t 0 -m GET -D "$image" "http://10.10.1.1:$port" > $output

@ -0,0 +1,99 @@
#include "dag_data_split.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct DataNode {
uint32_t dataLength;
char *data;
struct DataNode *next;
};
DataNode* splitData(char *buffer, uint32_t bufferSize) {
DataNode *head = NULL;
DataNode *tail = NULL;
uint32_t offset = 0;
while (offset < bufferSize) {
if (offset + 4 > bufferSize) {
break;
}
uint32_t dataLength = *(uint32_t *)(buffer + offset);
offset += 4;
if (offset + dataLength > bufferSize) {
break;
}
DataNode *newNode = (DataNode *)malloc(sizeof(DataNode));
if (newNode == NULL) {
perror("Memory allocation failed");
freeDataNodes(head);
return NULL;
}
newNode->data = (char *)malloc(dataLength);
if (newNode->data == NULL) {
free(newNode);
perror("Memory allocation failed");
freeDataNodes(head);
return NULL;
}
memcpy(newNode->data, buffer + offset, dataLength);
newNode->dataLength = dataLength;
newNode->next = NULL;
if (head == NULL) {
head = newNode;
} else {
tail->next = newNode;
}
tail = newNode;
offset += dataLength;
}
return head;
}
void freeDataNodes(DataNode *head) {
while (head != NULL) {
DataNode *next = head->next;
free(head->data);
free(head);
head = next;
}
}
void printDataList(DataNode *head) {
int index = 0;
DataNode *current = head;
while (current != NULL) {
printf("Data %d: Length = %u\n", index, current->dataLength);
index++;
current = current->next;
}
}
int getDataNodeCount(DataNode *head) {
int count = 0;
DataNode *current = head;
while (current != NULL) {
count++;
current = current->next;
}
return count;
}
const char* getDataNodeByIndex(DataNode *head, int index) {
int count = 1;
DataNode *current = head;
while (current != NULL) {
if (count == index) {
return current->data;
}
count++;
current = current->next;
}
return NULL;
}

@ -0,0 +1,17 @@
#pragma once
#include <stdint.h>
typedef struct DataNode DataNode;
DataNode* splitData(char *buffer, uint32_t bufferSize);
void freeDataNodes(DataNode *head);
void printDataList(DataNode *head);
int getDataNodeCount(DataNode *head);
/**
* @param index is form 1 to n
*/
const char* getDataNodeByIndex(DataNode *head, int index);

@ -0,0 +1,48 @@
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include "dag_data_split.h"
#define MAX_BUF (1024 * 1024 * 1) // 1m
int main() {
char *d = malloc(MAX_BUF + 1);
ssize_t bytes_read = read(0, d, MAX_BUF);
if (bytes_read < 0) {
perror("Error reading input");
return 1;
}
DataNode *dataList = splitData(d, bytes_read);
if (dataList == NULL) {
fprintf(stderr, "Failed to split data.\n");
return 1;
}
const char *firstdata = getDataNodeByIndex(dataList, 1); // Assume this is text data
const char *seconddata = getDataNodeByIndex(dataList, 2); // Assume this is image data
if (firstdata == NULL || seconddata == NULL) {
fprintf(stderr, "Not enough data.\n");
freeDataNodes(dataList);
return 1;
}
// Prepare output string for the text data
// char output[1024];
// int len = snprintf(output, sizeof(output), "First data: %s\n", firstdata);
printf("the fistdata %s", firstdata);
// Output the text data
free(d);
// Assuming seconddata contains image data in raw binary form.
// Directly write image data to stdout.
// write(1, seconddata, strlen(seconddata));
freeDataNodes(dataList);
return 0;
}

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