Skip to content

Commit 6b0ba99

Browse files
authored
feature: added SJF scheduler and Regression based prediction (#385)
* feature: added SJF scheduler added REGRESSION based prediction support * fix: error handling * fixed the default values for def.server when not given * fix: replace GET by POST for hey requests (fix by Xioasu) * - update .clang-format props to match composite (almost) - reformat C codes in the repo - refactor the format.sh script - fetch latest AWSM master * Addressed Gabe's comments * error handling for when model_scale and model_beta2 is zero * fix the multi-tenantcy-predictions run.sh script * - upgraded to LLVM_VERSION=13 both on sledge & AWSM - updated dockerfile, main.yaml - added new uninstall_llvm.sh script to ease LLVM removal
1 parent 4ae8b02 commit 6b0ba99

File tree

142 files changed

+1419
-658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+1419
-658
lines changed

.clang-format

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
BasedOnStyle: Mozilla
32
IndentWidth: 8
43
Language: Cpp
@@ -10,10 +9,10 @@ AlignConsecutiveMacros: true
109
AlignEscapedNewlines: Left
1110
AlignTrailingComments: true
1211

13-
AllowShortBlocksOnASingleLine: true
12+
AllowShortBlocksOnASingleLine: Always
1413
AllowShortCaseLabelsOnASingleLine: false
1514
AllowShortFunctionsOnASingleLine: All
16-
AllowShortIfStatementsOnASingleLine: true
15+
AllowShortIfStatementsOnASingleLine: WithoutElse
1716
AllowShortLoopsOnASingleLine: true
1817

1918
AlwaysBreakAfterReturnType: AllDefinitions
@@ -38,7 +37,7 @@ BreakBeforeBinaryOperators: NonAssignment
3837

3938
ColumnLimit: 120
4039

41-
Cpp11BracedListStyle: false
40+
Cpp11BracedListStyle: true
4241

4342
IndentCaseLabels: false
4443
IndentWrappedFunctionNames: false
@@ -47,10 +46,9 @@ KeepEmptyLinesAtTheStartOfBlocks: false
4746

4847
MaxEmptyLinesToKeep: 2
4948

50-
DerivePointerAlignment: false
5149
PointerAlignment: Right
5250

53-
SortIncludes: false
51+
SortIncludes: true
5452

5553
SpaceAfterCStyleCast: false
5654
SpaceBeforeAssignmentOperators: true

.github/workflows/main.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request]
44

55
env:
66
LLVM_VERSION: 13
7-
WASI_SDK_URL: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
7+
WASI_SDK_VERSION: 12
88
WASI_SDK_PATH: /opt/wasi-sdk
99
LANG: C.UTF-8
1010
LANGUAGE: C.UTF-8
@@ -18,10 +18,10 @@ jobs:
1818
- name: Apt Update
1919
run: sudo apt-get update
2020
- uses: actions/checkout@v2
21-
- name: Install LLVM
21+
- name: Install Clang Format
2222
run: |
2323
sudo ./install_llvm.sh $LLVM_VERSION
24-
- name: Clang Format
24+
- name: Run Clang Format
2525
run: ./format.sh -d
2626
test:
2727
runs-on: ubuntu-20.04
@@ -62,6 +62,7 @@ jobs:
6262
echo "/root/.cargo/bin:$PATH" >> $GITHUB_PATH
6363
- name: Get wasi-sdk
6464
run: |
65+
WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk-$WASI_SDK_VERSION.0-linux.tar.gz
6566
wget $WASI_SDK_URL -O wasi-sdk.tar.gz
6667
mkdir -p $WASI_SDK_PATH
6768
tar xvfz wasi-sdk.tar.gz --strip-components=1 -C $WASI_SDK_PATH

.vscode/settings.json

+15-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"tenant.h": "c",
117117
"route_config.h": "c",
118118
"http_router.h": "c",
119-
"admissions_info.h": "c",
119+
"execution_histogram.h": "c",
120120
"tcp_server.h": "c",
121121
"stdint.h": "c",
122122
"scheduler_options.h": "c",
@@ -144,7 +144,20 @@
144144
"algorithm": "c",
145145
"stdio.h": "c",
146146
"get_time.h": "c",
147-
"unistd.h": "c"
147+
"unistd.h": "c",
148+
"wasi.h": "c",
149+
"stat.h": "c",
150+
"functional": "c",
151+
"sandbox_state.h": "c",
152+
"ratio": "c",
153+
"tuple": "c",
154+
"type_traits": "c",
155+
"perf_window.h": "c",
156+
"http_route_total.h": "c",
157+
"sledge_abi_symbols.h": "c",
158+
"mutex": "c",
159+
"lock.h": "c",
160+
"route_latency.h": "c"
148161
},
149162
"files.exclude": {
150163
"**/.git": true,

Dockerfile.x86_64

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# using ubuntu 20 docker image
22
FROM ubuntu:focal
33

4+
ENV LLVM_VERSION=13
5+
ENV WASI_SDK_VERSION=12
6+
47
ARG DEBIAN_FRONTEND=noninteractive
58
ARG HEY_URL=https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64
6-
ARG WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk_12.0_amd64.deb
9+
ARG WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb
710
ARG SHFMT_URL=https://github.com/mvdan/sh/releases/download/v3.2.4/shfmt_v3.2.4_linux_amd64
811
ARG SHELLCHECK_URL=https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz
912

@@ -74,12 +77,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
7477
vim \
7578
wabt
7679

77-
ENV LLVM_VERSION=12
7880
ADD install_llvm.sh /sledge/install_llvm.sh
7981
RUN ./sledge/install_llvm.sh $LLVM_VERSION
8082

8183
# WASI-SDK
82-
RUN curl -sS -L -O $WASI_SDK_URL && dpkg -i wasi-sdk_12.0_amd64.deb && rm -f wasi-sdk_12.0_amd64.deb
84+
RUN curl -sS -L -O $WASI_SDK_URL && dpkg -i wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb && rm -f wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb
8385
ENV WASI_SDK_PATH=/opt/wasi-sdk
8486

8587
# Create non-root user and add to sudoers

applications/Makefile

+5-6
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@ all: \
2727
license_plate_detection.install \
2828
resize_image.install \
2929
cnn_face_detection.install \
30-
scratch_storage_get.install \
31-
scratch_storage_set.install \
32-
scratch_storage_delete.install \
33-
scratch_storage_upsert.install \
30+
get_jpeg_resolution.install \
3431

3532
.PHONY: clean
3633
clean:
3734
@make -C wasm_apps clean
38-
@make -C scratch_storage clean
3935
@rm -rf dist
4036
@rm -rf ../runtime/bin/*.so
4137

@@ -69,7 +65,7 @@ dist/%.bc: ./wasm_apps/dist/%.wasm dist
6965
${AWSMCC} ${AWSMFLAGS} $< -o $@
7066

7167
dist/%.ll: dist/%.bc
72-
llvm-dis-12 $< -o $@
68+
llvm-dis $< -o $@
7369

7470
dist/%.wasm.so: dist/%.bc
7571
${CC} ${CFLAGS} ${LDFLAGS} $^ -o $@
@@ -109,6 +105,9 @@ license_plate_detection.install: ../runtime/bin/license_plate_detection.wasm.so
109105
.PHONY: cnn_face_detection.install
110106
cnn_face_detection.install: ../runtime/bin/cnn_face_detection.wasm.so
111107

108+
.PHONY: get_jpeg_resolution.install
109+
get_jpeg_resolution.install: ../runtime/bin/get_jpeg_resolution.wasm.so
110+
112111
.PHONY: trap_divzero.install
113112
trap_divzero.install: ../runtime/bin/trap_divzero.wasm.so
114113

awsm

Submodule awsm updated 70 files

format.sh

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22

3+
LLVM_VERSION=13
4+
35
validate() {
4-
utility="clang-format-13"
6+
utility="clang-format"
57
utility_version="$("$utility" --version 2> /dev/null)" || {
68
echo "$utility not found in path!"
79
exit 1
@@ -11,7 +13,7 @@ validate() {
1113
declare -i major=0
1214
declare -i minor=0
1315
declare -i patch=0
14-
declare -i required_major=13
16+
declare -i required_major=$LLVM_VERSION
1517
declare -i required_minor=0
1618
declare -i required_patch=0
1719

@@ -43,14 +45,14 @@ help() {
4345

4446
dry_run() {
4547
find runtime \
46-
\( -path "runtime/thirdparty" -o -path "applications/gocr" -o -path "applications/TinyEKF" -o -path "applications/CMSIS_5_NN" -o -path "applications/sod" -o -path "applications/**/thirdparty" \) -prune -false -o \
47-
-type f \( -iname \*.h -o -iname \*.c -o -iname \*.s \) -print \
48-
| xargs clang-format -Werror -n -ferror-limit=0
48+
\( -path "runtime/thirdparty" \) -prune -false -o \
49+
-type f \( -iname \*.h -o -iname \*.c -o -iname \*.s \) -print0 \
50+
| xargs --null clang-format -Werror -n -ferror-limit=1
4951
}
5052

5153
format() {
5254
find runtime \
53-
\( -path "runtime/thirdparty" -o -path "applications/gocr" -o -path "applications/TinyEKF" -o -path "applications/CMSIS_5_NN" -o -path "applications/sod" -o -path "applications/**/thirdparty" \) -prune -false -o \
55+
\( -path "runtime/thirdparty" \) -prune -false -o \
5456
-type f \( -iname \*.h -o -iname \*.c -o -iname \*.s \) -print0 \
5557
| xargs --null clang-format -i
5658
}

install_deb.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#!/bin/bash
22

3-
LLVM_VERSION=12
3+
# Note, wasi-sdk versions do NOT match llvm versions, e.g. wasi-sdk-12 actually uses llvm-11
4+
LLVM_VERSION=13
5+
WASI_SDK_VERSION=12
46

57
ARCH=$(uname -m)
68

79
if [[ $ARCH = "x86_64" ]]; then
810
SHFMT_URL=https://github.com/mvdan/sh/releases/download/v3.4.3/shfmt_v3.4.3_linux_amd64
9-
WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk_12.0_amd64.deb
11+
WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb
1012
elif [[ $ARCH = "aarch64" ]]; then
1113
SHFMT_URL=https://github.com/patrickvane/shfmt/releases/download/master/shfmt_linux_arm
1214
echo "ARM64 support is still a work in progress!"
@@ -64,7 +66,7 @@ wget $SHFMT_URL -O shfmt && chmod +x shfmt && sudo mv shfmt /usr/local/bin/shfmt
6466

6567
sudo ./install_llvm.sh $LLVM_VERSION
6668

67-
curl -sS -L -O $WASI_SDK_URL && sudo dpkg -i wasi-sdk_12.0_amd64.deb && rm -f wasi-sdk_12.0_amd64.deb
69+
curl -sS -L -O $WASI_SDK_URL && sudo dpkg -i wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb && rm -f wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb
6870

6971
if [ -z "${WASI_SDK_PATH}" ]; then
7072
export WASI_SDK_PATH=/opt/wasi-sdk

install_llvm.sh

+13-13
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ echo "Installing LLVM $LLVM_VERSION"
88
# Script Installs clang, lldb, lld, and clangd
99
curl --proto '=https' --tlsv1.2 -sSf https://apt.llvm.org/llvm.sh | bash -s -- "$LLVM_VERSION"
1010

11+
# Installing "libc++-xx-dev" automagically installs "libc++1-xx", "libunwind-xx" and "libunwind-xx-dev"
1112
apt-get install -y --no-install-recommends \
1213
"libc++-$LLVM_VERSION-dev" \
1314
"libc++abi-$LLVM_VERSION-dev" \
14-
"libc++1-$LLVM_VERSION" \
15-
"libunwind-$LLVM_VERSION" \
16-
"libunwind-$LLVM_VERSION-dev" \
1715
"clang-tools-$LLVM_VERSION" \
1816
"clang-tidy-$LLVM_VERSION" \
1917
"clang-format-$LLVM_VERSION"
2018

21-
sudo update-alternatives --remove-all clang-format
22-
sudo update-alternatives --remove-all clang
23-
sudo update-alternatives --remove-all clang++
24-
sudo update-alternatives --remove-all llvm-config
25-
sudo update-alternatives --remove-all llvm-objdump
26-
sudo update-alternatives --remove-all llvm-objdump
27-
sudo update-alternatives --remove-all clang-tidy
19+
update-alternatives --remove-all wasm-ld
20+
update-alternatives --remove-all llvm-config
21+
update-alternatives --remove-all llvm-objdump
22+
update-alternatives --remove-all llvm-dis
23+
update-alternatives --remove-all clang-format
24+
update-alternatives --remove-all clang
25+
update-alternatives --remove-all clang++
26+
update-alternatives --remove-all clang-tidy
2827

28+
update-alternatives --install /usr/bin/wasm-ld wasm-ld "/usr/bin/wasm-ld-$LLVM_VERSION" 100
29+
update-alternatives --install /usr/bin/llvm-config llvm-config "/usr/bin/llvm-config-$LLVM_VERSION" 100
30+
update-alternatives --install /usr/bin/llvm-objdump llvm-objdump "/usr/bin/llvm-objdump-$LLVM_VERSION" 100
31+
update-alternatives --install /usr/bin/llvm-dis llvm-dis /usr/bin/llvm-dis-$LLVM_VERSION 100
2932
update-alternatives --install /usr/bin/clang-format clang-format "/usr/bin/clang-format-$LLVM_VERSION" 100
3033
update-alternatives --install /usr/bin/clang clang "/usr/bin/clang-$LLVM_VERSION" 100
3134
update-alternatives --install /usr/bin/clang++ clang++ "/usr/bin/clang++-$LLVM_VERSION" 100
32-
update-alternatives --install /usr/bin/llvm-config llvm-config "/usr/bin/llvm-config-$LLVM_VERSION" 100
33-
update-alternatives --install /usr/bin/llvm-objdump llvm-objdump "/usr/bin/llvm-objdump-$LLVM_VERSION" 100
3435
update-alternatives --install /usr/bin/clang-tidy clang-tidy "/usr/bin/clang-tidy-$LLVM_VERSION" 100
35-
update-alternatives --install /usr/bin/wasm-ld wasm-ld "/usr/bin/wasm-ld-$LLVM_VERSION" 100

runtime/Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ BINARY_NAME=sledgert
3838

3939

4040
# Feature Toggles
41+
CFLAGS += -DEXECUTION_HISTOGRAM
42+
# CFLAGS += -DEXECUTION_REGRESSION
43+
44+
# It is recommended (not mandatory) to enable this flag along with the EXECUTION_HISTOGRAM flag:
4145
# CFLAGS += -DADMISSIONS_CONTROL
4246

4347
# Debugging Flags
@@ -56,6 +60,7 @@ BINARY_NAME=sledgert
5660
# CFLAGS += -DLOG_TO_FILE
5761

5862
# Various Informational Logs for Debugging
63+
# CFLAGS += -DLOG_EXECUTION_HISTOGRAM
5964
# CFLAGS += -DLOG_ADMISSIONS_CONTROL
6065
# CFLAGS += -DLOG_CONTEXT_SWITCHES
6166
# CFLAGS += -DLOG_HTTP_PARSER

runtime/include/admissions_control.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#pragma once
22

3+
#ifdef ADMISSIONS_CONTROL
4+
35
#include <stdbool.h>
46
#include <stdint.h>
57

6-
#ifdef ADMISSIONS_CONTROL
78
#define ADMISSIONS_CONTROL_GRANULARITY 1000000
89
extern _Atomic uint64_t admissions_control_admitted;
910
extern uint64_t admissions_control_capacity;
10-
#endif
1111

1212
void admissions_control_initialize(void);
1313
void admissions_control_add(uint64_t admissions_estimate);
1414
void admissions_control_subtract(uint64_t admissions_estimate);
1515
uint64_t admissions_control_calculate_estimate(uint64_t estimated_execution, uint64_t relative_deadline);
16-
uint64_t admissions_control_calculate_estimate_us(uint32_t estimated_execution_us, uint32_t relative_deadline_us);
1716
void admissions_control_log_decision(uint64_t admissions_estimate, bool admitted);
1817
uint64_t admissions_control_decide(uint64_t admissions_estimate);
18+
19+
#endif

runtime/include/admissions_info.h

-15
This file was deleted.

runtime/include/arch/arch_context_t.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#include <setjmp.h>
44
#include <ucontext.h>
55

6+
#include "arch/arch_context_variant_t.h"
67
#include "arch/reg_t.h"
78
#include "arch/ureg_t.h"
8-
#include "arch/arch_context_variant_t.h"
99

1010
struct arch_context {
1111
arch_context_variant_t variant;

runtime/include/auto_buf.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include "likely.h"
34
#include <errno.h>
45
#include <stdio.h>
56
#include <stdlib.h>

0 commit comments

Comments
 (0)