parent
4b2a905e92
commit
a66ea1bc25
@ -1,2 +1,2 @@
|
||||
sudo chsh -s /bin/bash hai
|
||||
sudo chsh -s /bin/bash weihao
|
||||
|
||||
|
@ -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
|
||||
},
|
@ -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…
Reference in new issue