修改机器学习部分

newsch
hwwang 4 months ago
parent 88163855bd
commit 99edf24def

@ -121,7 +121,11 @@
"h5cpp.h": "c",
"cstdlib": "c",
"sandbox_exit.h": "c",
"pocketsphinx.h": "c"
"pocketsphinx.h": "c",
"forward_list": "c",
"span": "c",
"any": "c",
"complex": "c"
},
"files.exclude": {
"**/.git": true,

@ -9,7 +9,8 @@ WASMCEPTION_URL=https://github.com/gwsystems/wasmception/releases/download/v0.2.
.PHONY: build
build:
ifeq ($(ARCH),x86_64)
cd ./awsm/wasmception && wget ${WASMCEPTION_URL} -O wasmception.tar.gz && tar xvfz wasmception.tar.gz && rm wasmception.tar.gz
cd ./awsm/wasmception
# && wget ${WASMCEPTION_URL} -O wasmception.tar.gz && tar xvfz wasmception.tar.gz && rm wasmception.tar.gz
endif
test -f ./${COMPILER}/wasmception/dist/bin/clang || make -C ${COMPILER}/wasmception
@cd ${COMPILER} && RUSTUP_TOOLCHAIN=stable cargo build --release && cd ${ROOT}

28
ma.py

@ -0,0 +1,28 @@
from collections import defaultdict
import statistics
# 创建一个字典来存储相同第四列的数据
grouped_data = defaultdict(list)
# 从 '1.log' 文件中读取数据
input_file_path = '1.log'
output_file_path = '2.log'
with open(input_file_path, 'r') as file:
for line in file:
parts = line.strip().split(',')
if len(parts) < 5: # 确保每一行至少有5个部分
continue
key = parts[4] # 第四列为键
value = int(parts[1]) # 第二列作为数值
grouped_data[key].append(value)
# 计算每个组的中位数
median_values = {key: statistics.median(values) for key, values in grouped_data.items()}
# 将结果写入到 '2.log' 文件
with open(output_file_path, 'w') as output_file:
for key, median in median_values.items():
output_file.write(f"{key}, {median}\n")
print(f"Results have been written to {output_file_path}")

@ -45,10 +45,10 @@ BINARY_NAME=sledgert
# This definition is used when the module is triggered by an HTTP request.
# It retrieves the length of the HTTP message data, the hash table, and the global queue length via a TCP socket.
# These values are then used as features for machine learning training
CFLAGS += -DDEEP_LEARN_SCHDUE
# CFLAGS += -DDEEP_LEARN_SCHDUE
# For machine learning purposes, the following data is collected and saved:
# Length of the HTTP message Hash table Global queue length Service execution time
CFLAGS += -DLOG_DEEP_LEARN_SCHDUE
# CFLAGS += -DLOG_DEEP_LEARN_SCHDUE
# This definition determines whether to use the median or the mean to calculate the execution times of the first 256 services.
# CFLAGS += -DGET_AVER_TIME
@ -73,7 +73,7 @@ CFLAGS += -DLOG_TO_FILE
# CFLAGS += -DLOG_MODULE_LOADING
# CFLAGS += -DOPT_AVOID_GLOBAL_QUEUE
# CFLAGS += -DLOG_RUNTIME_FILE_LOG
# CFLAGS += -DLOG_RUNTIME_MEM_LOG
CFLAGS += -DLOG_RUNTIME_MEM_LOG
# This dumps per module *.csv files containing the cycle a sandbox has been in RUNNING when each

@ -1,5 +1,6 @@
#include <stdint.h>
#include <unistd.h>
#include <math.h>
#include "arch/getcycles.h"
#include "client_socket.h"
@ -223,9 +224,11 @@ listener_thread_main(void *dummy)
module->mdl.http_data_size = content_length;
module->mdl.global_queue_node = global_request_scheduler_size();
module->mdl.hash_node = hash_count;
uint64_t estimated_execution_time = 0;
estimated_execution_time = module->mdl.http_data_size * module->val1 + module->val2;
#else
//
uint64_t register_execution_time = 0;
register_execution_time =module->val1 * module->mdl.http_data_size + module->val2 * 1000;
//debuglog("%s register_execution_time %ld\n, modle->val1 %ld, modle->val2 %ld", module->name, register_execution_time, module->val1, module->val2);
#endif
/* get total estimated execution time */
uint64_t estimated_execution_time = 0;
int front = 0, rear = 0;
@ -234,7 +237,7 @@ listener_thread_main(void *dummy)
while (rear != front)
{
struct module *current_module = queue[front++];
if (scheduler == SCHEDULER_SRSF || scheduler == SCHEDULER_EDF || scheduler == SCHEDULER_LLF)
if (scheduler == SCHEDULER_SRSF || scheduler == SCHEDULER_LLF)
{
#ifdef GET_AVER_TIME
estimated_execution_time += admission_info_get_average(&current_module->admissions_info);
@ -270,9 +273,29 @@ listener_thread_main(void *dummy)
current_module->runtime_visited = false;
}
}
#endif
/* Adding system start timestamp to avoid negative remaining slack in the following update. They are all cycles */
uint64_t remaining_slack = system_start_timestamp + module->relative_deadline - estimated_execution_time;
uint64_t remaining_slack = 0;
if (scheduler == SCHEDULER_LLF)
{
remaining_slack = system_start_timestamp + module->relative_deadline;
assert(remaining_slack != 0);
} else if (scheduler == SCHEDULER_MDL) {
#ifdef DEEP_LEARN_SCHDUE
assert(scheduler == SCHEDULER_MDL);
assert(register_execution_time != 0);
if(register_execution_time > estimated_execution_time*0.5 && register_execution_time < estimated_execution_time*5)
remaining_slack = system_start_timestamp + module->relative_deadline - register_execution_time;
else
remaining_slack = system_start_timestamp + module->relative_deadline - estimated_execution_time;
assert(remaining_slack != 0);
#endif
} else if (scheduler == SCHEDULER_SRSF) {
remaining_slack = system_start_timestamp + module->relative_deadline - estimated_execution_time;
assert(remaining_slack != 0);
}
uint64_t request_arrival_timestamp = __getcycles();

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before

Width:  |  Height:  |  Size: 201 KiB

After

Width:  |  Height:  |  Size: 201 KiB

Before

Width:  |  Height:  |  Size: 215 KiB

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

Before

Width:  |  Height:  |  Size: 241 KiB

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 KiB

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

@ -1,24 +0,0 @@
# -*- coding: utf-8 -*-
import csv
input_file = 'deep2.log'
output_file = 'data2.csv'
with open(input_file, 'r') as infile, open(output_file, 'w', newline='') as outfile:
writer = csv.writer(outfile)
writer.writerow(['y', 'x1', 'x2', 'x3'])
for line in infile:
parts = line.strip().split(',')
y = parts[1]
x1 = parts[2]
x2 = parts[3]
x3 = parts[4]
writer.writerow([y, x1, x2, x3])
print(f"{output_file}")

@ -38,5 +38,5 @@ cd $project_path/runtime/bin
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_noop2.json
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_dag_image.json
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_fibonacci.json
LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test.json
#LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test.json
LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_log.json

@ -0,0 +1,51 @@
{
"active": true,
"name": "gocr",
"path": "gocr_wasm.so",
"port": 10000,
"relative-deadline-us": 180000,
"argsize": 1,
"priority": 1,
"pre_module_count": 0,
"next_modules": ["voacc"],
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 10240000,
"http-resp-headers": [],
"http-resp-size": 10240,
"http-resp-content-type": "text/plain"
},
{
"active": true,
"name": "voacc",
"path": "voacc_wasm.so",
"port": 10002,
"relative-deadline-us": 180000,
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["work"],
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 10240,
"http-resp-headers": [],
"http-resp-size": 1024,
"http-resp-content-type": "text/plain"
},
{
"active": true,
"name": "work",
"path": "voacc_wasm.so",
"port": 10003,
"relative-deadline-us": 180000,
"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,360 @@
{
"active": true,
"name": "resize1",
"path": "resize_wasm.so",
"port": 10000,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"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,
"reg-prediction": [3,60],
"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,
"reg-prediction": [3,60],
"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"
},
{
"active": true,
"name": "cifar10_1",
"path": "cifar10_wasm.so",
"port": 10003,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"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"
},
{
"active": true,
"name": "work1",
"path": "work3_wasm.so",
"port": 10004,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"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"
},
{
"active": true,
"name": "resize1_2",
"path": "resize_wasm.so",
"port": 10005,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 1,
"pre_module_count": 0,
"next_modules": ["png2bmp1_2", "lpd_wasm1_2"],
"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_2",
"path": "C-Image-Manip_wasm.so",
"port": 10006,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["cifar10_2"],
"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_2",
"path": "lpd_wasm.so",
"port": 10007,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 2,
"pre_module_count": 1,
"next_modules": ["work1_2"],
"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",
},
{
"active": true,
"name": "cifar10_2",
"path": "cifar10_wasm.so",
"port": 10008,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["work1_2"],
"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"
},
{
"active": true,
"name": "work1_2",
"path": "work3_wasm.so",
"port": 10009,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"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"
},{
"active": true,
"name": "resize1_3",
"path": "resize_wasm.so",
"port": 10010,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 1,
"pre_module_count": 0,
"next_modules": ["png2bmp1_3", "lpd_wasm1_3"],
"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_3",
"path": "C-Image-Manip_wasm.so",
"port": 10011,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["cifar10_3"],
"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_3",
"path": "lpd_wasm.so",
"port": 10012,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 2,
"pre_module_count": 1,
"next_modules": ["work1_3"],
"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",
},
{
"active": true,
"name": "cifar10_3",
"path": "cifar10_wasm.so",
"port": 10013,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["work1_3"],
"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",
},
{
"active": true,
"name": "work1_3",
"path": "work3_wasm.so",
"port": 10014,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"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",
},
{
"active": true,
"name": "resize1_4",
"path": "resize_wasm.so",
"port": 10015,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 1,
"pre_module_count": 0,
"next_modules": ["png2bmp1_4", "lpd_wasm1_4"],
"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_4",
"path": "C-Image-Manip_wasm.so",
"port": 10016,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["cifar10_4"],
"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_4",
"path": "lpd_wasm.so",
"port": 10017,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 2,
"pre_module_count": 1,
"next_modules": ["work1_4"],
"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",
},
{
"active": true,
"name": "cifar10_4",
"path": "cifar10_wasm.so",
"port": 10018,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"argsize": 1,
"priority": 1,
"pre_module_count": 1,
"next_modules": ["work1_4"],
"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",
},
{
"active": true,
"name": "work1_4",
"path": "work3_wasm.so",
"port": 10019,
"relative-deadline-us": 16346,
"reg-prediction": [3,60],
"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",
}

@ -0,0 +1,26 @@
Runtime Environment:
CPU Speed: 2500 MHz
Processor Speed: 2500 MHz
RLIMIT_DATA: Infinite
RLIMIT_NOFILE: 1048576
Core Count: 8
Listener core ID: 1
First Worker core ID: 2
Worker core count: 5
Scheduler Policy: SRSF
Sigalrm Policy: TRIAGED
Preemption: Enabled
Quantum: 5000 us
Sandbox Performance Log: /home/hai/sledge/sledge/runtime/tests/runtime_sandbox_perf_log.log
Starting listener thread
Listener core thread: 7ffff7a006c0
Starting 5 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
C: 06, T: 0x7fffafc006c0, F: current_sandbox_start>
C: 04, T: 0x7ffff5c006c0, F: current_sandbox_start>
Loading…
Cancel
Save