Compare commits
23 Commits
main
...
sledge_gra
Author | SHA1 | Date |
---|---|---|
|
7da0f72179 | 7 months ago |
|
ed80c30ccf | 7 months ago |
|
8990f5c5ed | 7 months ago |
|
87672b74c4 | 7 months ago |
|
87ba8af8a0 | 8 months ago |
|
a696655ad5 | 8 months ago |
|
10d9659172 | 8 months ago |
|
97b158f508 | 9 months ago |
|
a66ea1bc25 | 10 months ago |
|
4b2a905e92 | 10 months ago |
|
a056d25ff4 | 10 months ago |
|
46b4325dba | 10 months ago |
|
8eae02580f | 10 months ago |
|
5711145b3b | 11 months ago |
|
1854297530 | 11 months ago |
|
bae018314f | 11 months ago |
|
0f9b75d784 | 11 months ago |
|
8ae955fbfc | 11 months ago |
|
702f5de60d | 11 months ago |
|
0b1fb6c5d7 | 11 months ago |
|
7abc07445d | 11 months ago |
|
3aeed6f94b | 11 months ago |
|
70fdbb348c | 12 months ago |
@ -1,3 +1,3 @@
|
||||
LD_LIBRARY_PATH=/home/hai/sledge-serverless-framework/runtime/bin
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_SANDBOX_PERF_LOG=/home/hai/sledge-serverless-framework/debuglog.txt
|
||||
LD_LIBRARY_PATH=/home/hai/sledge/sledge/runtime/bin
|
||||
SLEDGE_SCHEDULER=MDL
|
||||
SLEDGE_SANDBOX_PERF_LOG=/home/hai/sledge/sledge/runtime/tests/runtime_sandbox_perf_log.log
|
||||
|
@ -1,52 +1,114 @@
|
||||
{
|
||||
// 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
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"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
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "graph",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/runtime/bin/sledgert",
|
||||
"args": [
|
||||
"${workspaceFolder}/runtime/tests/graph.json"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"sourceFileMap": {
|
||||
"/sledge/runtime": "${workspaceFolder}/runtime"
|
||||
},
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"envFile": "${workspaceFolder}/.env",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "utest",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/runtime/utest/map",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"sourceFileMap": {},
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"envFile": "${workspaceFolder}/.env",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "C/C++ Runner: Debug Session",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": false,
|
||||
"cwd": "/home/weihao/sledge/sledge_tree/runtime/tests/noop",
|
||||
"program": "/home/weihao/sledge/sledge_tree/runtime/tests/noop/build/Debug/outDebug",
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
import sys
|
||||
|
||||
def calculate_average(input_file, column_index):
|
||||
total = 0
|
||||
count = 0
|
||||
|
||||
with open(input_file, 'r') as f:
|
||||
for line in f:
|
||||
columns = line.strip().split(',')
|
||||
if len(columns) > column_index:
|
||||
try:
|
||||
value = float(columns[column_index])
|
||||
total += value
|
||||
count += 1
|
||||
except ValueError:
|
||||
print(f"error value: {columns[column_index]}")
|
||||
|
||||
if count > 0:
|
||||
average = total / count
|
||||
print(f"list {column_index + 1} average: {average}")
|
||||
else:
|
||||
print("no value")
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 3:
|
||||
print(" python calculate_average.py input_file column_index")
|
||||
else:
|
||||
input_file = sys.argv[1]
|
||||
column_index = int(sys.argv[2]) - 1
|
||||
calculate_average(input_file, column_index)
|
@ -0,0 +1,41 @@
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def plot_max_rps_comparison():
|
||||
# Data from the previous description
|
||||
sizes = ['5KB', '40KB', '105KB', '305KB']
|
||||
max_rps_before = [121, 85, 63, 33]
|
||||
max_rps_after = [607, 235, 128, 45]
|
||||
|
||||
# Index for each bar position along the x-axis
|
||||
index = range(len(sizes))
|
||||
bar_width = 0.35 # width of the bars
|
||||
|
||||
# Setting up the plot
|
||||
fig, ax = plt.subplots()
|
||||
ax.set_facecolor('#f0f0f0')
|
||||
|
||||
# Creating bars for "Before Optimization"
|
||||
rects1 = ax.bar(index, max_rps_before, bar_width, label='Mixed Task', color='orange')
|
||||
|
||||
# Creating bars for "After Optimization" shifted to the right by `bar_width`
|
||||
rects2 = ax.bar([p + bar_width for p in index], max_rps_after, bar_width, label='Single Task', color='skyblue')
|
||||
|
||||
# Adding labels and title
|
||||
ax.set_xlabel('Image Size(KB)')
|
||||
ax.set_ylabel('MAX RPS')
|
||||
ax.set_title('Mixed and Single Task Performance Comparison')
|
||||
|
||||
# Setting the position of the x-ticks to be in the middle of the grouped bars
|
||||
ax.set_xticks([p + bar_width / 2 for p in index])
|
||||
ax.set_xticklabels(sizes)
|
||||
|
||||
# Adding a legend to explain which bars represent before and after optimization
|
||||
ax.legend()
|
||||
|
||||
# Displaying the plot
|
||||
plt.show()
|
||||
|
||||
# Call the function to display the plot
|
||||
plot_max_rps_comparison()
|
@ -0,0 +1,51 @@
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib import font_manager as fm
|
||||
|
||||
def load_data(filename):
|
||||
"""
|
||||
Load data from a file.
|
||||
Assumes that each line in the file is a float value.
|
||||
"""
|
||||
with open(filename, 'r') as file:
|
||||
data = file.read().split()
|
||||
data = [float(i) for i in data]
|
||||
return data
|
||||
|
||||
def main():
|
||||
# 加载数据
|
||||
edf_data = [0.83, 1.35, 1.88, 2.36, 1.9]
|
||||
llf_data = [0.45, 0.4, 0.52, 0.97, 0.9]
|
||||
|
||||
# 设置X轴的数据点
|
||||
x_labels = [50, 60, 70, 80, 90] # 确保数据与这些标签相匹配
|
||||
|
||||
font_properties = fm.FontProperties(family='Times New Roman', size=18)
|
||||
plt.rcParams.update({'font.size': 18, 'font.family': 'Times New Roman'})
|
||||
|
||||
# 创建图形和绘制数据
|
||||
plt.figure(figsize=(10, 5))
|
||||
ax = plt.gca() # 获取当前的Axes对象ax
|
||||
ax.set_facecolor('#f0f0f0') # 设置浅灰色背景
|
||||
plt.plot(x_labels, edf_data, marker='s', linestyle='-', color='#C8503D', markersize=8, label='EDF')
|
||||
plt.plot(x_labels, llf_data, marker='^', linestyle='-', color='#00008B', markersize=8, label='LLF')
|
||||
|
||||
# 添加标题、标签和图例
|
||||
plt.title('5KB-1.5*Deadline', fontsize=20, fontproperties=font_properties)
|
||||
plt.xlabel('Load (% of maximum RPS)', fontproperties=font_properties)
|
||||
plt.ylabel('Deadline Miss Rate (%)', fontproperties=font_properties)
|
||||
plt.legend(prop=font_properties)
|
||||
|
||||
# 设置X轴刻度
|
||||
plt.xticks(range(50, 91, 10))
|
||||
|
||||
# 设置网格
|
||||
plt.grid(True)
|
||||
|
||||
# 移除边框的四边刻度线
|
||||
plt.tick_params(axis='both', which='both', length=0) # 移除刻度线
|
||||
|
||||
# 显示图形
|
||||
plt.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -0,0 +1,24 @@
|
||||
# split_logs.py
|
||||
|
||||
def split_logs(input_file):
|
||||
modules = {
|
||||
"resize1": [],
|
||||
"png2bmp1": [],
|
||||
"lpd_wasm1": [],
|
||||
"cifar10_1": [],
|
||||
"work1": []
|
||||
}
|
||||
|
||||
with open(input_file, 'r') as f:
|
||||
for line in f:
|
||||
for module in modules.keys():
|
||||
if module in line:
|
||||
modules[module].append(line.strip())
|
||||
break
|
||||
|
||||
for module, entries in modules.items():
|
||||
with open(f"{module}.txt", 'w') as outfile:
|
||||
outfile.write("\n".join(entries) + "\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
split_logs("sledge.log")
|
@ -0,0 +1,20 @@
|
||||
import sys
|
||||
|
||||
def split_columns(input_file):
|
||||
columns = []
|
||||
|
||||
with open(input_file, 'r') as f:
|
||||
for line in f:
|
||||
parts = line.strip().split(',')
|
||||
for i, part in enumerate(parts):
|
||||
if len(columns) <= i:
|
||||
columns.append([])
|
||||
columns[i].append(part)
|
||||
|
||||
for i, column in enumerate(columns):
|
||||
with open(f"{input_file[:-4]}_column_{i + 1}.txt", 'w') as outfile:
|
||||
outfile.write("\n".join(column) + "\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
for input_file in sys.argv[1:]:
|
||||
split_columns(input_file)
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,180 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* Simple K-V store based on The Practice of Programming by Kernighan and Pike */
|
||||
|
||||
/* Bucket count is sized to be a prime that is approximately 20% larger than the desired capacity (6k keys) */
|
||||
#define MAP_BUCKET_COUNT 7907
|
||||
#define MAP_HASH jenkins_hash
|
||||
|
||||
struct map_node {
|
||||
struct map_node *next;
|
||||
char *key;
|
||||
void *value;
|
||||
uint32_t key_len;
|
||||
uint32_t value_len;
|
||||
uint32_t hash;
|
||||
bool manage_mvalue;
|
||||
};
|
||||
|
||||
struct map_bucket {
|
||||
struct map_node *head;
|
||||
};
|
||||
|
||||
struct hashmap {
|
||||
struct map_bucket buckets[MAP_BUCKET_COUNT];
|
||||
};
|
||||
|
||||
static inline void
|
||||
map_init(struct hashmap *restrict map)
|
||||
{
|
||||
for (int i = 0; i < MAP_BUCKET_COUNT; i++) {
|
||||
map->buckets[i].head = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* See https://en.wikipedia.org/wiki/Jenkins_hash_function */
|
||||
static inline uint32_t
|
||||
jenkins_hash(char *key, uint32_t key_len)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
uint32_t hash = 0;
|
||||
while (i != key_len) {
|
||||
hash += key[i++];
|
||||
hash += hash << 10;
|
||||
hash ^= hash >> 6;
|
||||
}
|
||||
hash += hash << 3;
|
||||
hash ^= hash >> 11;
|
||||
hash += hash << 15;
|
||||
return hash;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
map_get(struct hashmap *map, char *key, uint32_t key_len, uint32_t *ret_value_len)
|
||||
{
|
||||
void *value = NULL;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
|
||||
value = node->value;
|
||||
*ret_value_len = node->value_len;
|
||||
goto DONE;
|
||||
}
|
||||
}
|
||||
|
||||
if (value == NULL) *ret_value_len = 0;
|
||||
|
||||
DONE:
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @manage_mvalue manage _ mvalue determines whether the hash table or the caller manages value memory, and true is managed by the hash.
|
||||
*/
|
||||
static inline bool
|
||||
map_set(struct hashmap *map, char *key, uint32_t key_len, void *value, uint32_t value_len, bool manage_mvalue)
|
||||
{
|
||||
bool did_set = false;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) goto DONE;
|
||||
}
|
||||
|
||||
struct map_node *new_node = (struct map_node *)xmalloc(sizeof(struct map_node));
|
||||
*(new_node) = (struct map_node){ .hash = hash,
|
||||
.key = xmalloc(key_len),
|
||||
.key_len = key_len,
|
||||
.value_len = value_len,
|
||||
.next = bucket->head };
|
||||
|
||||
// Copy Key and Value
|
||||
memcpy(new_node->key, key, key_len);
|
||||
if (manage_mvalue) {
|
||||
new_node->value = xmalloc(value_len);
|
||||
memcpy(new_node->value, value, value_len);
|
||||
} else {
|
||||
new_node->value = value;
|
||||
}
|
||||
new_node->manage_mvalue = manage_mvalue;
|
||||
bucket->head = new_node;
|
||||
did_set = true;
|
||||
|
||||
DONE:
|
||||
return did_set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns boolean if node was deleted or not
|
||||
*/
|
||||
static inline bool
|
||||
map_delete(struct hashmap *map, char *key, uint32_t key_len)
|
||||
{
|
||||
bool did_delete = false;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
struct map_node *prev = NULL;
|
||||
struct map_node *node = bucket->head;
|
||||
while (node != NULL) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
if (prev == NULL) {
|
||||
bucket->head = node->next;
|
||||
} else {
|
||||
prev->next = node->next;
|
||||
}
|
||||
free(node->key);
|
||||
node->key = NULL;
|
||||
if (node->manage_mvalue) {
|
||||
free(node->value);
|
||||
node->value = NULL;
|
||||
}
|
||||
free(node);
|
||||
node = NULL;
|
||||
did_delete = true;
|
||||
break;
|
||||
}
|
||||
prev = node;
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
return did_delete;
|
||||
}
|
||||
|
||||
static inline void
|
||||
map_upsert(struct hashmap *map, char *key, uint32_t key_len, void *value, uint32_t value_len)
|
||||
{
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
node->value_len = value_len;
|
||||
node->value = realloc(node->value, value_len);
|
||||
assert(node->value);
|
||||
if (node->manage_mvalue)
|
||||
{
|
||||
memcpy(node->value, value, value_len);
|
||||
}else node->value = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
panic("map_upsert: key not found");
|
||||
}
|
@ -0,0 +1,246 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
//#include "lock.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
typedef pthread_rwlock_t rwlock_t;
|
||||
#define LOCK_INIT_RW(lock) pthread_rwlock_init(lock, NULL)
|
||||
#define LOCK_RDLOCK_RW(lock) pthread_rwlock_rdlock(lock)
|
||||
#define LOCK_WRLOCK_RW(lock) pthread_rwlock_wrlock(lock)
|
||||
#define LOCK_UNLOCK_RW(lock) pthread_rwlock_unlock(lock)
|
||||
|
||||
/* Simple K-V store based on The Practice of Programming by Kernighan and Pike */
|
||||
|
||||
/* Bucket count is sized to be a prime that is approximately 20% larger than the desired capacity (6k keys) */
|
||||
#define MAP_BUCKET_COUNT 7907
|
||||
#define MAP_HASH jenkins_hash
|
||||
|
||||
struct map_node {
|
||||
struct map_node *next;
|
||||
char *key;
|
||||
void *value;
|
||||
uint32_t key_len;
|
||||
uint32_t value_len;
|
||||
uint32_t hash;
|
||||
bool manage_mvalue;
|
||||
};
|
||||
|
||||
struct map_bucket {
|
||||
rwlock_t lock;
|
||||
struct map_node *head;
|
||||
};
|
||||
|
||||
struct hashmap {
|
||||
struct map_bucket buckets[MAP_BUCKET_COUNT];
|
||||
};
|
||||
|
||||
static inline void
|
||||
map_init(struct hashmap *restrict map)
|
||||
{
|
||||
for (int i = 0; i < MAP_BUCKET_COUNT; i++) {
|
||||
map->buckets[i].head = NULL;
|
||||
LOCK_INIT_RW(&map->buckets[i].lock);
|
||||
}
|
||||
}
|
||||
|
||||
/* See https://en.wikipedia.org/wiki/Jenkins_hash_function */
|
||||
static inline uint32_t
|
||||
jenkins_hash(char *key, uint32_t key_len)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
uint32_t hash = 0;
|
||||
while (i != key_len) {
|
||||
hash += key[i++];
|
||||
hash += hash << 10;
|
||||
hash ^= hash >> 6;
|
||||
}
|
||||
hash += hash << 3;
|
||||
hash ^= hash >> 11;
|
||||
hash += hash << 15;
|
||||
return hash;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
map_get(struct hashmap *map, char *key, uint32_t key_len, uint32_t *ret_value_len)
|
||||
{
|
||||
void *value = NULL;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
LOCK_RDLOCK_RW(&bucket->lock);
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
|
||||
value = node->value;
|
||||
*ret_value_len = node->value_len;
|
||||
goto DONE;
|
||||
}
|
||||
}
|
||||
|
||||
if (value == NULL) *ret_value_len = 0;
|
||||
|
||||
DONE:
|
||||
LOCK_UNLOCK_RW(&bucket->lock);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @manage_mvalue manage _ mvalue determines whether the hash table or the caller manages value memory, and true is managed by the hash.
|
||||
*/
|
||||
static inline bool
|
||||
map_set(struct hashmap *map, char *key, uint32_t key_len, void *value, uint32_t value_len, bool manage_mvalue)
|
||||
{
|
||||
bool did_set = false;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
LOCK_WRLOCK_RW(&bucket->lock);
|
||||
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) goto DONE;
|
||||
}
|
||||
|
||||
struct map_node *new_node = (struct map_node *)xmalloc(sizeof(struct map_node));
|
||||
*(new_node) = (struct map_node){ .hash = hash,
|
||||
.key = xmalloc(key_len),
|
||||
.key_len = key_len,
|
||||
.value_len = value_len,
|
||||
.next = bucket->head };
|
||||
|
||||
// Copy Key and Value
|
||||
memcpy(new_node->key, key, key_len);
|
||||
if (manage_mvalue) {
|
||||
new_node->value = xmalloc(value_len);
|
||||
memcpy(new_node->value, value, value_len);
|
||||
} else {
|
||||
new_node->value = value;
|
||||
}
|
||||
new_node->manage_mvalue = manage_mvalue;
|
||||
bucket->head = new_node;
|
||||
did_set = true;
|
||||
|
||||
DONE:
|
||||
LOCK_UNLOCK_RW(&bucket->lock);
|
||||
return did_set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns boolean if node was deleted or not
|
||||
*/
|
||||
static inline bool
|
||||
map_delete(struct hashmap *map, char *key, uint32_t key_len)
|
||||
{
|
||||
bool did_delete = false;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
LOCK_WRLOCK_RW(&bucket->lock);
|
||||
|
||||
struct map_node *prev = NULL;
|
||||
struct map_node *node = bucket->head;
|
||||
while (node != NULL) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
if (prev == NULL) {
|
||||
bucket->head = node->next;
|
||||
} else {
|
||||
prev->next = node->next;
|
||||
}
|
||||
free(node->key);
|
||||
node->key = NULL;
|
||||
if (node->manage_mvalue) {
|
||||
free(node->value);
|
||||
node->value = NULL;
|
||||
}
|
||||
free(node);
|
||||
node = NULL;
|
||||
did_delete = true;
|
||||
break;
|
||||
}
|
||||
prev = node;
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
LOCK_UNLOCK_RW(&bucket->lock);
|
||||
return did_delete;
|
||||
}
|
||||
|
||||
static inline void
|
||||
map_upsert(struct hashmap *map, char *key, uint32_t key_len, void *value, uint32_t value_len)
|
||||
{
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
LOCK_WRLOCK_RW(&bucket->lock);
|
||||
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
node->value_len = value_len;
|
||||
node->value = realloc(node->value, value_len);
|
||||
assert(node->value);
|
||||
if (node->manage_mvalue)
|
||||
{
|
||||
memcpy(node->value, value, value_len);
|
||||
}else node->value = value;
|
||||
goto DONE;
|
||||
}
|
||||
}
|
||||
panic("map_upsert: key not found");
|
||||
/*struct map_node *new_node = (struct map_node *)xmalloc(sizeof(struct map_node));
|
||||
|
||||
*(new_node) = (struct map_node){ .hash = hash,
|
||||
.key = xmalloc(key_len),
|
||||
.key_len = key_len,
|
||||
.value = xmalloc(value_len),
|
||||
.value_len = value_len,
|
||||
.next = bucket->head };
|
||||
|
||||
assert(new_node->key);
|
||||
assert(new_node->value);
|
||||
|
||||
// Copy Key and Value
|
||||
memcpy(new_node->key, key, key_len);
|
||||
memcpy(new_node->value, value, value_len);
|
||||
|
||||
bucket->head = new_node;*/
|
||||
|
||||
DONE:
|
||||
LOCK_UNLOCK_RW(&bucket->lock);
|
||||
}
|
||||
|
||||
/*static inline void
|
||||
map_destroy(struct hashmap *map) {
|
||||
for (int i = 0; i < MAP_BUCKET_COUNT; i++) {
|
||||
LOCK_LOCK_RW(&map->buckets[i].lock);
|
||||
struct map_node *current = map->buckets[i].head;
|
||||
struct map_node *next;
|
||||
|
||||
while (current != NULL) {
|
||||
next = current->next;
|
||||
free(current->key);
|
||||
if (current->manage_mvalue && current->value != NULL) {
|
||||
free(current->value);
|
||||
}
|
||||
free(current);
|
||||
current = next;
|
||||
}
|
||||
|
||||
LOCK_UNLOCK_RW(&map->buckets[i].lock);
|
||||
|
||||
pthread_mutex_destroy(&map->buckets[i].lock);
|
||||
|
||||
// 确保头指针设置为 NULL
|
||||
map->buckets[i].head = NULL;
|
||||
}
|
||||
// 如果 hashmap 是动态分配的,这里还需要释放 hashmap 结构本身
|
||||
// free(map);
|
||||
}*/
|
||||
|
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "likely.h"
|
||||
#include "panic.h"
|
||||
|
||||
static inline void *
|
||||
xmalloc(size_t size)
|
||||
{
|
||||
void *allocation = malloc(size);
|
||||
if (unlikely(allocation == NULL)) panic("xmalloc failed!\n");
|
||||
return allocation;
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
a
|
@ -0,0 +1 @@
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
function usage {
|
||||
echo "$0 [cpu-log]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
path="/home/hai/sledge-old/runtime/tests"
|
||||
|
||||
#test work1k 2000
|
||||
server_log_file="edf_1k.log"
|
||||
$path/compare/start_compare.sh $server_log_file >/dev/null 2>&1 &
|
||||
echo "sledge is running"
|
||||
./hey_test_compare.sh 60 22
|
||||
$path/kill_sledge.sh
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,24 @@
|
||||
function usage {
|
||||
echo "$0 [duration(s)] [concurrency]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# != 2 ] ; then
|
||||
usage
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
duration=$1
|
||||
concurrency=$2
|
||||
|
||||
f1="1byte_"$concurrency".txt"
|
||||
echo $f1
|
||||
f2="0.4k_"$concurrency".txt"
|
||||
|
||||
./test_8c.sh $f1 $duration $concurrency 1byte_file 10000 2>&1 &
|
||||
pid1=$!
|
||||
./test_8c.sh $f2 $duration $concurrency 410byte_file 10004 2>&1 &
|
||||
pid4=$!
|
||||
wait -f $pid1
|
||||
wait -f $pid2
|
||||
printf "[OK]\n"
|
@ -0,0 +1,29 @@
|
||||
#!/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=2400
|
||||
export SLEDGE_SCHEDULER=EDF
|
||||
export SLEDGE_SIGALRM_HANDLER=BROADCAST
|
||||
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/compare/test_work1k.json
|
@ -0,0 +1,22 @@
|
||||
function usage {
|
||||
echo "$0 [output file] [duration(s)] [concurrency] [image file] [port]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# != 5 ] ; then
|
||||
echo "input parameters are not 5"
|
||||
usage
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
output=$1
|
||||
duration=$2
|
||||
concurrency=$3
|
||||
image=$4
|
||||
port=$5
|
||||
|
||||
echo "hey -disable-compression -disable-keepalive -disable-redirects -c $concurrency -z $duration\s -t 0 -m GET -D "$image" "http://127.0.0.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 $concurrency -z 20s -t 0 -m GET -D "$image" "http://10.10.1.1:$port"
|
||||
hey -disable-compression -disable-keepalive -disable-redirects -n 5000 -c $concurrency -z $duration\s -t 0 -m GET -D "$image" "http://127.0.0.1:$port" > $output
|
@ -0,0 +1,136 @@
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k1_1",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10000,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 0,
|
||||
"next_modules": ["work1k1_2", "work1k1_3"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k1_2",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10001,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work1k1_4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k1_3",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10002,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 2,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work1k1_4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k1_4",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10003,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 2,
|
||||
"next_modules": [],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain",
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k2_1",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10004,
|
||||
"relative-deadline-us": 90000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 0,
|
||||
"next_modules": ["work1k2_2", "work1k2_3"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k2_2",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10005,
|
||||
"relative-deadline-us": 90000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work1k2_4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k2_3",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10006,
|
||||
"relative-deadline-us": 90000,
|
||||
"argsize": 1,
|
||||
"priority": 2,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work1k2_4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k2_4",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10007,
|
||||
"relative-deadline-us": 90000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 2,
|
||||
"next_modules": [],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plaini",
|
||||
},
|
@ -0,0 +1,85 @@
|
||||
{
|
||||
"active": true,
|
||||
"name": "fibona1",
|
||||
"path": "fibchain_wasm.so",
|
||||
"port": 10000,
|
||||
"relative-deadline-us": 18000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 0,
|
||||
"next_modules": ["fibona2"],
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "fibona2",
|
||||
"path": "fibchain_wasm.so",
|
||||
"port": 10002,
|
||||
"relative-deadline-us": 18000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["fibona3"],
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "fibona3",
|
||||
"path": "fibchain_wasm.so",
|
||||
"port": 10003,
|
||||
"relative-deadline-us": 18000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["fibona4"],
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "fibona4",
|
||||
"path": "fibchain_wasm.so",
|
||||
"port": 10004,
|
||||
"relative-deadline-us": 18000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["fibona5"],
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "fibona5",
|
||||
"path": "fibchain_wasm.so",
|
||||
"port": 10005,
|
||||
"relative-deadline-us": 18000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": [],
|
||||
"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,20 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
unsigned long int
|
||||
fib(unsigned long int n)
|
||||
{
|
||||
if (n <= 1) return n;
|
||||
return fib(n - 1) + fib(n - 2);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
unsigned long n = 0;
|
||||
scanf("%lu", &n);
|
||||
n= fib(n);
|
||||
printf("%lu\n", n);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,40 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// #include "get_time.h"
|
||||
unsigned long int
|
||||
fib(unsigned long int n)
|
||||
{
|
||||
if (n <= 1) return n;
|
||||
return fib(n - 1) + fib(n - 2);
|
||||
}
|
||||
/*
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
unsigned long r = 0;
|
||||
//scanf("%s", recv_buf);
|
||||
r = fib(30);
|
||||
printf("%lu\n", r);
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
//char * recv_buf = malloc(1024 * 1024);
|
||||
char recv_buf[1024 * 1024] = {0};
|
||||
//memset(recv_buf, 0, 1024 * 1024);
|
||||
unsigned long r = 0;
|
||||
//scanf("%s", recv_buf);
|
||||
r = read(0, recv_buf, 1024 * 1024);
|
||||
unsigned long n = 0;
|
||||
scanf("%lu", &n);
|
||||
//size_t rd = read(0, recv_buf, 1000*1024);
|
||||
//if (rd <= 0) return -1;
|
||||
|
||||
// unsigned long long st = get_time(), en;
|
||||
//r = fib(30);
|
||||
// en = get_time();
|
||||
printf("%lu\n", r);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
n = fib(n);
|
||||
}
|
||||
|
||||
printf("%lu\n", n);
|
||||
|
||||
// print_time(st, en);
|
||||
return 0;
|
||||
}
|
||||
|
@ -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,17 @@
|
||||
{
|
||||
"active": true,
|
||||
"name": "fibona1",
|
||||
"path": "fibonacci2_wasm.so",
|
||||
"port": 10000,
|
||||
"relative-deadline-us": 18000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 0,
|
||||
"next_modules": [],
|
||||
"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,68 @@
|
||||
{
|
||||
"active": true,
|
||||
"name": "work",
|
||||
"path": "work_wasm.so",
|
||||
"port": 10000,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 0,
|
||||
"next_modules": ["work2", "work3"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1048776,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1048776,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work2",
|
||||
"path": "work_wasm.so",
|
||||
"port": 10001,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1048776,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1048776,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work3",
|
||||
"path": "work_wasm.so",
|
||||
"port": 10002,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1048776,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1048776,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work4",
|
||||
"path": "fibonacciadd_wasm.so",
|
||||
"port": 10003,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 2,
|
||||
"next_modules": [],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1048776,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1048776,
|
||||
"http-resp-content-type": "text/plain"
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#define OUTPUT_BUFFER_SIZE (1024 * 5) // 5KB
|
||||
|
||||
int main() {
|
||||
char *data = (char *)malloc(10 * 1024); // Allocate 10KB
|
||||
if (!data) {
|
||||
fprintf(stderr, "Failed to allocate memory.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ssize_t bytesRead = read(STDIN_FILENO, data, 10 * 1024);
|
||||
if (bytesRead == -1) {
|
||||
fprintf(stderr, "Failed to read data from file.\n");
|
||||
free(data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create a combined buffer to hold the output
|
||||
char *combined_output = malloc(2 * OUTPUT_BUFFER_SIZE + 50); // 50 extra bytes for text and safety
|
||||
if (!combined_output) {
|
||||
fprintf(stderr, "Failed to allocate memory for combined output.\n");
|
||||
free(data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Format the output in a single buffer
|
||||
int offset = sprintf(combined_output, "Buffer 1 (First 5KB): ");
|
||||
memcpy(combined_output + offset, data, OUTPUT_BUFFER_SIZE);
|
||||
offset += OUTPUT_BUFFER_SIZE;
|
||||
offset += sprintf(combined_output + offset, " Buffer 2 (Second 5KB): ");
|
||||
memcpy(combined_output + offset, data + OUTPUT_BUFFER_SIZE, OUTPUT_BUFFER_SIZE);
|
||||
|
||||
// Print everything in one go
|
||||
fwrite(combined_output, sizeof(char), offset + OUTPUT_BUFFER_SIZE, stdout);
|
||||
printf("\n");
|
||||
|
||||
// Clean up
|
||||
free(data);
|
||||
free(combined_output);
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
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)
|
@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void noop() {
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
noop();
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
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()
|
@ -0,0 +1,111 @@
|
||||
#include "dag_split_image.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct DataNode {
|
||||
uint32_t dataLength;
|
||||
unsigned char *data;
|
||||
struct DataNode *next;
|
||||
};
|
||||
|
||||
DataNode* splitData(unsigned 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 = (unsigned 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;
|
||||
}
|
||||
|
||||
unsigned 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;
|
||||
}
|
||||
uint32_t getImageDataSize(DataNode *head, int index){
|
||||
int count = 1;
|
||||
DataNode *current = head;
|
||||
while (current != NULL) {
|
||||
if (count == index) {
|
||||
return current->dataLength;
|
||||
}
|
||||
count++;
|
||||
current = current->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct DataNode DataNode;
|
||||
|
||||
DataNode* splitData(unsigned char *buffer, uint32_t bufferSize);
|
||||
|
||||
void freeDataNodes(DataNode *head);
|
||||
|
||||
void printDataList(DataNode *head);
|
||||
|
||||
int getDataNodeCount(DataNode *head);
|
||||
|
||||
/**
|
||||
* @param index is form 1 to n
|
||||
*/
|
||||
unsigned char* getDataNodeByIndex(DataNode *head, int index);
|
||||
uint32_t getImageDataSize(DataNode *head, int index);
|
@ -0,0 +1,79 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "dag_split_image.h"
|
||||
|
||||
#define MAX_IMG_SZ 8*1025*1024
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned char *zInpbuf = NULL;
|
||||
|
||||
zInpbuf = malloc(MAX_IMG_SZ);
|
||||
if (!zInpbuf)
|
||||
{
|
||||
perror("malloc");
|
||||
return -1;
|
||||
}
|
||||
ssize_t imgSz = read(0, zInpbuf, MAX_IMG_SZ);
|
||||
if (imgSz <= 0)
|
||||
{
|
||||
perror("read");
|
||||
free(zInpbuf);
|
||||
return -1;
|
||||
}
|
||||
DataNode *dataList = splitData(zInpbuf, imgSz);
|
||||
if (dataList == NULL) {
|
||||
fprintf(stderr, "Failed to split data.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
unsigned char *Imagedata1 = getDataNodeByIndex(dataList, 1);
|
||||
unsigned char *Imagedata2 = getDataNodeByIndex(dataList, 2);
|
||||
|
||||
uint32_t imageSize1 = getImageDataSize(dataList, 1);
|
||||
uint32_t imageSize2 = getImageDataSize(dataList, 2);
|
||||
|
||||
int x, y;
|
||||
FILE *out_bin = stdout;
|
||||
|
||||
for (int i = 0; i < 54; i++)
|
||||
{
|
||||
x = Imagedata1[i];
|
||||
y = (i < imageSize2) ? Imagedata2[i] : x;
|
||||
fwrite(&x, 1, 1, out_bin);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
unsigned long big_img_offset = 54;
|
||||
unsigned long small_img_offset = 54;
|
||||
|
||||
while (big_img_offset < imageSize1)
|
||||
{
|
||||
if (i == 2400) i = 0;
|
||||
|
||||
x = Imagedata1[big_img_offset++];
|
||||
|
||||
if (i < 300 && small_img_offset < imageSize2)
|
||||
{
|
||||
y = Imagedata2[small_img_offset++];
|
||||
fwrite(&y, 1, 1, out_bin);
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite(&x, 1, 1, out_bin);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
while (big_img_offset < imageSize1)
|
||||
{
|
||||
x = Imagedata1[big_img_offset++];
|
||||
fwrite(&x, 1, 1, out_bin);
|
||||
}
|
||||
|
||||
free(zInpbuf);
|
||||
return 0;
|
||||
}
|
@ -1 +1,2 @@
|
||||
sudo chsh -s /bin/bash xiaosuGW
|
||||
sudo chsh -s /bin/bash hai
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
#!/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
|
||||
#xport 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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue