Compare commits

..

8 Commits
main ... tree

@ -25,5 +25,5 @@
"workspaceMount": "source=${localWorkspaceFolder},target=/sledge,type=bind,consistency=cached",
"workspaceFolder": "/sledge",
"postCreateCommand": "make -C /sledge install && make -B -C /sledge/runtime/tests clean all",
"containerUser": "dev",
"containerUser": "dev"
}

@ -1,3 +1,2 @@
LD_LIBRARY_PATH=/home/hai/sledge-serverless-framework/runtime/bin
SLEDGE_SCHEDULER=EDF
SLEDGE_SANDBOX_PERF_LOG=/home/hai/sledge-serverless-framework/debuglog.txt

2
.gitignore vendored

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

129
.vscode/launch.json vendored

@ -1,52 +1,85 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Hyde",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/runtime/bin/sledgert",
"args": [
"${workspaceFolder}/runtime/experiments/applications/ocr/hyde/spec.json"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"envFile": "${workspaceFolder}/.env",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Hyde",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/runtime/bin/sledgert",
"args": [
"${workspaceFolder}/runtime/experiments/applications/ocr/hyde/spec.json"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "SLEDGE_SANDBOX_PERF_LOG",
"value": "${workspaceFolder}/debug.log"
}
],
"externalConsole": false,
"MIMode": "gdb",
"envFile": "${workspaceFolder}/.env",
"sourceFileMap": {
"/sledge/runtime": "${workspaceFolder}/runtime"
},
{
"name": "Preemption",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/runtime/bin/sledgert",
"args": [
"${workspaceFolder}/runtime/experiments/preemption/spec.json"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"envFile": "${workspaceFolder}/.env",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "Preemption",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/runtime/bin/sledgert",
"args": [
"${workspaceFolder}/runtime/tests/test_multiple_image_processing4.json"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"sourceFileMap": {
"/sledge/runtime": "${workspaceFolder}/runtime"
},
"envFile": "${workspaceFolder}/.env",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "tree",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/runtime/bin/sledgert",
"args": [
"${workspaceFolder}/runtime/tests/tree.json"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"sourceFileMap": {
"/sledge/runtime": "${workspaceFolder}/runtime"
},
"envFile": "${workspaceFolder}/.env",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

@ -95,7 +95,11 @@
"compare": "c",
"cstdint": "c",
"format": "c",
"jsmn.h": "c"
"jsmn.h": "c",
"priority_queue.h": "c",
"hash.h": "c",
"lock.h": "c",
"span": "cpp"
},
"files.exclude": {
"**/.git": true,

@ -0,0 +1,88 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TABLE_SIZE 100
typedef struct Node {
int key;
char value[256];
struct Node* next;
} Node;
typedef struct Edge {
Node* from;
Node* to;
double cost;
struct Edge* next;
} Edge;
typedef struct Graph {
Node* nodes[TABLE_SIZE];
Edge* edges[TABLE_SIZE];
} Graph;
unsigned int hash(int key) {
return key % TABLE_SIZE;
}
void insertNode(Graph* g, int key, const char* value) {
unsigned int index = hash(key);
Node* new_node = (Node*) malloc(sizeof(Node));
if (new_node) {
new_node->key = key;
strcpy(new_node->value, value);
new_node->next = g->nodes[index];
g->nodes[index] = new_node;
}
}
Node* findNode(Graph* g, int key) {
unsigned int index = hash(key);
Node* node = g->nodes[index];
while (node) {
if (node->key == key)
return node;
node = node->next;
}
return NULL;
}
void insertEdge(Graph* g, int fromKey, int toKey, double cost) {
Node* fromNode = findNode(g, fromKey);
Node* toNode = findNode(g, toKey);
if (fromNode && toNode) {
unsigned int index = hash(fromKey);
Edge* new_edge = (Edge*) malloc(sizeof(Edge));
if (new_edge) {
new_edge->from = fromNode;
new_edge->to = toNode;
new_edge->cost = cost;
new_edge->next = g->edges[index];
g->edges[index] = new_edge;
}
}
}
void initGraph(Graph* g) {
for (int i = 0; i < TABLE_SIZE; i++) {
g->nodes[i] = NULL;
g->edges[i] = NULL;
}
}
int main() {
Graph g;
initGraph(&g);
insertNode(&g, 1, "Node 1");
insertNode(&g, 2, "Node 2");
insertEdge(&g, 1, 2, 0.5);
Node* n = findNode(&g, 1);
if (n) {
printf("Found node: %s\n", n->value);
}
return 0;
}

@ -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
@ -59,7 +59,7 @@ CFLAGS += -DLOG_TO_FILE
# CFLAGS += -DLOG_PREEMPTION
# CFLAGS += -DLOG_MODULE_LOADING
# CFLAGS += -DOPT_AVOID_GLOBAL_QUEUE
# CFLAGS += -DLOG_RUNTIME_FILE_LOG
CFLAGS += -DLOG_RUNTIME_FILE_LOG
CFLAGS += -DLOG_RUNTIME_MEM_LOG
# This dumps per module *.csv files containing the cycle a sandbox has been in RUNNING when each

@ -0,0 +1,53 @@
import unittest,importlib,BeautifulReport
import cffi
def load():
with open("/home/hai/sledge-serverless-framework/runtime/include/hash.h", "r") as f:
inc = ""
for line in f:
if not line.strip().startswith('#'):
inc += line
src = open("/home/hai/sledge-serverless-framework/runtime/Utest_py/hash.c").read()
builder = cffi.FFI()
builder.cdef(inc)
builder.set_source("hashlib",src)
builder.compile()
md = importlib.import_module("hashlib")
return md.lib
md = load()
class HashTableTestCase(unittest.TestCase):
def test_case1(self):
'''
测试添加和查找功能
'''
table = md.create_table()
md.add_item(table, b"key1", "Hello World")
value = md.find_value(table, b"key1")
self.assertEqual(value, "Hello World")
print('Value for "key1":', value)
def test_case2(self):
'''
测试查找不存在的键
'''
table = md.create_table()
value = md.find_value(table, b"nonexistent")
self.assertIsNone(value)
print('Value for "nonexistent":', value)
def test_case3(self):
# 确保每个测试后表被释放
md.free_table(self.table)
sut = unittest.TestSuite()
sut.addTest(unittest.makeSuite(HashTableTestCase))
run = BeautifulReport.BeautifulReport(sut)
run.report(filename="test.html",description="单元测试")

Binary file not shown.

@ -0,0 +1,49 @@
// hash_test.c
#include "../include/hash.h"
#include <stdio.h>
typedef struct test
{
char *name;
}test;
int main(int argc, char *argv[]) {
test *test1 = malloc(sizeof(test));
test *test2 = malloc(sizeof(test));
test1->name = "test1";
test2->name = "test2";
HashTable *myTable = create_table();
add_item(myTable, "key1", test1);
add_item(myTable, "key2", test2);
char *input = argv[1];
test *value = find_value(myTable, input);
if (value) {
printf("Test Passed: %s\n", value->name);
} else {
printf("Test Failed: Key not found.\n");
}
remove_item(myTable, "key1");
printf("remove key1.\n");
test *value2 = find_value(myTable, input);
if (value2) {
printf("Test Passed: %s\n", value2->name);
} else {
printf("Test Failed: Key not found.\n");
}
add_item(myTable, "key1", test1);
test *value4 = find_value(myTable, "key1");
if (value4) {
printf("Test Passed: %s\n", value4->name);
} else {
printf("Test Failed: Key not found.\n");
}
test *value3 = find_value(myTable, "key2");
if (value3) {
printf("Test Passed: %s\n", value3->name);
} else {
printf("Test Failed: Key not found.\n");
}
free(test1);
free(test2);
free_table(myTable);
return 0;
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,144 @@
#ifndef HASH_H
#define HASH_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <pthread.h>
#define TABLE_SIZE 32 // the size of hash table
#define MAX_KEY_LENGTH 32 // the maximum length of key
typedef struct {
char key[MAX_KEY_LENGTH];
void *value;
int is_deleted; // Flag to mark items as deleted
} HashItem;
typedef struct {
HashItem **items;
pthread_mutex_t lock;
} HashTable;
static inline unsigned long
hash_function(const char *str) {
unsigned long i = 0;
for (int j = 0; str[j]; j++)
i += str[j];
return i % TABLE_SIZE;
}
static inline HashTable
*create_table() {
HashTable *table = (HashTable *)malloc(sizeof(HashTable));
if (!table) {
fprintf(stderr, "Failed to allocate memory for hash table struct.\n");
return NULL;
}
table->items = (HashItem **)malloc(sizeof(HashItem*) * TABLE_SIZE);
if (!table->items) {
fprintf(stderr, "Failed to allocate memory for items.\n");
free(table); // Free the table if item allocation fails
return NULL;
}
pthread_mutex_init(&table->lock, NULL);
for (int i = 0; i < TABLE_SIZE; i++) {
table->items[i] = NULL;
}
return table;
}
static inline void
add_item(HashTable *table, const char *key, void *value) {
assert(table != NULL);
assert(key != NULL);
assert(value != NULL);
pthread_mutex_lock(&table->lock);
unsigned long index = hash_function(key);
HashItem *item = malloc(sizeof(HashItem));
if (!item) {
fprintf(stderr, "Failed to allocate memory for a new item.\n");
pthread_mutex_unlock(&table->lock);
return;
}
strcpy(item->key, key);
item->value = value;
item->is_deleted = 0;
while (table->items[index] != NULL && !table->items[index]->is_deleted && strcmp(table->items[index]->key, key) != 0) {
index = (index + 1) % TABLE_SIZE;
}
free(table->items[index]); // Free the existing item if overwriting
table->items[index] = item;
pthread_mutex_unlock(&table->lock);
}
static inline void
remove_item(HashTable *table, const char *key) {
assert(table != NULL);
assert(key != NULL);
pthread_mutex_lock(&table->lock);
unsigned long index = hash_function(key);
while (table->items[index] != NULL && strcmp(table->items[index]->key, key) != 0) {
index = (index + 1) % TABLE_SIZE;
}
if (table->items[index] != NULL) {
table->items[index]->is_deleted = 1; // Mark as deleted
}
pthread_mutex_unlock(&table->lock);
}
static inline void
*find_value(HashTable *table, const char *key) {
assert(table != NULL);
assert(key != NULL);
pthread_mutex_lock(&table->lock);
unsigned long index = hash_function(key);
int count = 0;
while (table->items[index] != NULL && count < TABLE_SIZE && (table->items[index]->is_deleted || strcmp(table->items[index]->key, key) != 0)) {
index = (index + 1) % TABLE_SIZE;
count++;
}
if (table->items[index] == NULL || table->items[index]->is_deleted)
{
pthread_mutex_unlock(&table->lock);
return NULL;
}
else {
pthread_mutex_unlock(&table->lock);
return table->items[index]->value;
}
}
static inline void
free_table(HashTable *table) {
assert(table != NULL);
pthread_mutex_lock(&table->lock);
for (int i = 0; i < TABLE_SIZE; i++) {
if (table->items[i] != NULL) {
free(table->items[i]); // Free each item
}
}
free(table->items);
free(table);
pthread_mutex_unlock(&table->lock);
pthread_mutex_destroy(&table->lock);
}
#endif

@ -20,6 +20,7 @@
#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
@ -78,7 +79,15 @@ struct module {
/* Entry Function to invoke serverless function */
mod_main_fn_t main;
struct module *next_module; /* the next module in the chain */
//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;
struct module *parent_module;
/* parent module or not?*/
bool is_sandboxcreate;
};
/*************************

@ -225,7 +225,8 @@ 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->next_module == NULL) {
if(sandbox->module->parent_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)

@ -6,6 +6,7 @@
#include <stdint.h>
#include <sys/socket.h>
#include "debuglog.h"
#include "deque.h"
#include "http_total.h"
@ -26,6 +27,7 @@ struct sandbox_request {
uint64_t last_update_timestamp; /* cycles */
uint64_t remaining_slack; /* cycles */
char * previous_function_output;
char * previous_function_output2;
ssize_t output_length;
ssize_t previous_request_length;
/*
@ -74,7 +76,7 @@ static inline struct sandbox_request *
sandbox_request_allocate(struct module *module, bool request_from_outside, ssize_t request_length,
char *arguments, int socket_descriptor, const struct sockaddr *socket_address,
uint64_t request_arrival_timestamp, uint64_t enqueue_timestamp, uint64_t remaining_slack,
uint64_t admissions_estimate, char *previous_function_output, ssize_t output_length)
uint64_t admissions_estimate, char *previous_function_output, char * previous_function_output2, ssize_t output_length)
{
struct sandbox_request *sandbox_request = (struct sandbox_request *)malloc(sizeof(struct sandbox_request));
assert(sandbox_request);
@ -91,6 +93,7 @@ sandbox_request_allocate(struct module *module, bool request_from_outside, ssize
sandbox_request->enqueue_timestamp = enqueue_timestamp;
sandbox_request->absolute_deadline = request_arrival_timestamp + module->relative_deadline;
sandbox_request->previous_function_output = previous_function_output;
sandbox_request->previous_function_output2 = previous_function_output2;
sandbox_request->output_length = output_length;
sandbox_request->previous_request_length = request_length;
sandbox_request->last_update_timestamp = enqueue_timestamp;

@ -33,6 +33,7 @@ struct sandbox {
uint64_t id;
bool request_from_outside;
char * previous_function_output; /* the output of the previous function */
char * previous_function_output2;
ssize_t output_length; /* the length of previous_function_output */
ssize_t previous_request_length; /* the length of previous request */
sandbox_state_t state;

@ -8,8 +8,10 @@
#include "scheduler.h"
#include "module.h"
#include "software_interrupt.h"
#include "hash.h"
extern uint64_t system_start_timestamp;
#define OUPUT_MAX 20;
__thread struct sandbox *worker_thread_current_sandbox = NULL;
@ -70,7 +72,11 @@ current_sandbox_start(void)
char *error_message = "";
sandbox_initialize_stdio(sandbox);
struct module * next_module = sandbox->module->next_module;
//struct module * next_module = sandbox->module->next_module;
struct module * next_module = sandbox->module->parent_module;
static HashTable *sandboxes_request_table = NULL;
if (sandboxes_request_table == NULL) sandboxes_request_table = create_table();
/*
* Add the client fd to epoll if it is the first or last sandbox in the chain because they
@ -120,27 +126,69 @@ current_sandbox_start(void)
} else if (next_module != NULL) {
/* Generate a new request, copy the current sandbox's output to the next request's buffer, and put it to the global queue */
ssize_t output_length = sandbox->request_response_data_length - sandbox->request_length;
char * pre_func_output = (char *)malloc(output_length);
if (!pre_func_output) {
char * pre_func_output = NULL;
char * pre_func_output2 = NULL;
if (strcmp(next_module->left_module->name, sandbox->module->name) == 0)
{
pre_func_output = (char *)malloc(output_length);
if (!pre_func_output) {
fprintf(stderr, "Failed to allocate memory for the previous output: %s\n", strerror(errno));
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);
}else
{
pre_func_output2 = (char *)malloc(output_length);
if (!pre_func_output2) {
fprintf(stderr, "Failed to allocate memory for the previous output: %s\n", strerror(errno));
goto err;
};
memcpy(pre_func_output2, 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);
struct sandbox_request *sandbox_request =
sandbox_request_allocate(next_module, false, sandbox->request_length,
next_module->name, sandbox->client_socket_descriptor,
(const struct sockaddr *)&sandbox->client_address,
sandbox->request_arrival_timestamp, enqueue_timestamp,
sandbox->remaining_slack, true, pre_func_output, output_length);
/* TODO: All sandboxs in the chain share the same request id, but sandbox_request_allocate()
* will busy-wait to generate an unique id, should we optimize it here?
*/
sandbox_request->id = sandbox->id;
struct sandbox_request *sandbox_request = NULL;
static bool left_output_flag = false;
if (next_module->is_sandboxcreate == false)
{
sandbox_request =
sandbox_request_allocate(next_module, false, sandbox->request_length,
next_module->name, sandbox->client_socket_descriptor,
(const struct sockaddr *)&sandbox->client_address,
sandbox->request_arrival_timestamp, enqueue_timestamp,
sandbox->remaining_slack, true, pre_func_output, pre_func_output2, output_length);
sandbox_request->id = sandbox->id;
add_item(sandboxes_request_table, next_module->name, sandbox_request);
if (pre_func_output != NULL) left_output_flag = true;
else left_output_flag = false;
/*change the flag*/
next_module->is_sandboxcreate = true;
}else
{
sandbox_request = find_value(sandboxes_request_table, next_module->name);
assert(sandbox_request);
if (left_output_flag == true)
{
sandbox_request->previous_function_output2 = pre_func_output2;
}else
{
sandbox_request->previous_function_output = pre_func_output;
}
ssize_t combined_length = sandbox_request->output_length + output_length + 3;
remove_item(sandboxes_request_table, next_module->name);
char *combined_output = (char *)malloc(combined_length);
if (!combined_output) {
fprintf(stderr, "Failed to allocate memory for the combined output: %s\n", strerror(errno));
goto err;
}
strcpy(combined_output, sandbox_request->previous_function_output);
strcat(combined_output, "+");
strcat(combined_output, sandbox_request->previous_function_output2);
sandbox->output_length = combined_length;
#ifdef OPT_AVOID_GLOBAL_QUEUE
/* TODO: The running time of the current sandbox contains the next sandbox's initialization time, does it matter? */
if (sandbox->absolute_deadline == sandbox_request->absolute_deadline) {
@ -160,12 +208,19 @@ current_sandbox_start(void)
#else
/* Add to the Global Sandbox Request Scheduler */
global_request_scheduler_add(sandbox_request);
if (sandbox_send_response(sandbox) < 0) {
error_message = "Unable to build and send client response\n";
goto err;
};
next_module->is_sandboxcreate = false;
}
#endif
/* Remove the client fd from epoll if it is the first sandbox in the chain */
if (sandbox->request_from_outside) {
sandbox_remove_from_epoll(sandbox);
}
sandbox_set_as_returned(sandbox, SANDBOX_RUNNING);
} else {
/* Retrieve the result, construct the HTTP response, and send to client */
if (sandbox_send_response(sandbox) < 0) {

@ -180,7 +180,8 @@ listener_thread_main(void *dummy)
struct module * next_module = module;
while(next_module) {
estimated_execution_time += admission_info_get_percentile(&next_module->admissions_info);
next_module = next_module->next_module;
//next_module = next_module->next_module;
next_module = next_module->left_module;
}
/* Adding system start timestamp to avoid negative remaining slack in the following update. They are all cycles */
@ -191,7 +192,7 @@ listener_thread_main(void *dummy)
sandbox_request_allocate(module, true, 0, module->name, client_socket,
(const struct sockaddr *)&client_address,
request_arrival_timestamp, request_arrival_timestamp,remaining_slack,
work_admitted, NULL, 0);
work_admitted, NULL, NULL, 0);
/* Add to the Global Sandbox Request Scheduler */
global_request_scheduler_add(sandbox_request);

@ -19,7 +19,8 @@
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 *
************************/
@ -374,7 +375,29 @@ module_new_from_json(char *file_name)
int module_count = 0;
char *request_headers = NULL;
char *reponse_headers = NULL;
struct module *tail_module = 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");
}
for (int i = 0; i < total_tokens; i++) {
assert(tokens[i].type == JSMN_OBJECT);
@ -454,7 +477,18 @@ 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, "tail-module") == 0) {
}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) {
assert(tokens[i + j + 1].type == JSMN_PRIMITIVE);
if (val[0] == 't') {
is_tail_module = true;
@ -463,7 +497,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",
@ -568,18 +602,22 @@ module_new_from_json(char *file_name)
if (module == NULL) goto module_new_err;
assert(module);
// if (tail_module != NULL) { tail_module->next_module = module; }
// tail_module = module;
// tail_module->next_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;
}
// /* 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);
module->left_module = NULL;
module->right_module = NULL;
module->parent_module = NULL;
module->is_sandboxcreate = false;
nodes[module_count] = module;
module_count++;
}
@ -588,6 +626,24 @@ 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)
{
assert(nodes[left_index]);
nodes[i]->left_module = nodes[left_index];
nodes[left_index]->parent_module = nodes[i];
}
if (right_index < module_count)
{
assert(nodes[right_index]);
nodes[i]->right_module = nodes[right_index];
nodes[right_index]->parent_module = nodes[i];
}
}
free(nodes);
#ifdef LOG_MODULE_LOADING
debuglog("Loaded %d module%s!\n", module_count, module_count > 1 ? "s" : "");
#endif

@ -1,19 +1,17 @@
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=noop
TESTS=fibonacci big_fibonacci C-Image-Manip empty work work1k work10k work100k work1m forever filesys sockserver sockclient empty tree
TESTSRT=$(TESTS:%=%_rt)
TESTSRT2=$(TESTS2:%=%_rt)
.PHONY: all clean rttests tinyekf cifar10 gocr sod add
.PHONY: all clean rttests tinyekf cifar10 gocr sod
all: rttests tinyekf cifar10 gocr sod
@echo "Test Compilation done!"
rttests: $(TESTSRT)
add: $(TESTSRT2)
clean:
@echo "Cleaning Test Applications"

@ -1,22 +0,0 @@
import os
def calculate_average(filename):
with open(filename, "r") as file:
values = file.readlines()
values = [int(value.strip()) for value in values]
average = sum(values) / len(values) if values else 0
return average
def main():
noop_functions = ["noop1", "noop2", "noop3", "noop4", "noop5"]
for noop in noop_functions:
filename = f"{noop}.txt"
if os.path.exists(filename):
average = calculate_average(filename)
print(f"Average for {filename}: {average}")
else:
print(f"{filename} does not exist.")
if __name__ == "__main__":
main()

@ -1,26 +0,0 @@
import sys
def process_file(input_file, noop_functions):
data = {noop: [] for noop in noop_functions}
with open(input_file, "r") as infile:
for line in infile:
for noop in noop_functions:
if noop in line:
value = line.split(",")[6]
data[noop].append(value)
for noop, values in data.items():
with open(f"{noop}.txt", "w") as outfile:
outfile.write("\n".join(values))
if __name__ == "__main__":
noop_functions = ["noop1", "noop2", "noop3", "noop4", "noop5"]
argv = sys.argv[1:]
if len(argv) < 1:
print("usage:", sys.argv[0], "file_dir percentage")
sys.exit()
input_file = argv[0]
process_file(input_file, noop_functions)

@ -16,20 +16,17 @@ server_log="noop_"$chain_len".log"
log="noop"$chain_len"-"$repeat_t".txt"
start_script="start-noop"$chain_len".sh"
echo $start_script
path="/home/weihao/sledge/sledge_tree/runtime/tests"
path="/users/xiaosuGW/sledge-serverless-framework/runtime/tests"
chmod 400 $path/id_rsa
ssh -o stricthostkeychecking=no -i $path/id_rsa xiaosuGW@10.10.1.1 "$path/$start_script $server_log >/dev/null 2>&1 &"
$path/$start_script $server_log >/dev/null 2>&1 &
echo "hey test"
hey -c 1 -z 60s -disable-keepalive -m GET "http://127.0.0.1:10000" > $log 2>&1 &
hey -c 1 -z 60s -disable-keepalive -m GET -d 29 "http://10.10.1.1:10000" > $log 2>&1 &
pid1=$!
wait -f $pid1
printf "[OK]\n"
$path/kill_sledge.sh
ssh -o stricthostkeychecking=no -i $path/id_rsa xiaosuGW@10.10.1.1 "$path/kill_sledge.sh"

@ -1,8 +0,0 @@
## 本地回环 E2E时间测试 三轮测试平均
| 函数个数 | noop1 | noop3 | noop5 |
| ------------------------------ | ------------- | ------------- | ------------- |
| 三轮测试数据?E2E时间ms | 0.4、0.4、0.4 | 0.5、0.5、05. | 0.7、0.7、0.7 |
| 平均E2E时间(ms) | 0.4 | 0.5 | 0.7 |
| 三轮测试数据?初始化时间us | 9 | 115 | 220 |
| 平均初始化时间us | 8.9、8.8、9.1 | 115、115、114 | 223、217、221 |

Binary file not shown.

@ -94,85 +94,85 @@ fib(unsigned long int n)
//return 0;
//}
main(int argc, char **argv)
int main(int argc, char **argv)
{
unsigned long n = 0, r;
scanf("%lu", &n);
FILE *f = stdout;
//FILE *f = stdout;
// unsigned long long st = get_time(), en;
//r = fib(29);
r = fib(n);
// en = get_time();
switch(n) {
case 0: {
char array[4 * 1024] = {0};
memset(array, 'a', 4 * 1024);
array[4 * 1024 - 1] = 0;
//printf("%s\n", array);
fwrite(array, 1, 4 * 1024 - 1, f);
break;
}
case 1: {
char array[100 * 1024] = {'b'};
memset(array, 'b', 100 * 1024);
array[100 * 1024 - 1] = 0;
//printf("%s\n", array);
fwrite(array, 1, 100 * 1024 - 1, f);
break;
}
case 2: {
char array[200 * 1024] = {'c'};
memset(array, 'c', 200 * 1024);
array[200 * 1024 - 1] = 0;
fwrite(array, 1, 200 * 1024 - 1, f);
//printf("%s\n", array);
break;
}
case 4: {
char array[400 * 1024] = {'d'};
memset(array, 'd', 400 * 1024);
array[400 * 1024 - 1] = 0;
fwrite(array, 1, 400 * 1024 - 1, f);
//printf("%s\n", array);
break;
}
case 6: {
char array[600 * 1024] = {'e'};
memset(array, 'e', 600 * 1024);
array[600 * 1024 - 1] = 0;
fwrite(array, 1, 600 * 1024 - 1, f);
//printf("%s\n", array);
break;
}
case 8: {
char array[800 * 1024] = {'f'};
memset(array, 'f', 800 * 1024);
array[800 * 1024 - 1] = 0;
fwrite(array, 1, 800 * 1024 - 1, f);
//printf("%s\n", array);
break;
}
case 10:{
char array[1000 * 1024] = {'g'};
memset(array, 'g', 1000 * 1024);
array[1000 * 1024 - 1] = 0;
fwrite(array, 1, 1000 * 1024 - 1, f);
//printf("%s\n", array);
break;
}
default: printf("error input of n\n");
}
fclose(f);
// switch(n) {
// case 0: {
// char array[4 * 1024] = {0};
// memset(array, 'a', 4 * 1024);
// array[4 * 1024 - 1] = 0;
// //printf("%s\n", array);
// fwrite(array, 1, 4 * 1024 - 1, f);
// break;
// }
// case 1: {
// char array[100 * 1024] = {'b'};
// memset(array, 'b', 100 * 1024);
// array[100 * 1024 - 1] = 0;
// //printf("%s\n", array);
// fwrite(array, 1, 100 * 1024 - 1, f);
// break;
// }
// case 2: {
// char array[200 * 1024] = {'c'};
// memset(array, 'c', 200 * 1024);
// array[200 * 1024 - 1] = 0;
// fwrite(array, 1, 200 * 1024 - 1, f);
// //printf("%s\n", array);
// break;
// }
// case 4: {
// char array[400 * 1024] = {'d'};
// memset(array, 'd', 400 * 1024);
// array[400 * 1024 - 1] = 0;
// fwrite(array, 1, 400 * 1024 - 1, f);
// //printf("%s\n", array);
// break;
// }
// case 6: {
// char array[600 * 1024] = {'e'};
// memset(array, 'e', 600 * 1024);
// array[600 * 1024 - 1] = 0;
// fwrite(array, 1, 600 * 1024 - 1, f);
// //printf("%s\n", array);
// break;
// }
// case 8: {
// char array[800 * 1024] = {'f'};
// memset(array, 'f', 800 * 1024);
// array[800 * 1024 - 1] = 0;
// fwrite(array, 1, 800 * 1024 - 1, f);
// //printf("%s\n", array);
// break;
// }
// case 10:{
// char array[1000 * 1024] = {'g'};
// memset(array, 'g', 1000 * 1024);
// array[1000 * 1024 - 1] = 0;
// fwrite(array, 1, 1000 * 1024 - 1, f);
// //printf("%s\n", array);
// break;
// }
// default: printf("error input of n\n");
// }
//fclose(f);
//printf("%lu\n", n);
//printf("%lu\n", r);
printf("%lu\n", r);
return 0;
}

@ -2,5 +2,5 @@
pid=`ps -ef|grep "sledgert"|grep -v grep |awk '{print $2}'`
echo $pid
kill -2 $pid
sudo kill -2 $pid

@ -1,14 +0,0 @@
#include <stdio.h>
// 定义一个完全无操作的noop函数
void noop() {
// 此函数完全不执行任何操作
}
int main() {
// 仅调用noop函数
noop();
// main函数也不进行任何输出
return 0;
}

@ -36,7 +36,7 @@ def get_values(key, value, miss_deadline_rate, total_latency, running_times, pre
before_dot = file_name.split(".")[0]
joint_f_name = before_dot + "_total_time.txt"
cmd='python3 /home/weihao/sledge/sledge_tree/runtime/tests/meet_deadline_percentage.py %s 50' % file_name
cmd='python3 ~/sledge-serverless-framework/runtime/tests/meet_deadline_percentage.py %s 50' % file_name
rt=os.popen(cmd).read().strip()
cmd2='mv total_time.txt %s' % joint_f_name
os.popen(cmd2)

File diff suppressed because one or more lines are too long

@ -73,7 +73,7 @@
"\n",
"colors=list(mcolors.TABLEAU_COLORS.keys()) \n",
"\n",
"with open('G:\\\\test_data\\\\'rate.txt, 'r') as f:\n",
"with open('G:\\\\test_data\\\\rate.txt', 'r') as f:\n",
" min_seg = 512\n",
" for line in f.readlines():\n",
" line = line.strip()\n",
@ -2703,7 +2703,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.6.4"
}
},
"nbformat": 4,

@ -1 +1 @@
sudo chsh -s /bin/bash hai
sudo chsh -s /bin/bash xiaosuGW

@ -1,32 +0,0 @@
#!/bin/bash
function usage {
echo "$0 [perf output file, chain_function_perf.log or single_function_perf.log or opt_function_perf.log]"
exit 1
}
if [ $# != 1 ] ; then
usage
exit 1;
fi
output=$1
declare project_path="$(
cd "$(dirname "$0")/../.."
pwd
)"
echo $project_path
path=`pwd`
#export SLEDGE_DISABLE_PREEMPTION=true
export SLEDGE_CPU_SPEED=2500
export SLEDGE_SCHEDULER=FIFO
#export SLEDGE_SIGALRM_HANDLER=BROADCAST
#export SLEDGE_SIGALRM_HANDLER=TRIAGED
export SLEDGE_NWORKERS=16
#export SLEDGE_SCHEDULER=EDF
export SLEDGE_SANDBOX_PERF_LOG=$path/$output
echo $SLEDGE_SANDBOX_PERF_LOG
cd $project_path/runtime/bin
LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_noop1.json

@ -1,32 +0,0 @@
#!/bin/bash
function usage {
echo "$0 [perf output file, chain_function_perf.log or single_function_perf.log or opt_function_perf.log]"
exit 1
}
if [ $# != 1 ] ; then
usage
exit 1;
fi
output=$1
declare project_path="$(
cd "$(dirname "$0")/../.."
pwd
)"
echo $project_path
path=`pwd`
#export SLEDGE_DISABLE_PREEMPTION=true
export SLEDGE_CPU_SPEED=2500
export SLEDGE_SCHEDULER=FIFO
#export SLEDGE_SIGALRM_HANDLER=BROADCAST
#export SLEDGE_SIGALRM_HANDLER=TRIAGED
export SLEDGE_NWORKERS=16
#export SLEDGE_SCHEDULER=EDF
export SLEDGE_SANDBOX_PERF_LOG=$path/$output
echo $SLEDGE_SANDBOX_PERF_LOG
cd $project_path/runtime/bin
LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_noop3.json

@ -1,32 +0,0 @@
#!/bin/bash
function usage {
echo "$0 [perf output file, chain_function_perf.log or single_function_perf.log or opt_function_perf.log]"
exit 1
}
if [ $# != 1 ] ; then
usage
exit 1;
fi
output=$1
declare project_path="$(
cd "$(dirname "$0")/../.."
pwd
)"
echo $project_path
path=`pwd`
#export SLEDGE_DISABLE_PREEMPTION=true
export SLEDGE_CPU_SPEED=2500
export SLEDGE_SCHEDULER=FIFO
#export SLEDGE_SIGALRM_HANDLER=BROADCAST
#export SLEDGE_SIGALRM_HANDLER=TRIAGED
export SLEDGE_NWORKERS=16
#export SLEDGE_SCHEDULER=EDF
export SLEDGE_SANDBOX_PERF_LOG=$path/$output
echo $SLEDGE_SANDBOX_PERF_LOG
cd $project_path/runtime/bin
LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_noop5.json

@ -20,11 +20,11 @@ declare project_path="$(
echo $project_path
path=`pwd`
#export SLEDGE_DISABLE_PREEMPTION=true
export SLEDGE_CPU_SPEED=2500
export SLEDGE_CPU_SPEED=2400
export SLEDGE_SCHEDULER=SRSF
#export SLEDGE_SIGALRM_HANDLER=BROADCAST
export SLEDGE_SIGALRM_HANDLER=TRIAGED
export SLEDGE_NWORKERS=32
export SLEDGE_SIGALRM_HANDLER=BROADCAST
#export SLEDGE_SIGALRM_HANDLER=TRIAGED
#export SLEDGE_NWORKERS=1
#export SLEDGE_SCHEDULER=EDF
export SLEDGE_SANDBOX_PERF_LOG=$path/$output
echo $SLEDGE_SANDBOX_PERF_LOG

@ -1,130 +0,0 @@
#!/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_8c.sh $f1 120 50 5k.jpg 10006 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 10006 2>&1 &
pid1=$!
wait -f $pid1
$path/kill_sledge.sh
#test single 5k c5 70% max RPS
f1="5k_single_70.txt"
server_log_file="execution_single_5k_70.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_rps.sh $f1 120 70 5k.jpg 10006 2>&1 &
pid1=$!
wait -f $pid1
$path/kill_sledge.sh
#test single 5k c5 80% max RPS
f1="5k_single_80.txt"
server_log_file="execution_single_5k_80.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_rps.sh $f1 120 80 5k.jpg 10006 2>&1 &
pid1=$!
wait -f $pid1
$path/kill_sledge.sh
#test single 5k c5 90% max RPS
f1="5k_single_90.txt"
server_log_file="execution_single_5k_90.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_rps.sh $f1 120 90 5k.jpg 10006 2>&1 &
pid1=$!
wait -f $pid1
$path/kill_sledge.sh
#test single 5k c5 99% max RPS
f1="5k_single_99.txt"
server_log_file="execution_single_5k_99.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_rps.sh $f1 120 100 5k.jpg 10006 2>&1 &
pid1=$!
wait -f $pid1
$path/kill_sledge.sh
#test single 105k c5 50% max RPS (135)
f1="105k_single_50.txt"
server_log_file="execution_single_105k_50.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_8c.sh $f1 120 13 5k.jpg 10000 2>&1 &
pid2=$!
wait -f $pid2
$path/kill_sledge.sh
#test single 105k c5 60% max RPS
f1="105k_single_60.txt"
server_log_file="execution_single_105k_60.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_8c.sh $f1 120 16 5k.jpg 10000 2>&1 &
pid2=$!
wait -f $pid2
$path/kill_sledge.sh
#test single 105k c5 70% max RPS
f1="105k_single_70.txt"
server_log_file="execution_single_105k_70.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_8c.sh $f1 120 19 5k.jpg 10000 2>&1 &
pid2=$!
wait -f $pid2
$path/kill_sledge.sh
#test single 105k c5 80% max RPS
f1="105k_single_80.txt"
server_log_file="execution_single_105k_80.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_8c.sh $f1 120 22 5k.jpg 10000 2>&1 &
pid2=$!
wait -f $pid2
$path/kill_sledge.sh
#test single 105k c5 90% max RPS
f1="105k_single_90.txt"
server_log_file="execution_single_105k_90.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_8c.sh $f1 120 25 5k.jpg 10000 2>&1 &
pid2=$!
wait -f $pid2
$path/kill_sledge.sh
#test single 105k c5 99% max RPS
f1="105k_single_99.txt"
server_log_file="execution_single_105k_99.log"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_8c.sh $f1 120 27 5k.jpg 10000 2>&1 &
pid2=$!
wait -f $pid2
$path/kill_sledge.sh

@ -15,9 +15,7 @@ concurrency=$3
image=$4
port=$5
echo "hey -disable-compression -disable-keepalive -disable-redirects -c 5 -q $concurrency -z $duration\s -t 0 -m GET -D "$image" "http://10.16.109.192:$port" > $output"
#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 $concurrency -z 20s -t 0 -m GET -D "$image" "http://10.10.1.1:$port"
hey -disable-compression -disable-keepalive -disable-redirects -c 5 -q $concurrency -z $duration\s -t 0 -m GET -D "$image" "http://10.16.109.192:$port" > $output
hey -disable-compression -disable-keepalive -disable-redirects -c $concurrency -z $duration\s -t 0 -m GET -D "$image" "http://10.10.1.1:$port" > $output

@ -3,8 +3,8 @@
"name": "fibonacci",
"path": "fibonacci_wasm.so",
"port": 10000,
"expected-execution-us": 600,
"relative-deadline-us": 2000,
"expected-execution-us": 5000,
"relative-deadline-us": 360000,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "text/plain",

@ -1,63 +0,0 @@
#!/bin/bash
function usage {
echo "$0 [aad step] [first_rps] [max_rps]"
exit 1
}
if [ $# != 3 ] ; then
usage
exit 1;
fi
step=$1
current_rps=$2
max_rps=$3
chmod 400 ./id_rsa
path="/home/weihao/sledge/sledge_tree/runtime/tests"
last_actual_rps=0
first_run=true
while [ $current_rps -le $max_rps ]
do
echo "Testing with RPS: $current_rps"
server_log_file="test_max_rps.log"
f1="105k_"$current_rps".txt"
f2="305k_"$current_rps".txt"
f3="5k_"$current_rps".txt"
f4="40k_"$current_rps".txt"
$path/start.sh $server_log_file >/dev/null 2>&1 &
echo "sledge is running"
./test_rps.sh $f1 30 $current_rps 5k.jpg 10000 2>&1 &
pid1=$!
wait -f $pid1
# read hey ouput max rps
actual_rps=$(grep "Requests/sec" "$f1" | awk '{print $2}')
# read loadtest max rps
# actual_rps=$(grep "Requests per second" "$f1" | awk '{print $4}')
echo "Actual RPS achieved: $actual_rps"
if [ "$first_run" = false ]; then
if (( $(echo "$actual_rps <= $last_actual_rps" | bc -l) )); then
echo "Actual RPS did not increase, stopping test."
break
fi
fi
last_actual_rps=$actual_rps
# ±ê¼ÇµÚÒ»´ÎÔËÐÐÒÑÍê³É
first_run=false
current_rps=$((current_rps + step))
$path/kill_sledge.sh
echo "sledge has been stopped"
done
echo "Max RPS testing completed."

@ -1,287 +1,27 @@
{
"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": "cifar10_1",
"path": "cifar10_wasm.so",
"port": 10000,
"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": "png2bmp1",
"path": "C-Image-Manip_wasm.so",
"name": "resize1",
"path": "resize_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": [],
@ -290,79 +30,17 @@
},
{
"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
"active": true,
"name": "resize2",
"path": "resize_wasm.so",
"port": 10002,
"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"
},

@ -1,15 +0,0 @@
{
"active": true,
"name": "noop1",
"path": "noop_wasm.so",
"port": 10000,
"relative-deadline-us": 0,
"argsize": 0,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 0,
"http-resp-headers": [],
"http-resp-size": 0,
"http-resp-content-type": "text/plain",
"tail-module": true
}

@ -1,43 +0,0 @@
{
"active": true,
"name": "noop1",
"path": "noop_wasm.so",
"port": 10000,
"relative-deadline-us": 0,
"argsize": 0,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 0,
"http-resp-headers": [],
"http-resp-size": 0,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "noop2",
"path": "noop_wasm.so",
"port": 10001,
"relative-deadline-us": 0,
"argsize": 0,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 0,
"http-resp-headers": [],
"http-resp-size": 0,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "noop3",
"path": "noop_wasm.so",
"port": 10002,
"relative-deadline-us": 0,
"argsize": 0,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 0,
"http-resp-headers": [],
"http-resp-size": 0,
"http-resp-content-type": "text/plain",
"tail-module": true
}

@ -1,71 +0,0 @@
{
"active": true,
"name": "noop1",
"path": "noop_wasm.so",
"port": 10000,
"relative-deadline-us": 0,
"argsize": 0,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 0,
"http-resp-headers": [],
"http-resp-size": 0,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "noop2",
"path": "noop_wasm.so",
"port": 10001,
"relative-deadline-us": 0,
"argsize": 0,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 0,
"http-resp-headers": [],
"http-resp-size": 0,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "noop3",
"path": "noop_wasm.so",
"port": 10002,
"relative-deadline-us": 0,
"argsize": 0,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 0,
"http-resp-headers": [],
"http-resp-size": 0,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "noop4",
"path": "noop_wasm.so",
"port": 10003,
"relative-deadline-us": 0,
"argsize": 0,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 0,
"http-resp-headers": [],
"http-resp-size": 0,
"http-resp-content-type": "text/plain",
},
{
"active": true,
"name": "noop5",
"path": "noop_wasm.so",
"port": 10004,
"relative-deadline-us": 0,
"argsize": 0,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 0,
"http-resp-headers": [],
"http-resp-size": 0,
"http-resp-content-type": "text/plain",
"tail-module": true
}

@ -14,9 +14,6 @@ rps=$3
image=$4
port=$5
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
#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

@ -0,0 +1,36 @@
127.0.0.1:10002${ "module" : "bitcount", "args" : [ "bitcount1" , "16777216" ] }
127.0.0.1:10002${ "module" : "bitcount", "args" : [ "bitcount2" , "16777216" ] }
;127.0.0.1:10004${ "module" : "basic_math", "args" : [ "basic_math1" ] }
;127.0.0.1:10004${ "module" : "basic_math", "args" : [ "basic_math2" ] }
;127.0.0.1:10006${ "module" : "binarytrees", "args" : [ "binarytrees1", "16" ] }
;127.0.0.1:10006${ "module" : "binarytrees", "args" : [ "binarytrees2", "16" ] }
;127.0.0.1:10008${ "module" : "crc", "args" : [ "crc1", "crc/large.pcm" ] }
;127.0.0.1:10008${ "module" : "crc", "args" : [ "crc2", "crc/large.pcm" ] }
;127.0.0.1:10010${ "module" : "dijkstra", "args" : [ "dijkstra1", "dijkstra/input.dat" ] }
;127.0.0.1:10010${ "module" : "dijkstra", "args" : [ "dijkstra2", "dijkstra/input.dat" ] }
;127.0.0.1:10012${ "module" : "forever", "args" : [ "forever01" ] }
;127.0.0.1:10012${ "module" : "forever", "args" : [ "forever02" ] }
;127.0.0.1:10014${ "module" : "fornever", "args" : [ "fornever01", "10" ] }
;127.0.0.1:10014${ "module" : "fornever", "args" : [ "fornever02", "20" ] }
;127.0.0.1:10014${ "module" : "fornever", "args" : [ "fornever03", "30" ] }
;127.0.0.1:10014${ "module" : "fornever", "args" : [ "fornever04", "40" ] }
;127.0.0.1:10016${ "module" : "fft", "args" : [ "fft1" , "8", "32768" ] }
;127.0.0.1:10016${ "module" : "fft", "args" : [ "fft2" , "8", "32768" ] }
;127.0.0.1:10018${ "module" : "function_pointers", "args" : [ "function_pointers1" ] }
;127.0.0.1:10018${ "module" : "function_pointers", "args" : [ "function_pointers2" ] }
;127.0.0.1:10020${ "module" : "gsm", "args" : [ "gsm1" , "-fps" , "-c", "gsm/large.au" ] }
;127.0.0.1:10020${ "module" : "gsm", "args" : [ "gsm2" , "-fps" , "-c", "gsm/large.au" ] }
;127.0.0.1:10022${ "module" : "libjpeg", "args" : [ "libjpeg1" ] }
;127.0.0.1:10022${ "module" : "libjpeg", "args" : [ "libjpeg2" ] }
;127.0.0.1:10024${ "module" : "mandelbrot", "args" : [ "mandelbrot1", "5000" ] }
;127.0.0.1:10024${ "module" : "mandelbrot", "args" : [ "mandelbrot2", "5000" ] }
;127.0.0.1:10026${ "module" : "matrix_multiply", "args" : [ "matrix_multiply1" ] }
;127.0.0.1:10026${ "module" : "matrix_multiply", "args" : [ "matrix_multiply2" ] }
;127.0.0.1:10028${ "module" : "patricia", "args" : [ "patricia1" , "large.udp" ] }
;127.0.0.1:10030${ "module" : "sqlite", "args" : [ "sqlite1" ] }
;127.0.0.1:10030${ "module" : "sqlite", "args" : [ "sqlite2" ] }
127.0.0.1:10032${ "module" : "stringsearch", "args" : [ "strsearch1" ] }
127.0.0.1:10032${ "module" : "stringsearch", "args" : [ "strsearch2" ] }
;127.0.0.1:10034${ "module" : "filesys", "args" : [ "filesys1", "fs_in.txt", "fs_out.txt" ] }
;127.0.0.1:10036${ "module" : "sockserver", "args" : [ "sockserv1", "20000" ] }
;127.0.0.1:10038${ "module" : "sockclient", "args" : [ "sockcli1", "localhost", "20000" ] }

@ -0,0 +1,16 @@
{
"active": true,
"name": "tree",
"path": "tree_wasm.so",
"port": 10000,
"expected-execution-us": 5000,
"relative-deadline-us": 360000,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 1024,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain"
}

@ -0,0 +1,63 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#define MAX_BUF 300
#define MAX_TOKENS 100
// 修改split_string函数使其返回字符串数组
char **split_string(char *str, int *token_count) {
char **p = malloc(MAX_TOKENS * sizeof(char*));
int i = 0;
char *saveptr;
char *token = strtok_r(str, "++", &saveptr);
while (token != NULL) {
p[i++] = token;
token = strtok_r(NULL, "++", &saveptr);
}
*token_count = i; // 设置token计数
return p;
}
int main(int argc, char **argv) {
char *d = malloc(MAX_BUF + 1);
int r = read(0, d, MAX_BUF);
d[r] = '\0';
// 移除输入中的换行符
if (d[r - 1] == '\n') {
d[r - 1] = '\0';
}
int token_count;
char **tokens = split_string(d, &token_count);
// 确保至少有两个token
if (token_count >= 2) {
char *endptr1, *endptr2;
long num1 = strtol(tokens[0], &endptr1, 10);
long num2 = strtol(tokens[1], &endptr2, 10);
// 检查转换是否成功
if (*endptr1 == '\0' && *endptr2 == '\0') {
long sum = num1 + num2;
printf("the sum is %ld\n", sum);
} else {
if (*endptr1 != '\0') {
return -1;
}
if (*endptr2 != '\0') {
return -1;
}
}
} else {
return -1;
}
free(tokens); // 释放分配的内存
free(d);
return 0;
}

Binary file not shown.

@ -0,0 +1,22 @@
Runtime Environment:
CPU Speed: 2400 MHz
Processor Speed: 2400 MHz
RLIMIT_DATA: Infinite
RLIMIT_NOFILE: 1048576 (Increased from 8192)
Core Count: 8
Listener core ID: 1
First Worker core ID: 2
Worker core count: 6
Scheduler Policy: EDF
Sigalrm Policy: BROADCAST
Preemption: Enabled
Quantum: 5000 us
Sandbox Performance Log: Disabled
Starting listener thread
Listener core thread: 7ffff7a006c0
Starting 6 worker thread(s)
C: 01, T: 0x7ffff7bfdd80, F: runtime_start_runtime_worker_threads>
Sandboxing environment ready!
C: 01, T: 0x7ffff7bfdd80, F: module_new>
Stack Size: 524288
Loading…
Cancel
Save