├── Makefile ├── README.md ├── experiments ├── fig-06_nginx-redis-perm │ ├── Makefile │ ├── README.md │ ├── apps │ │ ├── nginx │ │ │ ├── build.sh │ │ │ ├── nginx.cpio │ │ │ ├── permutations-3.csv │ │ │ ├── plot.py │ │ │ ├── templates │ │ │ │ ├── kraft │ │ │ │ │ ├── data.yaml │ │ │ │ │ └── template.yaml │ │ │ │ └── wayfinder │ │ │ │ │ ├── data.yaml │ │ │ │ │ └── template.yaml │ │ │ ├── test.sh │ │ │ └── wayfinder-jobs │ │ │ │ ├── 1.yaml │ │ │ │ └── 3.yaml │ │ └── redis │ │ │ ├── build.sh │ │ │ ├── permutations-3.csv │ │ │ ├── plot.py │ │ │ ├── redis.cpio │ │ │ ├── templates │ │ │ ├── kraft │ │ │ │ ├── data.yaml │ │ │ │ └── template.yaml │ │ │ └── wayfinder │ │ │ │ ├── data.yaml │ │ │ │ └── template.yaml │ │ │ ├── test.sh │ │ │ └── wayfinder-jobs │ │ │ └── 3.yaml │ ├── fig-06_nginx-redis-perm-nginx.svg │ ├── fig-06_nginx-redis-perm-redis.svg │ ├── paperresults │ │ ├── nginx.csv │ │ └── redis.csv │ └── support │ │ └── qemu-guest ├── fig-07_nginx-redis-normalized │ ├── Makefile │ ├── README.md │ ├── fig-07_nginx-redis-normalized.svg │ └── plot_scatter.py ├── fig-08_config-poset │ ├── Makefile │ ├── README.md │ ├── additional-resources │ │ ├── detailed-view.pdf │ │ └── raw-data.ods │ ├── fig-08_config-poset.svg │ ├── plot.sh │ └── poset.dot ├── fig-09_iperf-throughput │ ├── Makefile │ ├── README.md │ ├── docker-data │ │ ├── build-images.sh │ │ ├── configs │ │ │ ├── iperf-flexos-ept2.config │ │ │ ├── iperf-flexos-fcalls.config │ │ │ ├── iperf-flexos-mpk2.config │ │ │ ├── iperf-unikraft.config │ │ │ ├── kraft.yaml.ept2 │ │ │ └── kraft.yaml.fcalls │ │ ├── flexos-net.patch │ │ ├── run.sh │ │ ├── start-scripts │ │ │ ├── kvmflexos-start.sh │ │ │ └── kvmflexosept2-start.sh │ │ └── unikraft-pagetable.patch │ ├── fig-09_iperf-throughput.svg │ ├── flexos-iperf.dockerfile │ ├── iperf.plot │ └── results │ │ └── iperf.dat ├── fig-10_sqlite-exec-time │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── docker-data │ │ ├── Makefile │ │ ├── configs │ │ │ ├── genode.conf │ │ │ ├── kraft.yaml.ept2 │ │ │ ├── kraft.yaml.fcalls │ │ │ ├── kraft.yaml.mpk3 │ │ │ ├── sqlite-flexos-ept2.config │ │ │ ├── sqlite-flexos-fcalls.config │ │ │ ├── sqlite-flexos-mpk3.config │ │ │ ├── sqlite-kvm.config │ │ │ └── sqlite-linuxu.config │ │ ├── include │ │ │ ├── sqlite3.h │ │ │ └── sqlite3ext.h │ │ ├── main.c │ │ ├── patches │ │ │ ├── cpio-patches │ │ │ │ ├── 01.patch │ │ │ │ ├── 02.patch │ │ │ │ ├── 03.patch │ │ │ │ ├── 04.patch │ │ │ │ └── 05.patch │ │ │ ├── cubicleos.diff │ │ │ ├── flexos-ept2.diff │ │ │ └── flexos-ept2.diff.2 │ │ ├── run.sh │ │ ├── sqlite.cpio │ │ └── start-scripts │ │ │ ├── kvm-start.sh │ │ │ ├── kvmflexosept2-start.sh │ │ │ ├── kvmflexosfcalls-start.sh │ │ │ ├── kvmflexosmpk3-start.sh │ │ │ ├── linuxu-start.sh │ │ │ └── process-start.sh │ ├── fig-10_sqlite-exec-time.svg │ ├── flexos-sqlite.dockerfile │ ├── results │ │ └── sqlite.dat │ └── sqlite.plot ├── fig-11_flexos-alloc-latency │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── docker-data │ │ ├── configs │ │ │ ├── kraft.yaml.ept2 │ │ │ ├── kraft.yaml.mpk2 │ │ │ ├── microbenchmarks-flexos-ept2.config │ │ │ └── microbenchmarks-flexos-mpk2.config │ │ ├── run.sh │ │ └── start-scripts │ │ │ ├── kvmflexos-start.sh │ │ │ └── kvmflexosept2-start.sh │ ├── dss.plot │ ├── fig-11_flexos-alloc-latency-a.svg │ ├── fig-11_flexos-alloc-latency-b.svg │ ├── flexos-microbenchmarks.dockerfile │ ├── latency.plot │ ├── results │ │ ├── dss.dat │ │ └── latency.dat │ ├── toggle-kpti.sh │ └── tools │ │ └── benchmark_linux.sh └── tab-01_porting-effort │ ├── Makefile │ ├── README.md │ ├── flexos-porting.dockerfile │ └── lwip-patches │ ├── 0001-include-sockets.patch │ └── 0002-melt-sockets.patch └── support ├── 0001-Myshmem.patch ├── dockerfiles ├── Dockerfile.flexos-ae-base ├── Dockerfile.flexos-ae-plot ├── Dockerfile.flexos-base ├── Dockerfile.nginx └── Dockerfile.redis ├── ept2-tmpfix.patch ├── img.cpio ├── kraftcleanup ├── kraftrc.default ├── kraftrc.nginx └── kraftrc.redis /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Directories 3 | # 4 | WORKDIR ?= $(CURDIR) 5 | 6 | # 7 | # Parameters 8 | # 9 | KRAFT_TOKEN ?= 10 | 11 | # 12 | # General configuration 13 | # 14 | REG ?= ghcr.io 15 | ORG ?= project-flexos 16 | EXPS ?= fig-06_nginx-redis-perm \ 17 | fig-07_nginx-redis-normalized \ 18 | fig-08_config-poset \ 19 | fig-09_iperf-throughput \ 20 | fig-10_sqlite-exec-time \ 21 | fig-11_flexos-alloc-latency \ 22 | tab-01_porting-effort 23 | IMAGES ?= flexos-base \ 24 | nginx \ 25 | redis \ 26 | flexos-ae-plot \ 27 | flexos-ae-base 28 | TARGETS ?= prepare \ 29 | run \ 30 | plot \ 31 | clean \ 32 | properclean 33 | 34 | ifeq ($(KRAFT_TOKEN),) 35 | define ERROR_MISSING_TOKEN 36 | 37 | 38 | Missing `KRAFT_TOKEN` environmental variable 39 | 40 | This variable is used to connect the command-line utility `kraft` to the GitHub 41 | API and download additional Unikraft repositories. To generate a new token, 42 | go to https://github.com/settings/tokens/new and select permission: 43 | 44 | - repo:public_repo 45 | 46 | Once you have generated this token, simply export it in your command-line, like 47 | so: 48 | 49 | $$ export KRAFT_TOKEN=ghp_... 50 | 51 | Once this is done, please re-run your command: 52 | 53 | $$ $(MAKE) $(MAKECMDGOALS) 54 | 55 | 56 | endef 57 | $(error $(ERROR_MISSING_TOKEN)) 58 | endif 59 | 60 | # 61 | # Utility vars 62 | # 63 | # Prefix each docker image with `docker-` so it has a unique phony target 64 | DIMAGES := $(addprefix docker-,$(IMAGES)) 65 | Q ?= @ 66 | 67 | # 68 | # Tools 69 | # 70 | DOCKER ?= docker 71 | CURL ?= curl 72 | 73 | # 74 | # Find shortname for experiment 75 | # 76 | # Params: 77 | # $1: The canonical name of the experiment, e.g. `fig-XX_short-desc` 78 | # $2: The desired returning element, 1 for `fig-XX` and 2 for `short-desc` 79 | # 80 | underscore = $(word $(2),$(subst _, ,$(1))) 81 | 82 | # 83 | # Create a new experiment target 84 | # 85 | # Params: 86 | # $1: The common API target, e.g. `prepare` 87 | # $2: The canonical name of the experiment, e.g. `fig-XX_short-name` 88 | # 89 | define create-exp-target 90 | .PHONY: $(1) 91 | $(1): $(1)-$(2) 92 | 93 | .PHONY: $(2) 94 | $(2): $(1) 95 | 96 | .PHONY: $(1)-$(2) 97 | $$(call underscore,$(2),1): $(1)-$(2) 98 | $(1)-$$(call underscore,$(2),1): $(1)-$(2) 99 | $(1)-$(2): 100 | $(Q)$(MAKE) -C $(WORKDIR)/experiments/$(2) $(1) 101 | endef 102 | 103 | # 104 | # Targets 105 | # 106 | .PHONY: all 107 | all: prepare run plot 108 | 109 | .PHONY: prepare 110 | prepare: docker 111 | 112 | # Iterate over all experiments and all targets and provide an entrypoint for 113 | # each, e.g. `prepare-fig-XX_short-desc` and `prepare-fig-XX`. 114 | $(foreach EXP,$(EXPS), \ 115 | $(foreach TARGET,$(TARGETS),$(eval $(call create-exp-target,$(TARGET),$(EXP))) \ 116 | )) 117 | 118 | .PHONY: docker 119 | docker: $(DIMAGES) 120 | 121 | .PHONY: $(DIMAGES) 122 | $(DIMAGES): TAG ?= latest 123 | $(DIMAGES): 124 | $(Q)$(DOCKER) build \ 125 | --tag $(REG)/$(ORG)/$(@:docker-%=%):$(TAG) \ 126 | --build-arg UK_KRAFT_GITHUB_TOKEN="$(KRAFT_TOKEN)" \ 127 | --file $(WORKDIR)/support/dockerfiles/Dockerfile.$(@:docker-%=%) \ 128 | $(WORKDIR)/support 129 | 130 | # Prepare the final Zenodo archive 131 | zenodo: 132 | mkdir -p $(WORKDIR)/repositories 133 | # clone all repos in the flexos organization 134 | cd $(WORKDIR)/repositories && \ 135 | $(CURL) -s https://github.com:@api.github.com/orgs/${ORG}/repos?per_page=200 | \ 136 | jq .[].ssh_url | xargs -n 1 git clone 137 | # remove this one otherwise we'd be duplicate 138 | rm -rf repositories/asplos22-ae 139 | tar -czf $(WORKDIR)/../flexos-asplos22-ae.tar.gz $(WORKDIR) 140 | 141 | dependencies: docker 142 | apt install time jq 143 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Files and directories 3 | # 4 | REG ?= ghcr.io 5 | ORG ?= project-flexos 6 | WORKDIR ?= $(CURDIR) 7 | RESULTSDIR ?= $(WORKDIR)/results 8 | TMPDIR ?= /tmp/$(notdir $(WORKDIR)) 9 | APPSDIR ?= $(WORKDIR)/apps 10 | PLOT_FORMAT ?= svg 11 | PLOT ?= $(WORKDIR)/$(notdir $(WORKDIR)).$(PLOT_FORMAT) 12 | TAG ?= latest 13 | Q ?= @ 14 | 15 | # 16 | # Experiment variables 17 | # 18 | WAYFINDER_CORES ?= 1,2 19 | HOST_CORES ?= 3,4 20 | APPS ?= nginx redis 21 | NUM_COMPARTMENTS ?= 3 22 | TEST_ITERATIONS ?= 1 23 | 24 | # 25 | # Tools 26 | # 27 | SNAKE ?= python3 28 | WGET ?= wget 29 | APT ?= apt 30 | MKDIR ?= mkdir -p 31 | WAYFINDER ?= $(TMPDIR)/wayfinder/dist/wayfinder 32 | RM ?= rm 33 | TASKSET ?= taskset 34 | TOTALCPUS ?= $(lscpu | grep '^CPU(s):' | awk '{ print $$2 }') 35 | YTT ?= ytt 36 | # Tools 37 | DOCKER ?= docker 38 | DOCKER_RUN ?= $(DOCKER) run --rm $(2) \ 39 | $(foreach E, $(shell printenv), -e "$(E)") \ 40 | --entrypoint "" \ 41 | -w $(WORKDIR) \ 42 | -v $(WORKDIR):$(WORKDIR) \ 43 | $(REG)/$(ORG)/$(1):$(TAG) \ 44 | $(3) 45 | CAT ?= cat 46 | JQ ?= jq 47 | GCC ?= gcc 48 | GIT ?= git 49 | 50 | # 51 | # Targets 52 | # 53 | .PHONY: all 54 | all: prepare run plot 55 | 56 | .PHONY: prepare 57 | prepare: install-wayfinder 58 | prepare: install-deps 59 | prepare: prepare-templates 60 | 61 | .PHONY: install-deps 62 | install-deps: 63 | $(APT) update 64 | $(APT) install --no-install-recommends \ 65 | bridge-utils \ 66 | net-tools \ 67 | socat \ 68 | uuid-runtime \ 69 | wrk \ 70 | redis-tools \ 71 | jq 72 | 73 | # If run with DOCKER= or within a container, unset DOCKER_RUN so all commands 74 | # are not proxied via docker container. 75 | ifeq ($(DOCKER),) 76 | DOCKER_RUN := 77 | else ifneq ($(wildcard /.dockerenv),) 78 | DOCKER_RUN := 79 | endif 80 | .DOCKER_PROXY := 81 | ifneq ($(DOCKER_RUN),) 82 | .DOCKER_PROXY := docker-proxy- 83 | prepare-wayfinder-app-%: 84 | $(info Running target via $(REG)/$(ORG)/flexos-base:$(TAG)...) 85 | $(Q)$(call DOCKER_RUN,flexos-base,,$(MAKE) $@) 86 | plot-app-%: 87 | $(info Running target via $(REG)/$(ORG)/flexos-ae-plot:$(TAG)...) 88 | $(Q)$(call DOCKER_RUN,flexos-ae-plot,,$(MAKE) $@) 89 | endif 90 | 91 | # 92 | # Create preparation step for an application 93 | # 94 | # Params: 95 | # $1: The application name 96 | # 97 | define prepare-wayfinder-app 98 | 99 | # This is an entry which is used to generate a job file to be used by Wayfinder. 100 | # The job file creates all the possible permutations which will result in a 101 | # unique unikernel binary image. 102 | .PHONY: $$(.DOCKER_PROXY)prepare-wayfinder-app-$(1) 103 | $$(.DOCKER_PROXY)prepare-wayfinder-app-$(1): $$(APPSDIR)/$(1)/wayfinder-jobs/$$(NUM_COMPARTMENTS).yaml 104 | $$(APPSDIR)/$(1)/wayfinder-jobs/$$(NUM_COMPARTMENTS).yaml: 105 | $$(YTT) \ 106 | --data-value num_compartments=$$(NUM_COMPARTMENTS) \ 107 | --file $$(APPSDIR)/$(1)/templates/wayfinder > $$(APPSDIR)/$(1)/wayfinder-jobs/$$(NUM_COMPARTMENTS).yaml 108 | 109 | # Make the general preparation step have these dynamic entries as dependents 110 | prepare-templates: prepare-wayfinder-app-$(1) 111 | 112 | # Make the general run step have these dynamic entries as dependents 113 | run-wayfinder: run-wayfinder-app-$(1) test-app-$(1) 114 | 115 | # This is an entry which is used to create a unique run-entry for the app, 116 | # allowing you to run a specific application (and thus its permutations). We 117 | # set the working directory (-w) on wayfinder within the /tmp folder, as this 118 | # will significantly speed up builds. Please ensure you have enough RAM or 119 | # set an alternative path via: 120 | # 121 | # $ make TMPDIR=/path/to/dir run-wayfinder 122 | # 123 | # Also, cores have been hard-coded, please adjust according to your machine, and 124 | # again, set accordingly, e.g.: 125 | # 126 | # $ make HOST_CORES="3,12,24" run-wayfinder 127 | # 128 | .PHONY: run-wayfinder-app-$(1) 129 | run-wayfinder-app-$(1): 130 | ifeq ($$(WAYFINDER_CORES),) 131 | $$(WAYFINDER) -v run \ 132 | --cpu-sets $$(HOST_CORES) \ 133 | -w $$(TMPDIR)/wayfinder-build-$(1)/ \ 134 | $$(APPSDIR)/$(1)/wayfinder-jobs/$$(NUM_COMPARTMENTS).yaml 135 | else 136 | $$(TASKSET) -c $$(WAYFINDER_CORES) \ 137 | $$(WAYFINDER) -v run \ 138 | --cpu-sets $$(HOST_CORES) \ 139 | -w $$(TMPDIR)/wayfinder-build-$(1)/ \ 140 | $$(APPSDIR)/$(1)/wayfinder-jobs/$$(NUM_COMPARTMENTS).yaml 141 | endif 142 | 143 | # Target to run the test script on all permutations 144 | .PHONY: test-app-$(1) 145 | test-app-$(1): $$(RESULTSDIR) 146 | test-app-$(1): RESULTS ?= $$(RESULTSDIR)/$(1).csv 147 | test-app-$(1): UNIKERNEL_INITRD ?= $$(APPSDIR)/$(1)/$(1).cpio 148 | test-app-$(1): 149 | ITERATIONS=$$(TEST_ITERATIONS) \ 150 | RESULTS=$$(RESULTS) \ 151 | UNIKERNEL_INITRD=$$(UNIKERNEL_INITRD) \ 152 | $$(APPSDIR)/$(1)/test.sh $$(TMPDIR)/wayfinder-build-$(1)/results 153 | 154 | # Create the list of permutations file 155 | plot: $$(APPSDIR)/$(1)/permutations-$$(NUM_COMPARTMENTS).csv 156 | plot: plot-app-$(1) 157 | $$(APPSDIR)/$(1)/permutations-$$(NUM_COMPARTMENTS).csv: 158 | $$(CAT) $$(TMPDIR)/wayfinder-build-$(1)/results/tasks.json | \ 159 | $$(JQ) -r '(["TASKID"] + keys[0] as $$$$k | .[$$$$k] | keys_unsorted) as $$$$cols | to_entries | map([.key, .value[]]) as $$$$rows | $$$$cols,$$$$rows[] | @csv' > \ 160 | $$@ 161 | 162 | # Create a plot entrypoint for the app 163 | .PHONY: $$(.DOCKER_PROXY)plot-app-$(1) 164 | $$(.DOCKER_PROXY)plot-app-$(1): 165 | $$(SNAKE) $$(APPSDIR)/$(1)/plot.py \ 166 | $$(APPSDIR)/$(1)/permutations-$$(NUM_COMPARTMENTS).csv \ 167 | $$(RESULTSDIR)/$(1).csv \ 168 | $$(WORKDIR)/$$(notdir $$(WORKDIR))-$(1).$$(PLOT_FORMAT) 169 | 170 | # Probide a target to clean up the experiment 171 | .PHONY: properclean-wayfinder-app-$(1) 172 | properclean: properclean-wayfinder-app-$(1) 173 | properclean-wayfinder-app-$(1): 174 | $$(RM) -r $$(TMPDIR)/wayfinder-build-$(1)/ 175 | 176 | endef 177 | 178 | $(foreach APP,$(APPS), \ 179 | $(eval $(call prepare-wayfinder-app,$(APP))) \ 180 | ) 181 | 182 | .PHONY: install-wayfinder 183 | install-wayfinder: $(TMPDIR) 184 | install-wayfinder: WAYFINDER_VERSION=0.1.0 185 | install-wayfinder: $(WAYFINDER) 186 | 187 | $(WAYFINDER): $(TMPDIR)/wayfinder 188 | $(MAKE) -C $(TMPDIR)/wayfinder container 189 | $(MAKE) -C $(TMPDIR)/wayfinder build 190 | 191 | $(TMPDIR)/wayfinder: 192 | $(GIT) clone --branch v$(WAYFINDER_VERSION) https://github.com/lancs-net/wayfinder.git $(TMPDIR)/wayfinder 193 | 194 | $(TMPDIR): 195 | $(MKDIR) $@ 196 | 197 | $(RESULTSDIR): 198 | $(MKDIR) $@ 199 | 200 | .PHONY: run 201 | run: run-wayfinder 202 | 203 | .PHONY: run-wayfinder 204 | run-wayfinder: WAYFINDER_CORES="1,2" 205 | run-wayfinder: 206 | $(TASKSET) -c $(WAYFINDER_CORES) $(WAYFINDER) 207 | 208 | .PHONY: plot 209 | plot: 210 | 211 | .PHONY: clean 212 | clean: 213 | @- 214 | 215 | .PHONY: properclean 216 | properclean: 217 | $(RM) -f $(TMPDIR) 218 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/nginx/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Just ensure the environment is OK for kraft 4 | export UK_WORKDIR=/usr/src/unikraft 5 | export UK_CACHEDIR=/usr/src/unikraft/.kraftcache 6 | export KRAFTRC=/usr/src/unikraft/.kraftrc 7 | export LC_ALL=C.UTF-8 8 | export LANG=C.UTF-8 9 | for env in $(cat /etc/environment); do \ 10 | export $(echo $env | sed -e 's/"//g'); \ 11 | done 12 | 13 | NUM_COMPARTMENTS=${NUM_COMPARTMENTS:-1} 14 | TEMPLDIR=${TEMPLDIR:-/kraft-yaml-template} 15 | TEMPDIR=$(mktemp -d) 16 | 17 | cp -rfv $TEMPLDIR/* $TEMPDIR 18 | 19 | KRAFT_BUILD_EXTRA=() 20 | KRAFT_BUILD_EXTRA+=(V=1) 21 | USE_UBSAN=n 22 | USE_KASAN=n 23 | USE_SP=n 24 | 25 | SFI_FLAGS='"-fsanitize=undefined -fsanitize=kernel-address -fstack-protector-all -mstack-protector-guard=global"' 26 | 27 | for ENV in $(env); do 28 | # Iterate over unique libs 29 | if [[ "${ENV:0:3}" != "LIB" ]]; then continue; fi 30 | LIB=${ENV%=*} 31 | if [ "${LIB: -12}" != "_COMPARTMENT" ]; then continue; fi 32 | 33 | LIB=${LIB%_COMPARTMENT*} 34 | COMPARTMENT="${LIB}_COMPARTMENT" 35 | cat << EOF >> ${TEMPDIR}/data.yaml 36 | ${LIB}: ${!COMPARTMENT} 37 | EOF 38 | 39 | USE_SFI="${LIB}_SFI" 40 | if [[ "${!USE_SFI}" == "y" ]]; then 41 | USE_UBSAN=y 42 | USE_KASAN=y 43 | USE_UKSP=y 44 | 45 | if [[ "${LIB}" == "LIBNEWLIB" ]]; then 46 | KRAFT_BUILD_EXTRA+=(LIBNEWLIB_CFLAGS_EXTRA="${SFI_FLAGS}") 47 | elif [[ "${LIB}" == "LIBUKSCHED" ]]; then 48 | KRAFT_BUILD_EXTRA+=(LIBUKSCHED_CFLAGS="${SFI_FLAGS}") 49 | KRAFT_BUILD_EXTRA+=(LIBUKSCHEDCOOP_CFLAGS="${SFI_FLAGS}") 50 | # elif [[ "${LIB}" == "LIBREDIS" ]]; then 51 | # KRAFT_BUILD_EXTRA+=(LIBREDIS_LUA_CFLAGS_EXTRA="${SFI_FLAGS}") 52 | # KRAFT_BUILD_EXTRA+=(LIBREDIS_HIREDIS_CFLAGS_EXTRA="${SFI_FLAGS}") 53 | # KRAFT_BUILD_EXTRA+=(LIBREDIS_COMMON_CFLAGS_EXTRA="${SFI_FLAGS}") 54 | # KRAFT_BUILD_EXTRA+=(LIBREDIS_SERVER_CFLAGS_EXTRA="${SFI_FLAGS}") 55 | # KRAFT_BUILD_EXTRA+=(LIBREDIS_CLIENT_CFLAGS_EXTRA="${SFI_FLAGS}") 56 | else 57 | KRAFT_BUILD_EXTRA+=(${LIB}_CFLAGS_EXTRA="${SFI_FLAGS}") 58 | fi 59 | fi 60 | done 61 | 62 | echo "compartments:" >> ${TEMPDIR}/data.yaml 63 | 64 | for ((I=1; I<=$NUM_COMPARTMENTS; I++)); do 65 | DEFAULT="false" 66 | if [[ "${I}" == "1" ]]; then 67 | DEFAULT="true" 68 | fi 69 | 70 | COMPARTMENT_DRIVER="COMPARTMENT${I}_DRIVER" 71 | COMPARTMENT_ISOLSTACK="COMPARTMENT${I}_ISOLSTACK" 72 | 73 | cat << EOF >> ${TEMPDIR}/data.yaml 74 | - name: comp${I} 75 | mechanism: 76 | driver: ${!COMPARTMENT_DRIVER} 77 | noisolstack: ${!COMPARTMENT_ISOLSTACK} 78 | default: ${DEFAULT} 79 | EOF 80 | done 81 | 82 | ytt \ 83 | --data-value num_compartments=$NUM_COMPARTMENTS \ 84 | --file ${TEMPDIR} > /usr/src/unikraft/apps/nginx/kraft.yaml 85 | 86 | cd /usr/src/unikraft/apps/nginx/ 87 | 88 | KRAFT_CONFIGURE_EXTRA=() 89 | if [[ "${USE_UBSAN}" == "y" ]]; then 90 | KRAFT_CONFIGURE_EXTRA+=(--yes LIBUBSAN) 91 | fi 92 | if [[ "${USE_KASAN}" == "y" ]]; then 93 | KRAFT_CONFIGURE_EXTRA+=(--yes LIBKASAN) 94 | fi 95 | if [[ "${USE_UKSP}" == "y" ]]; then 96 | KRAFT_CONFIGURE_EXTRA+=(--yes LIBUKSP) 97 | fi 98 | 99 | set -xe 100 | 101 | kraft -v configure -F "${KRAFT_CONFIGURE_EXTRA[@]}" |& tee build.log 102 | 103 | cp .config config 104 | echo "# Extra from build.sh" >> config 105 | echo "# configure params:" >> config 106 | echo "# ${KRAFT_CONFIGURE_EXTRA[@]}" >> config 107 | echo "# build params:" >> config 108 | echo "# ${KRAFT_BUILD_EXTRA[@]}" >> config 109 | 110 | kraft -v build \ 111 | --fast \ 112 | --no-progress \ 113 | --compartmentalize \ 114 | "${KRAFT_BUILD_EXTRA[@]}" |& tee -a build.log 115 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/nginx/templates/kraft/data.yaml: -------------------------------------------------------------------------------- 1 | #@data/values 2 | --- 3 | num_compartments: 2 4 | 5 | libraries: 6 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/nginx/templates/kraft/template.yaml: -------------------------------------------------------------------------------- 1 | #@ load("@ytt:data", "data") 2 | #@ load("@ytt:assert", "assert") 3 | #! 4 | #@ compartments = data.values.compartments or \ 5 | #@ assert.fail("compartments must be specified") 6 | #@ libraries = data.values.libraries or \ 7 | #@ assert.fail("libraries must be specified") 8 | #! 9 | #@yaml/text-templated-strings 10 | --- 11 | specification: '0.6' 12 | name: nginx 13 | unikraft: 14 | version: staging 15 | kconfig: 16 | - CONFIG_LIBDEVFS=y 17 | - CONFIG_LIBCPIO=y 18 | - CONFIG_LIBINITRAMFS=y 19 | - CONFIG_LIBDEVFS_AUTOMOUNT=y 20 | - CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y 21 | - CONFIG_LIBVFSCORE_ROOTFS_RAMFS=y 22 | - CONFIG_OPTIMIZE_PERF=y 23 | - CONFIG_LIBUK9P=n 24 | - CONFIG_LIB9PFS=n 25 | - CONFIG_LIBDEVFS=y 26 | - CONFIG_LIBDEVFS_AUTOMOUNT=y 27 | - CONFIG_LIBUKLIBPARAM=y 28 | - CONFIG_LIBUKDEBUG=y 29 | - CONFIG_LIBUKALLOC=y 30 | - CONFIG_LIBUKSCHED=y 31 | - CONFIG_LIBPOSIX_SYSINFO=y 32 | - CONFIG_LIBPOSIX_LIBDL=y 33 | - CONFIG_LIBFLEXOS=y 34 | - CONFIG_LIBFLEXOS_ENABLE_DSS=y 35 | - CONFIG_LIBFLEXOS_INTELPKU=y 36 | 37 | targets: 38 | - architecture: x86_64 39 | platform: kvm 40 | 41 | compartments: 42 | #@ for compartment in compartments: 43 | - #@ compartment 44 | #@ end 45 | 46 | libraries: 47 | uksched: 48 | compartment: #@ "comp{}".format(libraries["LIBUKSCHED"]) 49 | is_core: true 50 | ukschedcoop: 51 | compartment: #@ "comp{}".format(libraries["LIBUKSCHED"]) 52 | is_core: true 53 | tlsf: 54 | version: staging 55 | kconfig: 56 | - CONFIG_LIBTLSF=y 57 | compartment: #@ "comp{}".format(libraries["LIBTLSF"]) 58 | pthread-embedded: 59 | version: staging 60 | compartment: #@ "comp{}".format(libraries["LIBPTHREAD_EMBEDDED"]) 61 | newlib: 62 | version: staging 63 | kconfig: 64 | - CONFIG_LIBNEWLIBC=y 65 | - CONFIG_LIBNEWLIBC_WANT_IO_C99_FORMATS=y 66 | - CONFIG_LIBNEWLIBC_LINUX_ERRNO_EXTENSIONS=y 67 | compartment: #@ "comp{}".format(libraries["LIBNEWLIB"]) 68 | lwip: 69 | version: staging 70 | kconfig: 71 | - CONFIG_LWIP_IPV6=y 72 | - CONFIG_LWIP_POOLS=y 73 | - CONFIG_LWIP_UKNETDEV=y 74 | - CONFIG_LWIP_UKNETDEV_POLLONLY=y 75 | - CONFIG_LWIP_TCP_KEEPALIVE=y 76 | - CONFIG_LWIP_TCP=y 77 | - CONFIG_LWIP_WND_SCALE=y 78 | - CONFIG_LWIP_TCP_KEEPALIVE=y 79 | - CONFIG_LWIP_THREADS=y 80 | - CONFIG_LWIP_SOCKET=y 81 | - CONFIG_LWIP_AUTOIFACE=y 82 | - CONFIG_LWIP_IPV4=y 83 | - CONFIG_LWIP_DHCP=y 84 | - CONFIG_LWIP_DNS=y 85 | 86 | compartment: #@ "comp{}".format(libraries["LIBLWIP"]) 87 | nginx: 88 | version: staging 89 | kconfig: 90 | - CONFIG_LIBNGINX_MAIN_FUNCTION=y 91 | compartment: #@ "comp{}".format(libraries["LIBNGINX"]) 92 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/nginx/templates/wayfinder/data.yaml: -------------------------------------------------------------------------------- 1 | #@data/values 2 | --- 3 | num_compartments: 1 4 | libraries: 5 | - name: tlsf 6 | compartmentalizable: false 7 | - name: lwip 8 | compartmentalizable: true 9 | - name: nginx 10 | compartmentalizable: false 11 | - name: newlib 12 | compartmentalizable: false 13 | - name: uksched 14 | compartmentalizable: true 15 | - name: pthread-embedded 16 | compartmentalizable: false 17 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/nginx/templates/wayfinder/template.yaml: -------------------------------------------------------------------------------- 1 | #@ load("@ytt:data", "data") 2 | #@ load("@ytt:assert", "assert") 3 | #! 4 | #@ num_compartments = int(data.values.num_compartments) or \ 5 | #@ assert.fail("num_compartments must be specified") 6 | #@ compartments = [x for x in range(1, num_compartments + 1)] 7 | #! 8 | #@yaml/text-templated-strings 9 | --- 10 | params: 11 | - name: NUM_COMPARTMENTS 12 | type: int 13 | only: 14 | - #@ num_compartments 15 | 16 | #@ for lib in data.values.libraries: 17 | #@ libname = lib.name.replace("-", "_").upper() 18 | - name: #@ "LIB{}_COMPARTMENT".format(libname) 19 | type: int 20 | #@ if lib.compartmentalizable: 21 | only: #@ compartments 22 | #@ else: 23 | only: [1] 24 | #@ end 25 | - name: #@ "LIB{}_SFI".format(libname) 26 | type: string 27 | #@ if libname == "TLSF" or libname == "PTHREAD_EMBEDDED": 28 | only: ["n"] 29 | #@ else: 30 | only: ["y", "n"] 31 | #@ end 32 | #@ end 33 | 34 | #@ for i in compartments: 35 | - name: #@ "COMPARTMENT{}_DRIVER".format(i) 36 | type: string 37 | #! only: ["intel-pku", "vmept"] 38 | only: ["intel-pku"] 39 | - name: #@ "COMPARTMENT{}_ISOLSTACK".format(i) 40 | type: string 41 | only: ["false"] 42 | #! only: ["true", "false"] 43 | #@ end 44 | 45 | inputs: 46 | - source: /etc/resolv.conf 47 | destination: /etc/resolv.conf 48 | - source: /etc/environment 49 | destination: /etc/environment 50 | - source: ./apps/nginx/build.sh 51 | destination: /build.sh 52 | - source: ./apps/nginx/templates/kraft 53 | destination: /kraft-yaml-template 54 | 55 | outputs: 56 | - path: /usr/src/unikraft/apps/nginx/build/nginx_kvm-x86_64 57 | - path: /usr/src/unikraft/apps/nginx/build/nginx_kvm-x86_64.dbg 58 | - path: /usr/src/unikraft/apps/nginx/kraft.yaml 59 | - path: /usr/src/unikraft/apps/nginx/config 60 | - path: /usr/src/unikraft/apps/nginx/build.log 61 | 62 | runs: 63 | - name: build 64 | image: ghcr.io/project-flexos/nginx:latest 65 | cores: 2 66 | cmd: /build.sh 67 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/nginx/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | 4 | DIR=$1 5 | 6 | if [[ "${DIR}" == "" ]]; then 7 | echo "Usage: $0 DIR" 8 | exit 1 9 | fi 10 | 11 | # Setting this manually since we are not running via wayfinder 12 | WAYFINDER_CORE_ID0=10 13 | WAYFINDER_CORE_ID1=12 14 | WAYFINDER_CORE_ID2=14 15 | 16 | echo "performance" > /sys/devices/system/cpu/cpu${WAYFINDER_CORE_ID0}/cpufreq/scaling_governor 17 | echo "performance" > /sys/devices/system/cpu/cpu${WAYFINDER_CORE_ID1}/cpufreq/scaling_governor 18 | echo "performance" > /sys/devices/system/cpu/cpu${WAYFINDER_CORE_ID2}/cpufreq/scaling_governor 19 | 20 | QEMU_GUEST=${QEMU_GUEST:-./support/qemu-guest} 21 | BRIDGE=asplosae$WAYFINDER_CORE_ID0 # create a unique bridge 22 | BRIDGE_IP="172.${WAYFINDER_CORE_ID0}.${WAYFINDER_CORE_ID1}.1" 23 | UNIKERNEL_INITRD=${UNIKERNEL_INITRD:-./nginx.cpio} 24 | UNIKERNEL_IP="172.${WAYFINDER_CORE_ID0}.${WAYFINDER_CORE_ID1}.2" 25 | NUM_PARALLEL_CONNS=${NUM_PARALLEL_CONNS:-30} 26 | NUM_THREADS=${NUM_THREADS:-14} 27 | ITERATIONS=${ITERATIONS:-5} 28 | DURATION=${DURATION:-10s} 29 | RESULTS=${RESULTS:-./results.txt} 30 | BOOT_WARMUP_SLEEP=${BOOT_WARMUP_SLEEP:-4} 31 | CHUNK=0 32 | 33 | if [[ ! -f ${RESULTS} ]]; then 34 | echo "TASKID,CHUNK,ITERATION,METHOD,VALUE" > ${RESULTS} 35 | fi 36 | 37 | if [[ ! -f ${UNIKERNEL_INITRD} ]]; then 38 | echo "Missing initram image!" 39 | exit 1 40 | fi 41 | 42 | function cleanup { 43 | echo "Cleaning up..." 44 | ifconfig ${BRIDGE} down || true 45 | brctl delbr ${BRIDGE} || true 46 | pkill qemu-system-x86_64 || true 47 | } 48 | 49 | trap "cleanup" EXIT 50 | 51 | echo "Creating bridge..." 52 | brctl addbr ${BRIDGE} || true 53 | ifconfig ${BRIDGE} down 54 | ifconfig ${BRIDGE} ${BRIDGE_IP} 55 | ifconfig ${BRIDGE} up 56 | 57 | for D in ${DIR}/*; do 58 | if [[ ! -d ${D} ]]; then continue; fi 59 | 60 | TASKID=$(basename ${D}) 61 | UNIKERNEL_IMAGE=${D}/usr/src/unikraft/apps/nginx/build/nginx_kvm-x86_64 62 | 63 | if [[ ! -f ${UNIKERNEL_IMAGE} ]]; then 64 | continue 65 | fi 66 | 67 | for ((I=1; I<=${ITERATIONS};I++)) do 68 | echo "Starting unikernel..." 69 | 70 | echo "${UNIKERNEL_IMAGE}" 71 | taskset -c ${WAYFINDER_CORE_ID0} \ 72 | ${QEMU_GUEST} \ 73 | -x \ 74 | -k ${UNIKERNEL_IMAGE} \ 75 | -m 1024 \ 76 | -i ${UNIKERNEL_INITRD} \ 77 | -b ${BRIDGE} \ 78 | -p ${WAYFINDER_CORE_ID1} \ 79 | -a "netdev.ipv4_addr=${UNIKERNEL_IP} netdev.ipv4_gw_addr=${BRIDGE_IP} netdev.ipv4_subnet_mask=255.255.255.0 vfs.rootdev=ramfs --" 80 | 81 | echo "Sleeping ${BOOT_WARMUP_SLEEP}..." 82 | sleep ${BOOT_WARMUP_SLEEP} 83 | 84 | echo "Starting experiment..." 85 | taskset -c ${WAYFINDER_CORE_ID2} \ 86 | wrk \ 87 | -t ${NUM_THREADS} \ 88 | -c ${NUM_PARALLEL_CONNS} \ 89 | -d ${DURATION} \ 90 | http://${UNIKERNEL_IP} | \ 91 | awk 'BEGIN{a["Requests/sec:"]} ($1 in a) && ($2 ~ /[0-9]/){print $2}' | \ 92 | awk -v prefix="${TASKID},${CHUNK},${I},REQ" '{ print prefix "," $0 }' >> ${RESULTS} 93 | 94 | pkill qemu-system-x86 95 | pkill qemu 96 | pkill qemu* 97 | done 98 | done 99 | 100 | 101 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/nginx/wayfinder-jobs/1.yaml: -------------------------------------------------------------------------------- 1 | params: 2 | - name: NUM_COMPARTMENTS 3 | type: int 4 | only: 5 | - 1 6 | - name: LIBTLSF_COMPARTMENT 7 | type: int 8 | only: 9 | - 1 10 | - name: LIBTLSF_SFI 11 | type: string 12 | only: 13 | - "n" 14 | - name: LIBLWIP_COMPARTMENT 15 | type: int 16 | only: 17 | - 1 18 | - name: LIBLWIP_SFI 19 | type: string 20 | only: 21 | - "y" 22 | - "n" 23 | - name: LIBNGINX_COMPARTMENT 24 | type: int 25 | only: 26 | - 1 27 | - name: LIBNGINX_SFI 28 | type: string 29 | only: 30 | - "y" 31 | - "n" 32 | - name: LIBNEWLIB_COMPARTMENT 33 | type: int 34 | only: 35 | - 1 36 | - name: LIBNEWLIB_SFI 37 | type: string 38 | only: 39 | - "y" 40 | - "n" 41 | - name: LIBUKSCHED_COMPARTMENT 42 | type: int 43 | only: 44 | - 1 45 | - name: LIBUKSCHED_SFI 46 | type: string 47 | only: 48 | - "y" 49 | - "n" 50 | - name: LIBPTHREAD_EMBEDDED_COMPARTMENT 51 | type: int 52 | only: 53 | - 1 54 | - name: LIBPTHREAD_EMBEDDED_SFI 55 | type: string 56 | only: 57 | - "n" 58 | - name: COMPARTMENT1_DRIVER 59 | type: string 60 | only: 61 | - intel-pku 62 | - name: COMPARTMENT1_ISOLSTACK 63 | type: string 64 | only: 65 | - "false" 66 | inputs: 67 | - source: /etc/resolv.conf 68 | destination: /etc/resolv.conf 69 | - source: /etc/environment 70 | destination: /etc/environment 71 | - source: ./apps/nginx/build.sh 72 | destination: /build.sh 73 | - source: ./apps/nginx/templates/kraft 74 | destination: /kraft-yaml-template 75 | outputs: 76 | - path: /usr/src/unikraft/apps/nginx/build/nginx_kvm-x86_64 77 | - path: /usr/src/unikraft/apps/nginx/build/nginx_kvm-x86_64.dbg 78 | - path: /usr/src/unikraft/apps/nginx/kraft.yaml 79 | - path: /usr/src/unikraft/apps/nginx/config 80 | - path: /usr/src/unikraft/apps/nginx/build.log 81 | runs: 82 | - name: build 83 | image: ghcr.io/project-flexos/nginx:latest 84 | cores: 2 85 | cmd: /build.sh 86 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/nginx/wayfinder-jobs/3.yaml: -------------------------------------------------------------------------------- 1 | params: 2 | - name: NUM_COMPARTMENTS 3 | type: int 4 | only: 5 | - 3 6 | - name: LIBTLSF_COMPARTMENT 7 | type: int 8 | only: 9 | - 1 10 | - name: LIBTLSF_SFI 11 | type: string 12 | only: 13 | - "n" 14 | - name: LIBLWIP_COMPARTMENT 15 | type: int 16 | only: 17 | - 1 18 | - 2 19 | - 3 20 | - name: LIBLWIP_SFI 21 | type: string 22 | only: 23 | - "y" 24 | - "n" 25 | - name: LIBNGINX_COMPARTMENT 26 | type: int 27 | only: 28 | - 1 29 | - name: LIBNGINX_SFI 30 | type: string 31 | only: 32 | - "y" 33 | - "n" 34 | - name: LIBNEWLIB_COMPARTMENT 35 | type: int 36 | only: 37 | - 1 38 | - name: LIBNEWLIB_SFI 39 | type: string 40 | only: 41 | - "y" 42 | - "n" 43 | - name: LIBUKSCHED_COMPARTMENT 44 | type: int 45 | only: 46 | - 1 47 | - 2 48 | - 3 49 | - name: LIBUKSCHED_SFI 50 | type: string 51 | only: 52 | - "y" 53 | - "n" 54 | - name: LIBPTHREAD_EMBEDDED_COMPARTMENT 55 | type: int 56 | only: 57 | - 1 58 | - name: LIBPTHREAD_EMBEDDED_SFI 59 | type: string 60 | only: 61 | - "n" 62 | - name: COMPARTMENT1_DRIVER 63 | type: string 64 | only: 65 | - intel-pku 66 | - name: COMPARTMENT1_ISOLSTACK 67 | type: string 68 | only: 69 | - "false" 70 | - name: COMPARTMENT2_DRIVER 71 | type: string 72 | only: 73 | - intel-pku 74 | - name: COMPARTMENT2_ISOLSTACK 75 | type: string 76 | only: 77 | - "false" 78 | - name: COMPARTMENT3_DRIVER 79 | type: string 80 | only: 81 | - intel-pku 82 | - name: COMPARTMENT3_ISOLSTACK 83 | type: string 84 | only: 85 | - "false" 86 | inputs: 87 | - source: /etc/resolv.conf 88 | destination: /etc/resolv.conf 89 | - source: /etc/environment 90 | destination: /etc/environment 91 | - source: ./apps/nginx/build.sh 92 | destination: /build.sh 93 | - source: ./apps/nginx/templates/kraft 94 | destination: /kraft-yaml-template 95 | outputs: 96 | - path: /usr/src/unikraft/apps/nginx/build/nginx_kvm-x86_64 97 | - path: /usr/src/unikraft/apps/nginx/build/nginx_kvm-x86_64.dbg 98 | - path: /usr/src/unikraft/apps/nginx/kraft.yaml 99 | - path: /usr/src/unikraft/apps/nginx/config 100 | - path: /usr/src/unikraft/apps/nginx/build.log 101 | runs: 102 | - name: build 103 | image: ghcr.io/project-flexos/nginx:latest 104 | cores: 2 105 | cmd: /build.sh 106 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/redis/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Just ensure the environment is OK for kraft 4 | export UK_WORKDIR=/usr/src/unikraft 5 | export UK_CACHEDIR=/usr/src/unikraft/.kraftcache 6 | export KRAFTRC=/usr/src/unikraft/.kraftrc 7 | export LC_ALL=C.UTF-8 8 | export LANG=C.UTF-8 9 | for env in $(cat /etc/environment); do \ 10 | export $(echo $env | sed -e 's/"//g'); \ 11 | done 12 | 13 | NUM_COMPARTMENTS=${NUM_COMPARTMENTS:-1} 14 | TEMPLDIR=${TEMPLDIR:-/kraft-yaml-template} 15 | TEMPDIR=$(mktemp -d) 16 | 17 | cp -rfv $TEMPLDIR/* $TEMPDIR 18 | 19 | KRAFT_BUILD_EXTRA=() 20 | KRAFT_BUILD_EXTRA+=(V=1) 21 | USE_UBSAN=n 22 | USE_KASAN=n 23 | USE_SP=n 24 | 25 | SFI_FLAGS='"-fsanitize=undefined -fsanitize=kernel-address -fstack-protector-all -mstack-protector-guard=global"' 26 | 27 | for ENV in $(env); do 28 | # Iterate over unique libs 29 | if [[ "${ENV:0:3}" != "LIB" ]]; then continue; fi 30 | LIB=${ENV%=*} 31 | if [ "${LIB: -12}" != "_COMPARTMENT" ]; then continue; fi 32 | 33 | LIB=${LIB%_COMPARTMENT*} 34 | COMPARTMENT="${LIB}_COMPARTMENT" 35 | cat << EOF >> ${TEMPDIR}/data.yaml 36 | ${LIB}: ${!COMPARTMENT} 37 | EOF 38 | 39 | USE_SFI="${LIB}_SFI" 40 | if [[ "${!USE_SFI}" == "y" ]]; then 41 | USE_UBSAN=y 42 | USE_KASAN=y 43 | USE_UKSP=y 44 | 45 | if [[ "${LIB}" == "LIBNEWLIB" ]]; then 46 | KRAFT_BUILD_EXTRA+=(LIBNEWLIB_CFLAGS_EXTRA="${SFI_FLAGS}") 47 | elif [[ "${LIB}" == "LIBUKSCHED" ]]; then 48 | KRAFT_BUILD_EXTRA+=(LIBUKSCHED_CFLAGS="${SFI_FLAGS}") 49 | KRAFT_BUILD_EXTRA+=(LIBUKSCHEDCOOP_CFLAGS="${SFI_FLAGS}") 50 | # elif [[ "${LIB}" == "LIBREDIS" ]]; then 51 | # KRAFT_BUILD_EXTRA+=(LIBREDIS_LUA_CFLAGS_EXTRA="${SFI_FLAGS}") 52 | # KRAFT_BUILD_EXTRA+=(LIBREDIS_HIREDIS_CFLAGS_EXTRA="${SFI_FLAGS}") 53 | # KRAFT_BUILD_EXTRA+=(LIBREDIS_COMMON_CFLAGS_EXTRA="${SFI_FLAGS}") 54 | # KRAFT_BUILD_EXTRA+=(LIBREDIS_SERVER_CFLAGS_EXTRA="${SFI_FLAGS}") 55 | # KRAFT_BUILD_EXTRA+=(LIBREDIS_CLIENT_CFLAGS_EXTRA="${SFI_FLAGS}") 56 | else 57 | KRAFT_BUILD_EXTRA+=(${LIB}_CFLAGS_EXTRA="${SFI_FLAGS}") 58 | fi 59 | fi 60 | done 61 | 62 | echo "compartments:" >> ${TEMPDIR}/data.yaml 63 | 64 | for ((I=1; I<=$NUM_COMPARTMENTS; I++)); do 65 | DEFAULT="false" 66 | if [[ "${I}" == "1" ]]; then 67 | DEFAULT="true" 68 | fi 69 | 70 | COMPARTMENT_DRIVER="COMPARTMENT${I}_DRIVER" 71 | COMPARTMENT_ISOLSTACK="COMPARTMENT${I}_ISOLSTACK" 72 | 73 | cat << EOF >> ${TEMPDIR}/data.yaml 74 | - name: comp${I} 75 | mechanism: 76 | driver: ${!COMPARTMENT_DRIVER} 77 | noisolstack: ${!COMPARTMENT_ISOLSTACK} 78 | default: ${DEFAULT} 79 | EOF 80 | done 81 | 82 | ytt \ 83 | --data-value num_compartments=$NUM_COMPARTMENTS \ 84 | --file ${TEMPDIR} > /usr/src/unikraft/apps/redis/kraft.yaml 85 | 86 | cd /usr/src/unikraft/apps/redis/ 87 | 88 | KRAFT_CONFIGURE_EXTRA=() 89 | if [[ "${USE_UBSAN}" == "y" ]]; then 90 | KRAFT_CONFIGURE_EXTRA+=(--yes LIBUBSAN) 91 | fi 92 | if [[ "${USE_KASAN}" == "y" ]]; then 93 | KRAFT_CONFIGURE_EXTRA+=(--yes LIBKASAN) 94 | fi 95 | if [[ "${USE_UKSP}" == "y" ]]; then 96 | KRAFT_CONFIGURE_EXTRA+=(--yes LIBUKSP) 97 | fi 98 | 99 | set -xe 100 | 101 | kraft -v configure -F "${KRAFT_CONFIGURE_EXTRA[@]}" |& tee build.log 102 | 103 | cp .config config 104 | echo "# Extra from build.sh" >> config 105 | echo "# configure params:" >> config 106 | echo "# ${KRAFT_CONFIGURE_EXTRA[@]}" >> config 107 | echo "# build params:" >> config 108 | echo "# ${KRAFT_BUILD_EXTRA[@]}" >> config 109 | 110 | kraft -v build \ 111 | --fast \ 112 | --no-progress \ 113 | --compartmentalize \ 114 | "${KRAFT_BUILD_EXTRA[@]}" |& tee -a build.log 115 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/redis/templates/kraft/data.yaml: -------------------------------------------------------------------------------- 1 | #@data/values 2 | --- 3 | num_compartments: 2 4 | 5 | libraries: 6 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/redis/templates/kraft/template.yaml: -------------------------------------------------------------------------------- 1 | #@ load("@ytt:data", "data") 2 | #@ load("@ytt:assert", "assert") 3 | #! 4 | #@ compartments = data.values.compartments or \ 5 | #@ assert.fail("compartments must be specified") 6 | #@ libraries = data.values.libraries or \ 7 | #@ assert.fail("libraries must be specified") 8 | #! 9 | #@yaml/text-templated-strings 10 | --- 11 | specification: '0.6' 12 | name: redis 13 | unikraft: 14 | version: staging 15 | kconfig: 16 | - CONFIG_LIBCPIO=y 17 | - CONFIG_LIBINITRAMFS=y 18 | - CONFIG_OPTIMIZE_PERF=y 19 | - CONFIG_LIBUK9P=n 20 | - CONFIG_LIB9PFS=n 21 | - CONFIG_LIBDEVFS=y 22 | - CONFIG_LIBDEVFS_AUTOMOUNT=y 23 | - CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y 24 | - CONFIG_LIBVFSCORE_ROOTFS_RAMFS=y 25 | - CONFIG_LIBUKLIBPARAM=y 26 | - CONFIG_LIBUKDEBUG=y 27 | - CONFIG_LIBUKALLOC=y 28 | - CONFIG_LIBUKSCHED=y 29 | - CONFIG_LIBPOSIX_SYSINFO=y 30 | - CONFIG_LIBPOSIX_LIBDL=y 31 | - CONFIG_LIBFLEXOS=y 32 | - CONFIG_LIBFLEXOS_ENABLE_DSS=y 33 | - CONFIG_LIBFLEXOS_INTELPKU=y 34 | 35 | targets: 36 | - architecture: x86_64 37 | platform: kvm 38 | 39 | compartments: 40 | #@ for compartment in compartments: 41 | - #@ compartment 42 | #@ end 43 | 44 | libraries: 45 | uksched: 46 | compartment: #@ "comp{}".format(libraries["LIBUKSCHED"]) 47 | is_core: true 48 | ukschedcoop: 49 | compartment: #@ "comp{}".format(libraries["LIBUKSCHED"]) 50 | is_core: true 51 | #! uktime: 52 | #! compartment: #@ "comp{}".format(libraries["LIBUKTIME"]) 53 | #! is_core: true 54 | tlsf: 55 | version: staging 56 | kconfig: 57 | - CONFIG_LIBTLSF=y 58 | compartment: #@ "comp{}".format(libraries["LIBTLSF"]) 59 | pthread-embedded: 60 | version: staging 61 | compartment: #@ "comp{}".format(libraries["LIBPTHREAD_EMBEDDED"]) 62 | newlib: 63 | version: staging 64 | kconfig: 65 | - CONFIG_LIBNEWLIBC=y 66 | - CONFIG_LIBNEWLIBC_WANT_IO_C99_FORMATS=y 67 | - CONFIG_LIBNEWLIBC_LINUX_ERRNO_EXTENSIONS=y 68 | compartment: #@ "comp{}".format(libraries["LIBNEWLIB"]) 69 | lwip: 70 | version: staging 71 | kconfig: 72 | - CONFIG_LWIP_IPV6=y 73 | - CONFIG_LWIP_POOLS=y 74 | - CONFIG_LWIP_UKNETDEV_POLLONLY=y 75 | - CONFIG_LWIP_TCP_KEEPALIVE=y 76 | compartment: #@ "comp{}".format(libraries["LIBLWIP"]) 77 | redis: 78 | version: staging 79 | kconfig: 80 | - CONFIG_LIBREDIS_SERVER=y 81 | - CONFIG_LIBREDIS_COMMON=y 82 | - CONFIG_LIBREDIS_LIBREDIS_LUA=y 83 | - CONFIG_LIBREDIS_SERVER_MAIN_FUNCTION=y 84 | compartment: #@ "comp{}".format(libraries["LIBREDIS"]) 85 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/redis/templates/wayfinder/data.yaml: -------------------------------------------------------------------------------- 1 | #@data/values 2 | --- 3 | num_compartments: 1 4 | libraries: 5 | - name: tlsf 6 | compartmentalizable: false 7 | - name: lwip 8 | compartmentalizable: true 9 | - name: redis 10 | compartmentalizable: false 11 | - name: newlib 12 | compartmentalizable: false 13 | - name: uksched 14 | compartmentalizable: true 15 | - name: pthread-embedded 16 | compartmentalizable: false 17 | #! - name: uktime 18 | #! compartmentalizable: true 19 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/redis/templates/wayfinder/template.yaml: -------------------------------------------------------------------------------- 1 | #@ load("@ytt:data", "data") 2 | #@ load("@ytt:assert", "assert") 3 | #! 4 | #@ num_compartments = int(data.values.num_compartments) or \ 5 | #@ assert.fail("num_compartments must be specified") 6 | #@ compartments = [x for x in range(1, num_compartments + 1)] 7 | #! 8 | #@yaml/text-templated-strings 9 | --- 10 | params: 11 | - name: NUM_COMPARTMENTS 12 | type: int 13 | only: 14 | - #@ num_compartments 15 | 16 | #@ for lib in data.values.libraries: 17 | #@ libname = lib.name.replace("-", "_").upper() 18 | - name: #@ "LIB{}_COMPARTMENT".format(libname) 19 | type: int 20 | #@ if lib.compartmentalizable: 21 | only: #@ compartments 22 | #@ else: 23 | only: [1] 24 | #@ end 25 | - name: #@ "LIB{}_SFI".format(libname) 26 | type: string 27 | #@ if libname == "TLSF" or libname == "PTHREAD_EMBEDDED": 28 | only: ["n"] 29 | #@ else: 30 | only: ["y", "n"] 31 | #@ end 32 | #@ end 33 | 34 | #@ for i in compartments: 35 | - name: #@ "COMPARTMENT{}_DRIVER".format(i) 36 | type: string 37 | #! only: ["intel-pku", "vmept"] 38 | only: ["intel-pku"] 39 | - name: #@ "COMPARTMENT{}_ISOLSTACK".format(i) 40 | type: string 41 | only: ["false"] 42 | #! only: ["true", "false"] 43 | #@ end 44 | 45 | inputs: 46 | - source: /etc/resolv.conf 47 | destination: /etc/resolv.conf 48 | - source: /etc/environment 49 | destination: /etc/environment 50 | - source: ./apps/redis/build.sh 51 | destination: /build.sh 52 | - source: ./apps/redis/templates/kraft 53 | destination: /kraft-yaml-template 54 | 55 | outputs: 56 | - path: /usr/src/unikraft/apps/redis/build/redis_kvm-x86_64 57 | - path: /usr/src/unikraft/apps/redis/build/redis_kvm-x86_64.dbg 58 | - path: /usr/src/unikraft/apps/redis/kraft.yaml 59 | - path: /usr/src/unikraft/apps/redis/config 60 | - path: /usr/src/unikraft/apps/redis/build.log 61 | 62 | runs: 63 | - name: build 64 | image: ghcr.io/project-flexos/redis:latest 65 | cores: 2 66 | cmd: /build.sh 67 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/redis/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -xe 3 | DIR=$1 4 | if [[ "${DIR}" == "" ]]; then 5 | echo "Usage: $0 DIR" 6 | exit 1 7 | fi 8 | 9 | # Setting this manually since we are not running via ukbench 10 | WAYFINDER_CORE_ID0=10 11 | WAYFINDER_CORE_ID1=12 12 | WAYFINDER_CORE_ID2=14 13 | 14 | echo "performance" > /sys/devices/system/cpu/cpu${WAYFINDER_CORE_ID0}/cpufreq/scaling_governor 15 | echo "performance" > /sys/devices/system/cpu/cpu${WAYFINDER_CORE_ID1}/cpufreq/scaling_governor 16 | echo "performance" > /sys/devices/system/cpu/cpu${WAYFINDER_CORE_ID2}/cpufreq/scaling_governor 17 | 18 | QEMU_GUEST=${QEMU_GUEST:-./support/qemu-guest} 19 | BRIDGE=asplosae$WAYFINDER_CORE_ID0 # create a unique bridge 20 | BRIDGE_IP="172.${WAYFINDER_CORE_ID0}.${WAYFINDER_CORE_ID1}.1" 21 | UNIKERNEL_INITRD=${UNIKERNEL_INITRD:-./redis.cpio} 22 | UNIKERNEL_IP="172.${WAYFINDER_CORE_ID0}.${WAYFINDER_CORE_ID1}.2" 23 | NUM_PARALLEL_CONNS=${NUM_PARALLEL_CONNS:-30} 24 | ITERATIONS=${ITERATIONS:-5} 25 | RESULTS=${RESULTS:-./results.txt} 26 | CHUNKS=${CHUNKS:-5 50 500} 27 | BOOT_WARMUP_SLEEP=${BOOT_WARMUP_SLEEP:-4} 28 | NUM_REQUESTS=${NUM_REQUESTS:-100000} 29 | 30 | if [[ ! -f ${RESULTS} ]]; then 31 | echo "TASKID,CHUNK,ITERATION,METHOD,VALUE" > ${RESULTS} 32 | fi 33 | 34 | if [[ ! -f $UNIKERNEL_INITRD ]]; then 35 | echo "Missing initram image!" 36 | exit 1 37 | fi 38 | 39 | function cleanup { 40 | echo "Cleaning up..." 41 | pkill qemu-system-x86_64 || true 42 | docker stop asplos22-ae-fig-06-redis 43 | } 44 | 45 | function DOCKER_EXEC { 46 | docker exec -it asplos22-ae-fig-06-redis "$@" 47 | } 48 | 49 | echo "Starting intermediate docker container" 50 | docker run -d -it --rm --name asplos22-ae-fig-06-redis \ 51 | -v $(pwd):$(pwd) \ 52 | -v ${DIR}:${DIR} \ 53 | -w $(pwd) \ 54 | --security-opt seccomp:unconfined \ 55 | --privileged \ 56 | ghcr.io/project-flexos/flexos-ae-base:latest bash -c "while true; do sleep 1; done" 57 | 58 | echo "Waiting for docker image to start..." 59 | sleep 5 60 | 61 | 62 | trap "cleanup" EXIT 63 | 64 | echo "Creating bridge..." 65 | DOCKER_EXEC brctl addbr ${BRIDGE} || true 66 | DOCKER_EXEC ifconfig ${BRIDGE} down 67 | DOCKER_EXEC ifconfig ${BRIDGE} ${BRIDGE_IP} 68 | DOCKER_EXEC ifconfig ${BRIDGE} up 69 | 70 | for D in ${DIR}/*; do 71 | if [[ ! -d ${D} ]]; then continue; fi 72 | 73 | TASKID=$(basename ${D}) 74 | UNIKERNEL_IMAGE=${D}/usr/src/unikraft/apps/redis/build/redis_kvm-x86_64 75 | 76 | if [[ ! -f ${UNIKERNEL_IMAGE} ]]; then 77 | continue 78 | fi 79 | 80 | for CHUNK in ${CHUNKS}; do 81 | for ((I=1; I<=${ITERATIONS};I++)) do 82 | echo "Starting unikernel..." 83 | 84 | DOCKER_EXEC taskset -c ${WAYFINDER_CORE_ID0} \ 85 | ${QEMU_GUEST} \ 86 | -k ${UNIKERNEL_IMAGE} \ 87 | -x \ 88 | -m 1024 \ 89 | -i ${UNIKERNEL_INITRD} \ 90 | -b ${BRIDGE} \ 91 | -p ${WAYFINDER_CORE_ID1} \ 92 | -a "netdev.ipv4_addr=${UNIKERNEL_IP} netdev.ipv4_gw_addr=${BRIDGE_IP} netdev.ipv4_subnet_mask=255.255.255.0 vfs.rootdev=ramfs -- /redis.conf" 93 | 94 | echo "Sleeping ${BOOT_WARMUP_SLEEP}..." 95 | sleep ${BOOT_WARMUP_SLEEP} 96 | 97 | echo "Starting experiment..." 98 | DOCKER_EXEC \ 99 | taskset -c ${WAYFINDER_CORE_ID2} \ 100 | redis-benchmark \ 101 | -h ${UNIKERNEL_IP} -p 6379 \ 102 | -n ${NUM_REQUESTS} \ 103 | --csv \ 104 | -q \ 105 | -c 30 \ 106 | -k 1 \ 107 | -P 16 \ 108 | -t get,set \ 109 | -d ${I} | \ 110 | awk -v prefix="${TASKID},${CHUNK},${I}" '{ print prefix "," $0 }' >> ${RESULTS} 111 | sed -i 's/"//g' ${RESULTS} 112 | DOCKER_EXEC pkill qemu-system-x86 113 | done 114 | done 115 | done 116 | -------------------------------------------------------------------------------- /experiments/fig-06_nginx-redis-perm/apps/redis/wayfinder-jobs/3.yaml: -------------------------------------------------------------------------------- 1 | params: 2 | - name: NUM_COMPARTMENTS 3 | type: int 4 | only: 5 | - 3 6 | - name: LIBTLSF_COMPARTMENT 7 | type: int 8 | only: 9 | - 1 10 | - name: LIBTLSF_SFI 11 | type: string 12 | only: 13 | - "n" 14 | - name: LIBLWIP_COMPARTMENT 15 | type: int 16 | only: 17 | - 1 18 | - 2 19 | - 3 20 | - name: LIBLWIP_SFI 21 | type: string 22 | only: 23 | - "y" 24 | - "n" 25 | - name: LIBREDIS_COMPARTMENT 26 | type: int 27 | only: 28 | - 1 29 | - name: LIBREDIS_SFI 30 | type: string 31 | only: 32 | - "y" 33 | - "n" 34 | - name: LIBNEWLIB_COMPARTMENT 35 | type: int 36 | only: 37 | - 1 38 | - name: LIBNEWLIB_SFI 39 | type: string 40 | only: 41 | - "y" 42 | - "n" 43 | - name: LIBUKSCHED_COMPARTMENT 44 | type: int 45 | only: 46 | - 1 47 | - 2 48 | - 3 49 | - name: LIBUKSCHED_SFI 50 | type: string 51 | only: 52 | - "y" 53 | - "n" 54 | - name: LIBPTHREAD_EMBEDDED_COMPARTMENT 55 | type: int 56 | only: 57 | - 1 58 | - name: LIBPTHREAD_EMBEDDED_SFI 59 | type: string 60 | only: 61 | - "n" 62 | - name: COMPARTMENT1_DRIVER 63 | type: string 64 | only: 65 | - intel-pku 66 | - name: COMPARTMENT1_ISOLSTACK 67 | type: string 68 | only: 69 | - "false" 70 | - name: COMPARTMENT2_DRIVER 71 | type: string 72 | only: 73 | - intel-pku 74 | - name: COMPARTMENT2_ISOLSTACK 75 | type: string 76 | only: 77 | - "false" 78 | - name: COMPARTMENT3_DRIVER 79 | type: string 80 | only: 81 | - intel-pku 82 | - name: COMPARTMENT3_ISOLSTACK 83 | type: string 84 | only: 85 | - "false" 86 | inputs: 87 | - source: /etc/resolv.conf 88 | destination: /etc/resolv.conf 89 | - source: /etc/environment 90 | destination: /etc/environment 91 | - source: ./apps/redis/build.sh 92 | destination: /build.sh 93 | - source: ./apps/redis/templates/kraft 94 | destination: /kraft-yaml-template 95 | outputs: 96 | - path: /usr/src/unikraft/apps/redis/build/redis_kvm-x86_64 97 | - path: /usr/src/unikraft/apps/redis/build/redis_kvm-x86_64.dbg 98 | - path: /usr/src/unikraft/apps/redis/kraft.yaml 99 | - path: /usr/src/unikraft/apps/redis/config 100 | - path: /usr/src/unikraft/apps/redis/build.log 101 | runs: 102 | - name: build 103 | image: ghcr.io/project-flexos/redis:latest 104 | cores: 2 105 | cmd: /build.sh 106 | -------------------------------------------------------------------------------- /experiments/fig-07_nginx-redis-normalized/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Files and directories 3 | # 4 | WORKDIR ?= $(CURDIR) 5 | RESULTS ?= $(WORKDIR) 6 | PLOT_FORMAT ?= svg 7 | PLOT ?= $(WORKDIR)/$(notdir $(WORKDIR)).$(PLOT_FORMAT) 8 | 9 | FIG6DIR ?= $(WORKDIR)/../fig-06_nginx-redis-perm/ 10 | REDIS_PERMS_CSV ?= apps/redis/permutations-3.csv 11 | NGINX_PERMS_CSV ?= apps/nginx/permutations-3.csv 12 | # Change to results/ to use your freshly run results 13 | REDIS_RES_CSV ?= paperresults/redis.csv 14 | NGINX_RES_CSV ?= paperresults/nginx.csv 15 | 16 | # 17 | # Tools 18 | # 19 | SNAKE ?= /usr/bin/python3 20 | DOCKER ?= docker 21 | 22 | # 23 | # Targets 24 | # 25 | .PHONY: all 26 | all: prepare run plot 27 | 28 | .PHONY: prepare 29 | prepare: 30 | @- 31 | 32 | .PHONY: run 33 | run: 34 | @- 35 | 36 | .PHONY: plot 37 | plot: 38 | rm -rf $(PLOT) 39 | $(DOCKER) run --rm -v $(WORKDIR):/out -v $(FIG6DIR):/fig6 --privileged -ti \ 40 | ghcr.io/project-flexos/flexos-ae-plot $(SNAKE) /out/plot_scatter.py \ 41 | /fig6/$(REDIS_PERMS_CSV) /fig6/$(NGINX_PERMS_CSV) \ 42 | /fig6/$(REDIS_RES_CSV) /fig6/$(NGINX_RES_CSV) 43 | mv $(WORKDIR)/nginx-redis-scatter.svg $(PLOT) 44 | 45 | .PHONY: clean 46 | clean: 47 | rm -rf $(PLOT) 48 | 49 | .PHONY: properclean 50 | properclean: clean 51 | @- 52 | 53 | -------------------------------------------------------------------------------- /experiments/fig-07_nginx-redis-normalized/README.md: -------------------------------------------------------------------------------- 1 | # NGINX versus Redis normalized performance 2 | 3 | 4 | 5 | | Estimated prep. time | Estimated runtime | 6 | | -------------------- | ----------------- | 7 | | N/A | 0h 01m | 8 | 9 | ## Overview 10 | 11 | Nginx versus Redis normalized performance. This plot plots the data set 12 | generated by [Figure 13 | 6](https://github.com/project-flexos/asplos22-ae/tree/main/experiments/fig-06_nginx-redis-perm) 14 | in a scatter form. 15 | 16 | There is no `make prepare` or `make run` step, only `make plot`. Note that this 17 | figure must be run after Figure 6. 18 | -------------------------------------------------------------------------------- /experiments/fig-07_nginx-redis-normalized/plot_scatter.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import csv 4 | import matplotlib.pyplot as plt 5 | 6 | def check_equal_permutations(perm1, perm2): 7 | res1 = "" 8 | for i in perm1.keys(): 9 | res1 += perm1[i] 10 | res2 = "" 11 | for j in perm2.keys(): 12 | res2 += perm2[j] 13 | return res1 == res2 14 | 15 | def collate(permutations_file_redis=None, permutations_file_nginx=None, results_file_nginx=None, results_file_redis=None): 16 | if not os.path.isfile(permutations_file_nginx): 17 | print("Cannot find: %s" % permutations_file_nginx) 18 | sys.exit(1) 19 | 20 | if not os.path.isfile(permutations_file_redis): 21 | print("Cannot find: %s" % permutations_file_redis) 22 | sys.exit(1) 23 | 24 | permutations_nginx = {} 25 | 26 | with open(permutations_file_nginx, 'r') as csvfile: 27 | print("Processing %s..." % permutations_file_nginx) 28 | csvdata = csv.reader(csvfile, delimiter=",") 29 | cols = next(csvdata) 30 | for row in csvdata: 31 | permutations_nginx[row[0]] = (dict(zip(cols[1:], row[1:]))) 32 | permutations_nginx[row[0]]['spec'] = (dict(zip(cols[1:], row[1:]))) 33 | 34 | max_nginx = 0 35 | with open(results_file_nginx, 'r') as csvfile: 36 | print("Processing %s..." % results_file_nginx) 37 | csvdata = csv.reader(csvfile, delimiter=",") 38 | cols = next(csvdata) 39 | for row in csvdata: 40 | data = dict(zip(cols[1:], row[1:])) 41 | 42 | if row[0] not in permutations_nginx: 43 | print("Missing result from permutation: %s" % row[0]) 44 | continue 45 | 46 | if data["METHOD"] not in permutations_nginx[row[0]]: 47 | permutations_nginx[row[0]][data["METHOD"]] = {} 48 | 49 | if data["CHUNK"] not in permutations_nginx[row[0]][data["METHOD"]]: 50 | permutations_nginx[row[0]][data["METHOD"]][data["CHUNK"]] = [] 51 | 52 | if float(data["VALUE"]) > max_nginx: 53 | max_nginx = float(data["VALUE"]) 54 | 55 | permutations_nginx[row[0]][data["METHOD"]][data["CHUNK"]].append( 56 | float(data["VALUE"]) 57 | ) 58 | 59 | 60 | permutations_redis = {} 61 | 62 | with open(permutations_file_redis, 'r') as csvfile: 63 | print("Processing %s..." % permutations_file_redis) 64 | csvdata = csv.reader(csvfile, delimiter=",") 65 | cols = next(csvdata) 66 | for row in csvdata: 67 | permutations_redis[row[0]] = (dict(zip(cols[1:], row[1:]))) 68 | permutations_redis[row[0]]['spec'] = (dict(zip(cols[1:], row[1:]))) 69 | 70 | max_redis = 0 71 | 72 | with open(results_file_redis, 'r') as csvfile: 73 | print("Processing %s..." % results_file_redis) 74 | csvdata = csv.reader(csvfile, delimiter=",") 75 | cols = next(csvdata) 76 | for row in csvdata: 77 | data = dict(zip(cols[1:], row[1:])) 78 | 79 | if row[0] not in permutations_redis: 80 | print("Missing result from permutation: %s" % row[0]) 81 | continue 82 | 83 | if data["METHOD"] not in permutations_redis[row[0]]: 84 | permutations_redis[row[0]][data["METHOD"]] = {} 85 | 86 | if data["CHUNK"] not in permutations_redis[row[0]][data["METHOD"]]: 87 | permutations_redis[row[0]][data["METHOD"]][data["CHUNK"]] = [] 88 | if float(data["VALUE"]) > max_redis: 89 | max_redis = float(data["VALUE"]) 90 | permutations_redis[row[0]][data["METHOD"]][data["CHUNK"]].append( 91 | float(data["VALUE"]) 92 | ) 93 | 94 | x_1 = [] 95 | y_1 = [] 96 | x_2 = [] 97 | y_2 = [] 98 | x_3 = [] 99 | y_3 = [] 100 | colors_1 = [] 101 | colors_2 = [] 102 | colors_3 = [] 103 | for i in permutations_redis.keys(): 104 | for j in permutations_nginx.keys(): 105 | #print(permutations_nginx[j]) 106 | if check_equal_permutations(permutations_redis[i]['spec'], permutations_nginx[j]['spec']): 107 | if "GET" in permutations_redis[i] and "REQ" in permutations_nginx[j]: 108 | is_2 = 0 109 | is_three = 0 110 | is_two = 0 111 | for k in permutations_nginx[j]: 112 | if "COMPARTMENT" in k and k != "NUM_COMPARTMENTS": 113 | if permutations_nginx[j][k] == '3': 114 | is_three = 1 115 | 116 | if permutations_nginx[j][k] == '2': 117 | is_two = 1 118 | 119 | 120 | if is_three: 121 | colors_3.append('b') 122 | x_3.append(sum(permutations_redis[i]["GET"]["5"]) / (max_redis * len(permutations_redis[i]["GET"]["5"]))) 123 | y_3.append(sum(permutations_nginx[j]["REQ"]["5"]) / (max_nginx * len(permutations_nginx[j]["REQ"]["5"]))) 124 | else: 125 | if is_two: 126 | colors_2.append('g') 127 | x_2.append(sum(permutations_redis[i]["GET"]["5"]) / (max_redis * len(permutations_redis[i]["GET"]["5"]))) 128 | y_2.append(sum(permutations_nginx[j]["REQ"]["5"]) / (max_nginx * len(permutations_nginx[j]["REQ"]["5"]))) 129 | else: 130 | colors_1.append('k') 131 | x_1.append(sum(permutations_redis[i]["GET"]["5"]) / (max_redis * len(permutations_redis[i]["GET"]["5"]))) 132 | y_1.append(sum(permutations_nginx[j]["REQ"]["5"]) / (max_nginx * len(permutations_nginx[j]["REQ"]["5"]))) 133 | 134 | #print("{} {}### {} {}".format(i,permutations_redis[i]["GET"]["5"],j,permutations_nginx[j]["REQ"]["5"])) 135 | 136 | plt.rcParams.update({'font.size': 13.5}) 137 | fig, ax = plt.subplots(figsize=(7, 2)) 138 | ax.scatter(x_1, y_1, c=colors_1, marker="o", label="1 compartment") 139 | ax.scatter(x_2, y_2, c=colors_2, marker="v", label="2 compartments") 140 | ax.scatter(x_3, y_3, c=colors_3, marker="p", label="3 compartments") 141 | ax.legend() 142 | ax.plot((0, 1), "#306BAC", linestyle='--') 143 | ax.set_xlim(0, 1) 144 | ax.set_ylim(0, 1) 145 | plt.grid(linestyle='--') 146 | plt.ylabel("Nginx norm. perf.") 147 | plt.xlabel("Redis normalized performance") 148 | plt.savefig("/out/nginx-redis-scatter.svg", format="svg", bbox_inches="tight") 149 | plt.show() 150 | if __name__ == "__main__": 151 | if len(sys.argv) < 2: 152 | print("Usage: ./plot.sh PERMUTATIONS_REDIS RESULTS_NGINX") 153 | sys.exit() 154 | 155 | permutations = collate( 156 | permutations_file_redis=sys.argv[1], 157 | permutations_file_nginx=sys.argv[2], 158 | results_file_redis=sys.argv[3], 159 | results_file_nginx=sys.argv[4], 160 | 161 | ) 162 | 163 | -------------------------------------------------------------------------------- /experiments/fig-08_config-poset/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Files and directories 3 | # 4 | WORKDIR ?= $(CURDIR) 5 | RESULTS ?= $(WORKDIR) 6 | PLOT_FORMAT ?= svg 7 | PLOT ?= $(WORKDIR)/$(notdir $(WORKDIR)).$(PLOT_FORMAT) 8 | 9 | # 10 | # Targets 11 | # 12 | .PHONY: all 13 | all: prepare run plot 14 | 15 | .PHONY: prepare 16 | prepare: 17 | @- 18 | 19 | .PHONY: run 20 | run: 21 | @- 22 | 23 | .PHONY: plot 24 | plot: 25 | ./plot.sh $(PLOT_FORMAT) $(PLOT) 26 | 27 | .PHONY: clean 28 | clean: 29 | rm -rf $(PLOT) 30 | 31 | .PHONY: properclean 32 | properclean: 33 | rm -rf $(PLOT) 34 | 35 | -------------------------------------------------------------------------------- /experiments/fig-08_config-poset/README.md: -------------------------------------------------------------------------------- 1 | # Configuration Poset for Redis 2 | 3 | 4 | 5 | | Estimated prep. time | Estimated runtime | 6 | | -------------------- | ----------------- | 7 | | N/A | 1h 00m (manual) | 8 | 9 | ## Overview 10 | 11 | This plot corresponds to Figure 8 in the paper, that presents the 12 | configurations partially ordered set (poset) for the Redis performance numbers 13 | presented in Figure 6. Each node represents a configuration, and a directed 14 | edge between nodes n1 and n2 indicates that the level of safety of n1 is 15 | probabilistically superior to that of n2. The safety of nodes on the same path 16 | is comparable, while that of nodes on different paths is not. The color of a 17 | node is indicates the performance of the corresponding configuration, with 18 | black being the fastest (1209.7k req/s on our machine) and white being the 19 | slowest (264.6k req/s). The stars represnt the most secure configuration 20 | with performance > 500k req/s. 21 | 22 | ## Generating the plot 23 | 24 | As a prerequisite, you'll need to install graphviz, on Debian/Ubuntu systems: 25 | ``` 26 | sudo apt install graphviz 27 | ``` 28 | 29 | Then you can generate the graph with: 30 | ``` 31 | make plot 32 | ``` 33 | 34 | ## Details about the plot's data 35 | 36 | For the sake of simplicity the [graphviz plot script](poset.dot) hardcodes data 37 | we gathered for the paper on our machine. A detailed version of the poset is 38 | available in this [PDF file](additional-resources/detailed-view.pdf). It 39 | contains for each configuration its description as well as the corresponding 40 | performance. The legend explains the labelling of the configurations. 41 | 42 | ### Plotting new results 43 | 44 | In order to plot the poset for new Redis performance 45 | numbers that would be obtained through the scripts relating to 46 | [Figure 6](../fig-06_nginx-redis-perm), one would need to edit in the 47 | [plot script](poset.dot) the `fillcolor` for each configuration, i.e. each 48 | line with a `tooltip` attribute identifying a configuration with the same 49 | scheme as in the [detailed poset view](additional-resources/detailed-view.pdf). 50 | 51 | The mapping of performance numbers to graphviz's hexadecimal color codes is 52 | automated in this LibreOffice [spreadsheet](additional-resources/raw-data.ods). 53 | One will need to enter Redis' performance numbers for each configuration in the 54 | column entitled "Redis GET Throughput", and the last column on the left will 55 | automatically compute the hexadecimal value that should be set for the 56 | `fillcolor` attribute of the corresponding configuration in the graphviz 57 | plot script. 58 | 59 | -------------------------------------------------------------------------------- /experiments/fig-08_config-poset/additional-resources/detailed-view.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/project-flexos/asplos22-ae/11a77fce56566e5ecc6be3946a60fcaeae864bf3/experiments/fig-08_config-poset/additional-resources/detailed-view.pdf -------------------------------------------------------------------------------- /experiments/fig-08_config-poset/additional-resources/raw-data.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/project-flexos/asplos22-ae/11a77fce56566e5ecc6be3946a60fcaeae864bf3/experiments/fig-08_config-poset/additional-resources/raw-data.ods -------------------------------------------------------------------------------- /experiments/fig-08_config-poset/plot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# != "2" ]; then 4 | echo "Usage: $0 " 5 | exit 0 6 | fi 7 | 8 | # First check that graphviz is installed 9 | if ! command -v dot &> /dev/null; then 10 | echo "Graphviz not installed, install it with:" 11 | echo "sudo apt install graphviz" 12 | exit -1 13 | fi 14 | 15 | # Plot 16 | dot -T$1 -Kneato poset.dot > $2 17 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Files and directories 3 | # 4 | WORKDIR ?= $(CURDIR) 5 | RESULTS ?= $(WORKDIR) 6 | PLOT_FORMAT ?= svg 7 | PLOT ?= $(WORKDIR)/$(notdir $(WORKDIR)).$(PLOT_FORMAT) 8 | 9 | # 10 | # Parameters 11 | # 12 | KRAFT_TOKEN ?= 13 | # These should be contiguous on the same NUMA node 14 | NOISOLED_CPU1 ?= 1 15 | NOISOLED_CPU2 ?= 2 16 | NOISOLED_CPU3 ?= 3 17 | NOISOLED_CPU4 ?= 4 18 | ISOLED_CPU1 ?= 5 19 | ISOLED_CPU2 ?= 6 20 | ISOLED_CPU3 ?= 7 21 | 22 | # 23 | # Tools 24 | # 25 | GNUPLOT ?= gnuplot 26 | DOCKER ?= docker 27 | 28 | # 29 | # Targets 30 | # 31 | .PHONY: all 32 | all: prepare run plot 33 | 34 | .PHONY: prepare 35 | prepare: 36 | $(DOCKER) build -f $(WORKDIR)/flexos-iperf.dockerfile \ 37 | --build-arg GITHUB_TOKEN="$(KRAFT_TOKEN)" \ 38 | --tag flexos-iperf $(WORKDIR) 39 | 40 | .PHONY: run 41 | run: 42 | $(DOCKER) run --rm -v $(WORKDIR):/out --privileged \ 43 | --security-opt seccomp:unconfined -ti flexos-iperf \ 44 | /root/run.sh $(ISOLED_CPU1) $(ISOLED_CPU2) $(ISOLED_CPU3) \ 45 | $(NOISOLED_CPU1) $(NOISOLED_CPU2) $(NOISOLED_CPU3) $(NOISOLED_CPU4) 46 | 47 | .PHONY: plot 48 | plot: 49 | rm -rf $(PLOT) 50 | $(DOCKER) run --rm -v $(WORKDIR):/out --privileged -ti \ 51 | ghcr.io/project-flexos/flexos-ae-plot $(GNUPLOT) /out/iperf.plot 52 | mv $(WORKDIR)/iperf.svg $(PLOT) 53 | 54 | .PHONY: clean 55 | clean: 56 | rm -rf results $(PLOT) 57 | 58 | .PHONY: properclean 59 | properclean: clean 60 | $(DOCKER) image rm -f flexos-iperf 61 | $(DOCKER) image prune -f 62 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/README.md: -------------------------------------------------------------------------------- 1 | # iPerf throughput 2 | 3 | 4 | 5 | | Estimated prep. time | Estimated runtime | 6 | | -------------------- | ----------------- | 7 | | 0h 45m | 1h 30m | 8 | 9 | ## Overview 10 | 11 | Network throughput (iPerf) with Unikraft (baseline), FlexOS w/o isolation, with 12 | 2 compartments backed by MPK (-_light_ = shared call stacks, -_dss_ = protected 13 | and DSS) and EPT. 14 | 15 | ## Troubleshooting 16 | 17 | - **Problem**: EPT measurements show very low performance, not achieving more 18 | than a few 100Mb/s. 19 | 20 | **Solution**: This is typically due to pinning issues. EPT measurements are not 21 | all pinned like MPK measurements for technical reasons, and they use 4 22 | non-isolated cores. If these cores are improperly set (different NUMA node 23 | than isolated ones, noise on them), this might result in drastic loss of 24 | performance. 25 | 26 | - **Problem**: All measurements are blocked at 1.9-2.0Gb/s (while they should 27 | achieve around 3Gb/s). 28 | 29 | **Solution**: This issue seems to happen from time to time even in correct 30 | setups, and we do not have a good explanation for it. iPerf is an extremely 31 | sensitive benchmark that involves not only two different TCP stacks (guest 32 | plus the host) but also very complex TCP behaviors. In this case 33 | the solution was generally to restart the machine with `reboot`. 34 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/docker-data/build-images.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set_rcvbuf() { 4 | sed -i "s/#define RECVBUFFERSIZE .*/#define RECVBUFFERSIZE ${1}/g" ./main.c 5 | } 6 | 7 | build_img() { 8 | isept=$( grep -e "CONFIG_LIBFLEXOS_VMEPT=y" .config ) 9 | if [ -n "$isept" ]; then 10 | # don't use --no-progress here, might cause issues 11 | make prepare && kraft -v build --fast --compartmentalize 12 | cp build/iperf_kvm-x86_64.comp0 images/${cur}.img.comp0 13 | cp build/iperf_kvm-x86_64.comp1 images/${cur}.img.comp1 14 | else 15 | make prepare && make -j 16 | cp build/iperf_kvm-x86_64 images/${cur}.img 17 | fi 18 | } 19 | 20 | mkdir -p ./images 21 | 22 | for i in {4..20}; do 23 | cur=$(echo 2^$i | bc) 24 | set_rcvbuf $cur 25 | build_img 26 | done 27 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/docker-data/configs/kraft.yaml.ept2: -------------------------------------------------------------------------------- 1 | --- 2 | specification: '0.6' 3 | name: iperf 4 | unikraft: 5 | version: staging 6 | kconfig: 7 | - CONFIG_LIBFLEXOS=y 8 | targets: 9 | - architecture: x86_64 10 | platform: kvm 11 | compartments: 12 | - name: comp1 13 | mechanism: 14 | driver: vmept 15 | default: true 16 | - name: comp2 17 | mechanism: 18 | driver: vmept 19 | libraries: 20 | newlib: 21 | version: staging 22 | kconfig: 23 | - CONFIG_LIBNEWLIBC=y 24 | - CONFIG_LIBNEWLIBM=y 25 | compartment: comp1 26 | lwip: 27 | version: staging 28 | kconfig: 29 | - CONFIG_LWIP_IPV6=y 30 | compartment: comp1 31 | iperf: 32 | version: staging 33 | compartment: comp2 34 | volumes: {} 35 | networks: {} 36 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/docker-data/configs/kraft.yaml.fcalls: -------------------------------------------------------------------------------- 1 | --- 2 | specification: '0.6' 3 | name: iperf 4 | unikraft: 5 | version: staging 6 | kconfig: 7 | - CONFIG_LIBFLEXOS=y 8 | targets: 9 | - architecture: x86_64 10 | platform: kvm 11 | compartments: 12 | - name: comp1 13 | mechanism: 14 | driver: fcalls 15 | default: true 16 | libraries: 17 | tlsf: 18 | version: staging 19 | kconfig: 20 | - CONFIG_LIBTLSF=y 21 | newlib: 22 | version: staging 23 | kconfig: 24 | - CONFIG_LIBNEWLIBC=y 25 | - CONFIG_LIBNEWLIBM=y 26 | compartment: comp1 27 | lwip: 28 | version: staging 29 | kconfig: 30 | - CONFIG_LWIP_IPV6=y 31 | compartment: comp1 32 | iperf: 33 | version: staging 34 | compartment: comp1 35 | volumes: {} 36 | networks: {} 37 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/docker-data/flexos-net.patch: -------------------------------------------------------------------------------- 1 | diff --git a/lib/uknetdev/include/uk/netdev_core.h b/lib/uknetdev/include/uk/netdev_core.h 2 | index 24454e1..fc8e0a4 100644 3 | --- a/lib/uknetdev/include/uk/netdev_core.h 4 | +++ b/lib/uknetdev/include/uk/netdev_core.h 5 | @@ -426,7 +426,8 @@ struct uk_netdev_event_handler { 6 | struct uk_netdev_data { 7 | enum uk_netdev_state state; 8 | 9 | - struct uk_netdev_event_handler *rxq_handler; 10 | + struct uk_netdev_event_handler 11 | + rxq_handler[CONFIG_LIBUKNETDEV_MAXNBQUEUES]; 12 | 13 | const uint16_t id; /**< ID is assigned during registration */ 14 | const char *drv_name; 15 | @@ -470,7 +471,7 @@ struct uk_netdev { 16 | struct uk_netdev_einfo *_einfo; 17 | 18 | #if (CONFIG_UK_NETDEV_SCRATCH_SIZE > 0) 19 | - char *scratch_pad; 20 | + char scratch_pad[CONFIG_UK_NETDEV_SCRATCH_SIZE]; 21 | #endif /* CONFIG_UK_NETDEV_SCRATCH_SIZE */ 22 | }; 23 | 24 | diff --git a/lib/uknetdev/netdev.c b/lib/uknetdev/netdev.c 25 | index 33d436b..1ae2c41 100644 26 | --- a/lib/uknetdev/netdev.c 27 | +++ b/lib/uknetdev/netdev.c 28 | @@ -100,16 +100,19 @@ static struct uk_netdev_data *_alloc_data(struct uk_alloc *a, 29 | { 30 | struct uk_netdev_data *data; 31 | 32 | + /* FIXME: these two should be identical, and yet they result in a small 33 | + * performance difference. We should investigate further to remove this 34 | + * hack. */ 35 | +#if CONFIG_LIBFLEXOS_NONE 36 | data = uk_calloc(a, 1, sizeof(*data)); 37 | +#else 38 | + data = flexos_calloc_whitelist(1, sizeof(*data)); 39 | +#endif 40 | if (!data) 41 | return NULL; 42 | 43 | data->drv_name = drv_name; 44 | data->state = UK_NETDEV_UNCONFIGURED; 45 | - data->rxq_handler = flexos_calloc_whitelist(sizeof(struct uk_netdev_event_handler), 46 | - CONFIG_LIBUKNETDEV_MAXNBQUEUES); 47 | - if (!data->rxq_handler) 48 | - return NULL; 49 | 50 | /* This is the only place where we set the device ID; 51 | * during the rest of the device's life time this ID is read-only 52 | diff --git a/plat/drivers/virtio/virtio_net.c b/plat/drivers/virtio/virtio_net.c 53 | index 3202246..f77f69a 100644 54 | --- a/plat/drivers/virtio/virtio_net.c 55 | +++ b/plat/drivers/virtio/virtio_net.c 56 | @@ -157,9 +157,7 @@ struct virtio_net_device { 57 | /* The mtu */ 58 | __u16 mtu; 59 | /* The hw address of the netdevice */ 60 | - /* NOTE FLEXOS: as a pointer here, we want to be able to share 61 | - * this with lwip */ 62 | - struct uk_hwaddr *hw_addr; 63 | + struct uk_hwaddr hw_addr; 64 | /* Netdev state */ 65 | __u8 state; 66 | /* RX promiscuous mode. */ 67 | @@ -821,7 +819,7 @@ static const struct uk_hwaddr *virtio_net_mac_get(struct uk_netdev *n) 68 | 69 | UK_ASSERT(n); 70 | d = to_virtionetdev(n); 71 | - return d->hw_addr; 72 | + return &d->hw_addr; 73 | } 74 | 75 | static __u16 virtio_net_mtu_get(struct uk_netdev *n) 76 | @@ -868,7 +866,7 @@ static int virtio_netdev_feature_negotiate(struct virtio_net_device *vndev) 77 | */ 78 | hw_len = virtio_config_get(vndev->vdev, 79 | __offsetof(struct virtio_net_config, mac), 80 | - &vndev->hw_addr->addr_bytes[0], 81 | + &vndev->hw_addr.addr_bytes[0], 82 | UK_NETDEV_HWADDR_LEN, 1); 83 | if (unlikely(hw_len != UK_NETDEV_HWADDR_LEN)) { 84 | uk_pr_err("Failed to retrieve the mac address from device\n"); 85 | @@ -1124,7 +1122,14 @@ static int virtio_net_add_dev(struct virtio_dev *vdev) 86 | 87 | UK_ASSERT(vdev != NULL); 88 | 89 | + /* FIXME: these two should be identical, and yet they result in a small 90 | + * performance difference. We should investigate further to remove this 91 | + * hack. */ 92 | +#if CONFIG_LIBFLEXOS_NONE 93 | vndev = uk_calloc(a, 1, sizeof(*vndev)); 94 | +#else 95 | + vndev = flexos_calloc_whitelist(1, sizeof(*vndev)); 96 | +#endif 97 | if (!vndev) { 98 | rc = -ENOMEM; 99 | goto err_out; 100 | @@ -1134,10 +1139,6 @@ static int virtio_net_add_dev(struct virtio_dev *vdev) 101 | vndev->netdev.rx_one = virtio_netdev_recv; 102 | vndev->netdev.tx_one = virtio_netdev_xmit; 103 | vndev->netdev.ops = &virtio_netdev_ops; 104 | - vndev->hw_addr = flexos_calloc_whitelist(1, sizeof(*(vndev->hw_addr))); 105 | - /* TODO FLEXOS: investigate, can we actually put this in lwip's domain 106 | - * instead of the shared one? */ 107 | - vndev->netdev.scratch_pad = flexos_calloc_whitelist(1, __PAGE_SIZE); 108 | 109 | rc = uk_netdev_drv_register(&vndev->netdev, a, drv_name); 110 | if (rc < 0) { 111 | @@ -1155,9 +1156,12 @@ static int virtio_net_add_dev(struct virtio_dev *vdev) 112 | exit: 113 | return rc; 114 | err_netdev_data: 115 | - flexos_free_whitelist(vndev->hw_addr); 116 | - flexos_free_whitelist(vndev->netdev.scratch_pad); 117 | +#if CONFIG_LIBFLEXOS_NONE 118 | + /* same comment as above */ 119 | uk_free(a, vndev); 120 | +#else 121 | + flexos_free_whitelist(vndev); 122 | +#endif 123 | err_out: 124 | goto exit; 125 | } 126 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/docker-data/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Authors: Hugo Lefeuvre 4 | 5 | SECONDS=0 6 | 7 | # Run SQLite benchmark for Linux (userland process), Unikraft 0.5 (linuxu and 8 | # kvm), FlexOS (kvm), CubicleOS (linuxu). 9 | 10 | CPU_ISOLED1=$1 11 | CPU_ISOLED2=$2 12 | CPU_ISOLED3=$3 13 | CPU_NOISOLED1=$4 14 | CPU_NOISOLED2=$5 15 | CPU_NOISOLED3=$6 16 | CPU_NOISOLED4=$7 17 | 18 | die() { echo "$*" 1>&2 ; exit 1; } 19 | 20 | if [ -z "$CPU_ISOLED1" ] 21 | then 22 | die "isolated CPU list not provided (read the main README!)" 23 | fi 24 | 25 | if [ -z "$CPU_ISOLED2" ] 26 | then 27 | die "isolated CPU list not provided (read the main README!)" 28 | fi 29 | 30 | if [ -z "$CPU_ISOLED3" ] 31 | then 32 | die "isolated CPU list not provided (read the main README!)" 33 | fi 34 | 35 | if [ -z "$CPU_NOISOLED1" ] 36 | then 37 | die "isolated CPU list not provided (read the main README!)" 38 | fi 39 | 40 | if [ -z "$CPU_NOISOLED2" ] 41 | then 42 | die "isolated CPU list not provided (read the main README!)" 43 | fi 44 | 45 | if [ -z "$CPU_NOISOLED3" ] 46 | then 47 | die "isolated CPU list not provided (read the main README!)" 48 | fi 49 | 50 | if [ -z "$CPU_NOISOLED4" ] 51 | then 52 | die "isolated CPU list not provided (read the main README!)" 53 | fi 54 | 55 | apt install -y bc iperf 56 | 57 | mkdir -p /out/results 58 | tmp=/out/results/iperf.dat 59 | rm $tmp && touch $tmp 60 | 61 | # --------- 62 | # CONSTANTS 63 | # --------- 64 | 65 | # number of reps in this benchmark 66 | REPS=5 67 | 68 | # ------- 69 | # HELPERS 70 | # ------- 71 | 72 | total=0 73 | runs=0 74 | 75 | header() { 76 | echo "" >> $tmp 77 | echo "" >> $tmp 78 | echo "# ${1} ${2}" >> $tmp 79 | echo "# recvbuf-size tx" >> $tmp 80 | } 81 | 82 | parse_output() { 83 | res=`cat .out | awk -e '$0 ~ /0.0-/ {print $7}' | tr -d '\r'` 84 | runs=$((runs+1)) 85 | total=$(echo "$total + $res" | bc -l) 86 | } 87 | 88 | output_avg() { 89 | avg=$(echo "scale=3; $total / $runs" | bc -l ) 90 | echo -e "${1}\t$avg" >> $tmp 91 | total=0 92 | runs=0 93 | } 94 | 95 | benchmark_kvm() { 96 | header $1 "KVM" 97 | t=$((16 * $REPS)) 98 | for i in {4..20}; do 99 | cur=$(echo 2^$i | bc) 100 | for j in $( seq 1 $REPS); do 101 | c=$(($(($i - 4)) * $REPS + $(($j - 1)))) 102 | echo "KVM / $1 run ${c}/${t}" 103 | isept=$( grep -e "CONFIG_LIBFLEXOS_VMEPT=y" .config ) 104 | ./kvm-start.sh run images/${cur}.img $CPU_ISOLED2 $CPU_ISOLED3 $CPU_NOISOLED1 \ 105 | $CPU_NOISOLED2 $CPU_NOISOLED3 $CPU_NOISOLED4 106 | if [ -n "$isept" ]; then 107 | script .out -c "taskset -c $CPU_ISOLED1 iperf -c 172.130.0.76 -p 12345 -t 10 --format g" 108 | else 109 | script .out -c "taskset -c $CPU_ISOLED1 iperf -c 172.130.0.2 -p 12345 -t 10 --format g" 110 | fi 111 | ./kvm-start.sh kill 112 | parse_output 113 | done 114 | output_avg $cur 115 | done 116 | } 117 | 118 | # --------- 119 | # BENCHMARK 120 | # --------- 121 | 122 | # Unikraft baseline NONE 123 | 124 | pushd unikraft-mainline/apps/app-iperf 125 | benchmark_kvm "unikraft-mainline" 126 | popd 127 | 128 | # FlexOS NONE 129 | 130 | pushd flexos/apps/iperf-fcalls 131 | benchmark_kvm "flexos-nompk" 132 | popd 133 | 134 | # FlexOS MPK 2 COMP isolstack 135 | 136 | pushd flexos/apps/iperf-mpk2-isolstack 137 | benchmark_kvm "flexos-mpk2-isolstack" 138 | popd 139 | 140 | # FlexOS MPK 2 COMP noisolstack 141 | 142 | pushd flexos/apps/iperf-mpk2-noisolstack 143 | benchmark_kvm "flexos-mpk2-noisolstack" 144 | popd 145 | 146 | # FlexOS EPT 2 COMP 147 | 148 | pushd flexos/apps/iperf-ept2 149 | benchmark_kvm "flexos-ept2" 150 | popd 151 | 152 | # remove the first two empty lines 153 | tail +3 $tmp 154 | cat $tmp 155 | 156 | duration=$SECONDS 157 | echo "Runtime: $(($duration / 60)) minutes and $(($duration % 60)) seconds." 158 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/docker-data/start-scripts/kvmflexos-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CPU_ISOLED1=$3 4 | CPU_ISOLED2=$4 5 | 6 | NETIF=uk0 7 | IP="172.130.0.2" 8 | 9 | function run { 10 | echo "creating bridge" 11 | brctl addbr $NETIF || true 12 | ifconfig $NETIF 172.130.0.1 13 | taskset -c ${CPU_ISOLED1} /root/qemu-guest -k $1 -x \ 14 | -m 1024 -b ${NETIF} -i /root/img.cpio -p ${CPU_ISOLED2} \ 15 | -a "netdev.ipv4_addr=${IP} netdev.ipv4_gw_addr=172.130.0.254 netdev.ipv4_subnet_mask=255.255.255.0 --" 16 | } 17 | 18 | function killimg { 19 | ifconfig $NETIF down 20 | brctl delbr $NETIF 21 | killall -9 qemu-system-x86 qemu-guest $0 22 | } 23 | 24 | die() { echo "$*" 1>&2 ; exit 1; } 25 | 26 | if [ $# -gt 8 ]; then 27 | die "Usage:\t$0 run \n\t$0 kill" 28 | elif [ $# -eq 0 ]; then 29 | die "Usage:\t$0 run \n\t$0 kill" 30 | else 31 | case "$1" in 32 | run) 33 | run $2 34 | ;; 35 | kill) 36 | killimg 37 | ;; 38 | *) 39 | die "'$1': unsupported argument." 40 | ;; 41 | esac 42 | fi 43 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/docker-data/start-scripts/kvmflexosept2-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CPU_ISOLED1=$3 4 | CPU_ISOLED2=$4 5 | CPU_NOISOLED1=$5 6 | CPU_NOISOLED2=$6 7 | CPU_NOISOLED3=$7 8 | CPU_NOISOLED4=$8 9 | 10 | # ----- 11 | 12 | # EDIT ME if you run me elsewhere 13 | 14 | QEMU_BIN="/root/qemu-system-ept" 15 | 16 | # ----- 17 | 18 | # you should not need to edit these 19 | 20 | MEM=2G 21 | 22 | NETIF=uk0 23 | 24 | BASEIP="172.130.0" 25 | GATEWAY="172.130.0.1" 26 | 27 | # start a dnsmasq server and echo its PID 28 | function run_dhcp { 29 | pkill -9 dnsmasq 30 | dnsmasq -d \ 31 | --log-queries \ 32 | --bind-dynamic \ 33 | --interface=$1 \ 34 | --listen-addr=${2}.1 \ 35 | --dhcp-range=${2}.2,${2}.254,255.255.255.0,12h &> $(pwd)/dnsmasq.log & 36 | echo $! 37 | } 38 | 39 | run() { 40 | TEMP=$(mktemp -d) 41 | 42 | echo "creating bridge" 43 | brctl addbr $NETIF || true 44 | ifconfig $NETIF $GATEWAY 45 | dnsmasq_pid=$(run_dhcp $NETIF $BASEIP) 46 | 47 | # scripts that handle tap creation 48 | cat > ${TEMP}/ifup.sh < ${TEMP}/ifdown.sh <&2 ; exit 1; } 97 | 98 | if [ $# -gt 8 ]; then 99 | die "Usage:\t$0 run \n\t$0 kill" 100 | elif [ $# -eq 0 ]; then 101 | die "Usage:\t$0 run \n\t$0 kill" 102 | else 103 | case "$1" in 104 | run) 105 | run $2 106 | ;; 107 | kill) 108 | killimg 109 | ;; 110 | *) 111 | die "'$1': unsupported argument." 112 | ;; 113 | esac 114 | fi 115 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/flexos-iperf.dockerfile: -------------------------------------------------------------------------------- 1 | # You can easily build it with the following command: 2 | # $ docker build --tag flexos-iperf -f flexos-iperf.dockerfile . 3 | # 4 | # If the build fails because you are rate-limited by GitHub, generate an app 5 | # token () and run instead: 6 | # $ docker build --build-arg UK_KRAFT_GITHUB_TOKEN="" --tag flexos-iperf 7 | # 8 | # and run with: 9 | # $ docker run --privileged --security-opt seccomp:unconfined -ti flexos-iperf bash 10 | # 11 | # (--security-opt seccomp:unconfined to limit docker overhead) 12 | 13 | FROM ghcr.io/project-flexos/flexos-ae-base:latest 14 | 15 | ARG GITHUB_TOKEN= 16 | ENV UK_KRAFT_GITHUB_TOKEN=${GITHUB_TOKEN} 17 | 18 | COPY docker-data/build-images.sh /root/ 19 | 20 | ############## 21 | # FlexOS (KVM) 22 | 23 | COPY docker-data/flexos-net.patch /root/ 24 | WORKDIR /root/.unikraft/apps 25 | 26 | # build flexos with 2 mpk compartments (iperf/rest) and private stacks 27 | RUN kraftcleanup 28 | # The /root/flexos-net.patch patch should be merged into the flexos main tree; the only reason 29 | # why it isn't is because it was added fairly late in the AE process and we didn't want to 30 | # potentially create bugs in other benchmarks. Ultimately, it should improve performance everywhere. 31 | RUN cd /root/.unikraft/unikraft && git checkout fdc605c0cc482c4d230885962d8aae1ad558157b && \ 32 | git apply /root/flexos-net.patch 33 | RUN sed -i "s/TCP_WND 32766/TCP_WND 65335/g" /root/.unikraft/libs/lwip/include/lwipopts.h 34 | COPY docker-data/configs/iperf-flexos-mpk2.config /root/.unikraft/apps/iperf/.config 35 | RUN cd iperf && make prepare && kraft -v build --no-progress --fast --compartmentalize 36 | COPY docker-data/start-scripts/kvmflexos-start.sh /root/.unikraft/apps/iperf/kvm-start.sh 37 | RUN cd iperf && /root/build-images.sh && rm -rf build/ 38 | RUN mv iperf iperf-mpk2-isolstack 39 | 40 | # build flexos with 2 mpk compartments (iperf/rest) and shared stacks 41 | RUN kraftcleanup 42 | RUN cd /root/.unikraft/unikraft && git checkout fdc605c0cc482c4d230885962d8aae1ad558157b && \ 43 | git apply /root/flexos-net.patch 44 | RUN sed -i "s/TCP_WND 32766/TCP_WND 65335/g" /root/.unikraft/libs/lwip/include/lwipopts.h 45 | RUN rm -rf /root/.unikraft/apps/iperf && cp -r iperf-mpk2-isolstack iperf-mpk2-noisolstack 46 | RUN sed -i "s/CONFIG_LIBFLEXOS_GATE_INTELPKU_PRIVATE_STACKS=y/# CONFIG_LIBFLEXOS_GATE_INTELPKU_PRIVATE_STACKS is not set/g" \ 47 | iperf-mpk2-noisolstack/.config 48 | RUN sed -i "s/CONFIG_LIBFLEXOS_ENABLE_DSS=y/# CONFIG_LIBFLEXOS_ENABLE_DSS is not set/g" \ 49 | iperf-mpk2-noisolstack/.config 50 | RUN sed -i "s/# CONFIG_LIBFLEXOS_GATE_INTELPKU_SHARED_STACKS is not set/CONFIG_LIBFLEXOS_GATE_INTELPKU_SHARED_STACKS=y/g" \ 51 | iperf-mpk2-noisolstack/.config 52 | RUN cd iperf-mpk2-noisolstack && rm -rf images build 53 | RUN cd iperf-mpk2-noisolstack && make prepare && kraft -v build --no-progress --fast --compartmentalize 54 | RUN cd iperf-mpk2-noisolstack && /root/build-images.sh && rm -rf build/ 55 | 56 | # build flexos with 2 ept compartments (iperf/rest) 57 | RUN kraftcleanup 58 | RUN sed -i "s/TCP_WND 32766/TCP_WND 65335/g" /root/.unikraft/libs/lwip/include/lwipopts.h 59 | RUN cd /root/.unikraft/unikraft && git checkout fdc605c0cc482c4d230885962d8aae1ad558157b && \ 60 | git apply /root/flexos-net.patch && git apply /root/ept2-tmpfix.patch 61 | COPY docker-data/configs/iperf-flexos-ept2.config iperf/.config 62 | COPY docker-data/configs/kraft.yaml.ept2 iperf/kraft.yaml 63 | RUN cd iperf && /root/build-images.sh && rm -rf build/ 64 | COPY docker-data/start-scripts/kvmflexosept2-start.sh iperf/kvm-start.sh 65 | RUN mv iperf iperf-ept2 66 | 67 | # build flexos with no compartments 68 | RUN kraftcleanup 69 | RUN cd /root/.unikraft/unikraft && git checkout fdc605c0cc482c4d230885962d8aae1ad558157b && \ 70 | git apply /root/flexos-net.patch 71 | # There is a bug in the FlexOS toolchain that causes instable measurements with the fcalls 72 | # backend. It will be fixed for the 0.2 release. For now, this workaround should be equivalent 73 | # to a proper fix in the toolchain. 74 | RUN cd ../libs && rm -rf lwip && git clone https://github.com/unikraft/lib-lwip.git && mv lib-lwip lwip 75 | RUN cd ../libs/lwip && git checkout 3c85bd46a3f764039d8f6e3128c8f5d7096dbd13 76 | RUN sed -i "s/TCP_WND 32766/TCP_WND 65335/g" ../libs/lwip/include/lwipopts.h 77 | RUN mv /root/.unikraft/apps/iperf /root/.unikraft/apps/iperf-fcalls 78 | COPY docker-data/configs/iperf-flexos-fcalls.config /root/.unikraft/apps/iperf-fcalls/.config 79 | COPY docker-data/configs/kraft.yaml.fcalls /root/.unikraft/apps/iperf-fcalls/kraft.yaml 80 | RUN cd iperf-fcalls && make prepare && kraft -v build --no-progress --fast --compartmentalize 81 | RUN cd iperf-fcalls && /root/build-images.sh && rm -rf build/ 82 | COPY docker-data/start-scripts/kvmflexos-start.sh /root/.unikraft/apps/iperf-fcalls/kvm-start.sh 83 | 84 | RUN mv /root/.unikraft /root/flexos 85 | 86 | ############## 87 | # Unikraft 0.5 (KVM and linuxu) 88 | # Performance is similar to Unikraft 0.4, so omit it. 89 | 90 | WORKDIR /root/unikraft-mainline/libs 91 | 92 | # page table support patch 93 | COPY docker-data/unikraft-pagetable.patch /tmp/pt.patch 94 | RUN cd /root/unikraft-mainline/unikraft && git apply /tmp/pt.patch --ignore-whitespace 95 | 96 | RUN git clone https://github.com/unikraft/lib-newlib.git 97 | RUN cd lib-newlib && git checkout ddc25cf1f361e33d1003ce1842212e8ff37b1e08 98 | 99 | RUN git clone https://github.com/unikraft/lib-pthread-embedded.git 100 | RUN cd lib-pthread-embedded && git checkout 2dd71294ab5fac328e62932992550405c866c7e8 101 | 102 | RUN cp -r /root/flexos/libs/iperf lib-iperf 103 | # use unikraft baseline branch 104 | RUN cd lib-iperf && git clean -xdf && git checkout . && git checkout 120324e7986f8fb7a90debd7637708c8485de519 105 | 106 | RUN git clone https://github.com/unikraft/lib-tlsf.git 107 | RUN cd lib-tlsf && git checkout ae4f7402a2c5ee6040dab799b397537177306cc9 108 | 109 | RUN git clone https://github.com/unikraft/lib-lwip.git 110 | RUN cd lib-lwip && git checkout 3c85bd46a3f764039d8f6e3128c8f5d7096dbd13 111 | RUN sed -i "s/TCP_WND 32766/TCP_WND 65335/g" lib-lwip/include/lwipopts.h 112 | 113 | WORKDIR /root/unikraft-mainline/apps 114 | 115 | RUN cp -r /root/flexos/apps/iperf-fcalls/ app-iperf 116 | # use unikraft baseline branch 117 | RUN cd app-iperf && git clean -xdf && git checkout . && git checkout 7cda87c1b39398b7338a01bb59bdefdcc03efd73 118 | COPY docker-data/configs/iperf-unikraft.config app-iperf/.config 119 | RUN cd app-iperf && /root/build-images.sh && rm -rf build/ 120 | RUN cp /root/flexos/apps/iperf-fcalls/kvm-start.sh app-iperf/kvm-start.sh 121 | 122 | ############## 123 | # Finish 124 | 125 | WORKDIR /root 126 | 127 | COPY docker-data/run.sh . 128 | RUN chmod u+x run.sh 129 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/iperf.plot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | 3 | reset 4 | 5 | set terminal svg enhanced size 650,300 font 'Arial,20' 6 | set output '/out/iperf.svg' 7 | 8 | set grid 9 | 10 | # Make the x axis labels easier to read. 11 | set xtics font ",18" nomirror 12 | set ytics nomirror 13 | 14 | # make sure that the legend doesn't take too much space 15 | set key inside bottom right samplen 1 font ',18' width -7 16 | 17 | # ensure that y label doesn't take too much space 18 | set ylabel "iPerf throughput (Gb/s)" offset 2.5,0 19 | set xlabel "Receive Buffer Size" offset 0,0.5 20 | 21 | # remove useless margins 22 | #set bmargin 2 23 | set lmargin 7 24 | set rmargin 1 25 | set tmargin 0.5 26 | 27 | # use logscale, display powers of two 28 | set logscale x 2 29 | set logscale y 2 30 | set format x '2^{%L}' 31 | 32 | # line styles 33 | set style line 1 \ 34 | linecolor rgb '#2C1320' \ 35 | linetype 1 linewidth 2 \ 36 | pointtype 7 pointsize 0.5 37 | set style line 2 \ 38 | linecolor rgb '#66A182' \ 39 | linetype 1 linewidth 2 \ 40 | pointtype 5 pointsize 0.5 41 | set style line 3 \ 42 | linecolor rgb '#7F95D1' \ 43 | linetype 1 linewidth 2 \ 44 | pointtype 11 pointsize 0.5 45 | set style line 4 \ 46 | linecolor rgb '#306BAC' \ 47 | linetype 1 linewidth 2 \ 48 | pointtype 9 pointsize 0.5 49 | set style line 5 \ 50 | linecolor rgb '#AF9BB6' \ 51 | linetype 1 linewidth 2 \ 52 | pointtype 13 pointsize 0.5 53 | 54 | # use this to set the range, although the default one seems to be good here 55 | #set yrange [0:3.5] 56 | set xrange [16:16384] 57 | 58 | plot '/out/results/iperf.dat' \ 59 | index 0 with linespoints linestyle 1 t "Unikraft", \ 60 | '' index 1 with linespoints linestyle 2 t "FlexOS NONE", \ 61 | '' index 3 with linespoints linestyle 3 t "FlexOS MPK2-light", \ 62 | '' index 2 with linespoints linestyle 4 t "FlexOS MPK2-dss", \ 63 | '' index 4 with linespoints linestyle 5 t "FlexOS EPT2" 64 | -------------------------------------------------------------------------------- /experiments/fig-09_iperf-throughput/results/iperf.dat: -------------------------------------------------------------------------------- 1 | 2 | 3 | # unikraft-mainline KVM 4 | # recvbuf-size tx 5 | 16 .980 6 | 32 1.634 7 | 64 2.876 8 | 128 2.926 9 | 256 2.918 10 | 512 2.884 11 | 1024 2.832 12 | 2048 2.972 13 | 4096 2.842 14 | 8192 2.918 15 | 16384 2.926 16 | 32768 3.010 17 | 65536 2.986 18 | 131072 2.968 19 | 262144 2.966 20 | 524288 2.930 21 | 1048576 2.980 22 | 23 | 24 | # flexos-nompk KVM 25 | # recvbuf-size tx 26 | 16 1.056 27 | 32 1.554 28 | 64 2.852 29 | 128 2.998 30 | 256 3.010 31 | 512 3.038 32 | 1024 2.996 33 | 2048 3.020 34 | 4096 2.994 35 | 8192 3.044 36 | 16384 3.042 37 | 32768 3.052 38 | 65536 3.070 39 | 131072 3.024 40 | 262144 3.058 41 | 524288 3.038 42 | 1048576 3.058 43 | 44 | 45 | # flexos-mpk2-isolstack KVM 46 | # recvbuf-size tx 47 | 16 .798 48 | 32 1.066 49 | 64 2.038 50 | 128 2.930 51 | 256 2.956 52 | 512 2.942 53 | 1024 3.008 54 | 2048 3.002 55 | 4096 2.990 56 | 8192 3.010 57 | 16384 3.032 58 | 32768 3.022 59 | 65536 3.042 60 | 131072 3.060 61 | 262144 3.030 62 | 524288 3.054 63 | 1048576 3.020 64 | 65 | 66 | # flexos-mpk2-noisolstack KVM 67 | # recvbuf-size tx 68 | 16 .806 69 | 32 1.214 70 | 64 2.186 71 | 128 2.878 72 | 256 2.962 73 | 512 2.974 74 | 1024 2.988 75 | 2048 2.946 76 | 4096 2.988 77 | 8192 3.006 78 | 16384 3.016 79 | 32768 3.020 80 | 65536 3.018 81 | 131072 3.024 82 | 262144 3.052 83 | 524288 3.012 84 | 1048576 2.990 85 | 86 | 87 | # flexos-ept2 KVM 88 | # recvbuf-size tx 89 | 16 .360 90 | 32 .650 91 | 64 1.072 92 | 128 1.688 93 | 256 2.730 94 | 512 2.770 95 | 1024 2.828 96 | 2048 2.796 97 | 4096 2.836 98 | 8192 2.894 99 | 16384 2.882 100 | 32768 2.896 101 | 65536 2.884 102 | 131072 2.872 103 | 262144 2.918 104 | 524288 2.802 105 | 1048576 2.798 106 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/.gitignore: -------------------------------------------------------------------------------- 1 | results/latency-linux.dat 2 | results/latency-linux-nokpti.dat 3 | results/latency-flexos.dat 4 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Files and directories 3 | # 4 | WORKDIR ?= $(CURDIR) 5 | RESULTS ?= $(WORKDIR) 6 | PLOT_FORMAT ?= svg 7 | PLOT ?= $(WORKDIR)/$(notdir $(WORKDIR)).$(PLOT_FORMAT) 8 | 9 | # 10 | # Parameters 11 | # 12 | KRAFT_TOKEN ?= 13 | ISOLED_CPU1 ?= 5 14 | ISOLED_CPU2 ?= 6 15 | 16 | # 17 | # Tools 18 | # 19 | GNUPLOT ?= gnuplot 20 | DOCKER ?= docker 21 | TIME ?= /usr/bin/time 22 | 23 | # 24 | # Targets 25 | # 26 | .PHONY: all 27 | all: prepare run plot 28 | 29 | .PHONY: prepare 30 | prepare: 31 | $(TIME) $(DOCKER) build -f $(WORKDIR)/flexos-sqlite.dockerfile \ 32 | --build-arg GITHUB_TOKEN="$(KRAFT_TOKEN)" \ 33 | --tag flexos-sqlite $(WORKDIR) 34 | 35 | .PHONY: run 36 | run: 37 | $(DOCKER) run --rm -v $(WORKDIR):/out --privileged \ 38 | --security-opt seccomp:unconfined -ti flexos-sqlite \ 39 | /root/run.sh $(ISOLED_CPU1) $(ISOLED_CPU2) 40 | 41 | .PHONY: plot 42 | plot: 43 | rm -rf $(PLOT) 44 | $(DOCKER) run --rm -v $(WORKDIR):/out --privileged -ti \ 45 | ghcr.io/project-flexos/flexos-ae-plot $(GNUPLOT) /out/sqlite.plot 46 | mv $(WORKDIR)/sqlite.svg $(PLOT) 47 | 48 | .PHONY: clean 49 | clean: 50 | rm -rf results $(PLOT) 51 | 52 | .PHONY: properclean 53 | properclean: clean 54 | $(DOCKER) image rm -f flexos-sqlite 55 | $(DOCKER) image prune -f 56 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/README.md: -------------------------------------------------------------------------------- 1 | # SQLite Performance Comparison 2 | 3 | 4 | 5 | | Estimated prep. time | Estimated runtime | 6 | | -------------------- | ----------------- | 7 | | 0h 40m | 0h 09m | 8 | 9 | ## Overview 10 | 11 | Time to perform 5000 INSERT queries with SQLite on Unikraft, FlexOS, Linux, SeL4 12 | (with the Genode system), and CubicleOS. The isolation profile is shown on the x 13 | axis (NONE: no isolation, MPK3: MPK with three compartments, EPT2: two 14 | compartments with EPT, PT2/3: two/three compartments with page-table-based 15 | isolation). 16 | 17 | ### Plot 18 | 19 | The plot contains some hardcoded data. If you want to generate a plot 20 | for your new run, you will need to edit the plot script. The values that you 21 | will want to adapt are the labels in the latency plot (and potentially their 22 | position). 23 | 24 | ## Troubleshooting 25 | 26 | - **Problem**: The run script hangs while benchmarking CubicleOS, with messages 27 | such as 28 | ``` 29 | cannot allocate memory for SQLITE 30 | ``` 31 | 32 | **Solution**: This is a known CubicleOS bug. In this case, simply terminate the 33 | current run with `CTRL-C`; the results for this run will not be considered in the 34 | final average. 35 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/Makefile: -------------------------------------------------------------------------------- 1 | UK_ROOT ?= $(PWD)/../../unikraft 2 | UK_LIBS ?= $(PWD)/../../libs 3 | LIBS := $(UK_LIBS)/lib-pthread-embedded:$(UK_LIBS)/lib-newlib:$(UK_LIBS)/lib-sqlite:$(UK_LIBS)/lib-tlsf 4 | all: 5 | @$(MAKE) -C $(UK_ROOT) A=$(PWD) L=$(LIBS) 6 | $(MAKECMDGOALS): 7 | @$(MAKE) -C $(UK_ROOT) A=$(PWD) L=$(LIBS) $(MAKECMDGOALS) 8 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/configs/genode.conf: -------------------------------------------------------------------------------- 1 | GENODE_DIR := /genode 2 | BASE_DIR := $(GENODE_DIR)/repos/base 3 | CONTRIB_DIR := $(GENODE_DIR)/contrib 4 | 5 | # enable parallel build 6 | #MAKE += -j4 7 | 8 | 9 | ## 10 | ## Run-tool configuration 11 | ## 12 | 13 | # create depot archives and update recipe versions automatically 14 | #RUN_OPT += --depot-auto-update 15 | 16 | # kernel to use (nova, hw, sel4, linux, or foc) 17 | KERNEL ?= sel4 18 | 19 | # board to use (pc, linux, or muen) 20 | BOARD ?= pc 21 | 22 | # local variable for run-tool arguments that depend on the used board 23 | BOARD_RUN_OPT(muen) = --include image/muen 24 | BOARD_RUN_OPT(muen) += --image-muen-hardware hardware/lenovo-t430s.xml 25 | BOARD_RUN_OPT(muen) += --image-muen-platform platform/lenovo-t430s.xml 26 | BOARD_RUN_OPT(muen) += --image-muen-gnat-path /opt/gnat 27 | BOARD_RUN_OPT(muen) += --image-muen-spark-path /opt/spark 28 | BOARD_RUN_OPT(muen) += --image-muen-system xml/genode-base_hw.xml 29 | BOARD_RUN_OPT(muen) += --image-muen-components 'libdebuglog libmudm libmutime libxhcidbg dbgserver sm time' 30 | BOARD_RUN_OPT(muen) += --image-muen-external-build 0 31 | BOARD_RUN_OPT(linux) = --include power_on/linux --include log/linux 32 | BOARD_RUN_OPT(pc) = $(QEMU_RUN_OPT) 33 | 34 | # local variable for run-tool arguments used for running scenarios in Qemu 35 | QEMU_RUN_OPT := --include power_on/qemu --include log/qemu --include image/iso 36 | 37 | 38 | ## 39 | ## Qemu arguments, effective when using the run tool's 'power_on/qemu' back end 40 | ## 41 | 42 | # enable GDB stub 43 | #QEMU_OPT += -s 44 | 45 | QEMU_OPT += -enable-kvm -m 3G 46 | 47 | # use time-tested graphics backend 48 | QEMU_OPT += -display sdl 49 | 50 | # use machine model that supports nested virtualization 51 | QEMU_OPT(nova) += -cpu core2duo 52 | 53 | # add kernel-specific Qemu arguments 54 | QEMU_OPT += $(QEMU_OPT(${KERNEL})) 55 | 56 | ifdef BOARD 57 | RUN_OPT += ${BOARD_RUN_OPT(${BOARD})} 58 | endif 59 | 60 | ifdef KERNEL 61 | RUN_OPT += --include boot_dir/$(KERNEL) 62 | endif 63 | 64 | 65 | ## 66 | ## Kernel-specific repository 67 | ## 68 | 69 | ifdef KERNEL 70 | REPOSITORIES += $(GENODE_DIR)/repos/base-$(KERNEL) 71 | endif 72 | 73 | ## 74 | ## Repositories needed for the default demo scenario 75 | ## 76 | 77 | REPOSITORIES += $(GENODE_DIR)/repos/base 78 | REPOSITORIES += $(GENODE_DIR)/repos/os 79 | REPOSITORIES += $(GENODE_DIR)/repos/demo 80 | 81 | 82 | ## 83 | ## Optional repositories 84 | ## 85 | 86 | # 87 | # Ports of popular open-source libraries and the C library. 88 | # 89 | # Make sure to execute 'make prepare' in 'libports' prior building. 90 | # 91 | REPOSITORIES += $(GENODE_DIR)/repos/libports 92 | 93 | # 94 | # Ports of popular 3rd-party applications 95 | # 96 | # The 'ports' repository depends on 'libc' and 'libports'. 97 | # Make sure to execute 'make prepare' in 'ports' prior building. 98 | # 99 | #REPOSITORIES += $(GENODE_DIR)/repos/ports 100 | 101 | # 102 | # Ports of the Linux TCP/IP stack and Linux drivers (USB) from the Linux kernel 103 | # 104 | #REPOSITORIES += $(GENODE_DIR)/repos/dde_linux 105 | 106 | # 107 | # NetBSD file-system support 108 | # 109 | #REPOSITORIES += $(GENODE_DIR)/repos/dde_rump 110 | 111 | # 112 | # High-level Genode-specific services and applications 113 | # 114 | # The 'gems' repository depends on 'libc' and 'libports'. 115 | # 116 | #REPOSITORIES += $(GENODE_DIR)/repos/gems 117 | 118 | # 119 | # Collection of community-maintained components 120 | # 121 | # Please follow the instructions provided at: 122 | # 123 | # https://github.com/genodelabs/genode-world 124 | # 125 | #REPOSITORIES += $(GENODE_DIR)/repos/world 126 | 127 | # 128 | # Drivers ported from the OpenBSD 129 | # 130 | #REPOSITORIES += $(GENODE_DIR)/repos/dde_bsd 131 | 132 | # 133 | # Drivers ported from iPXE 134 | # 135 | #REPOSITORIES += $(GENODE_DIR)/repos/dde_ipxe 136 | 137 | # 138 | # Drivers ported from Zircon 139 | # 140 | #REPOSITORIES += $(GENODE_DIR)/repos/dde_zircon 141 | 142 | REPOSITORIES += $(GENODE_DIR)/repos/sqlite 143 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/configs/kraft.yaml.ept2: -------------------------------------------------------------------------------- 1 | --- 2 | specification: '0.6' 3 | name: sqlite 4 | unikraft: 5 | version: staging 6 | kconfig: 7 | - CONFIG_LIBDEVFS=y 8 | - CONFIG_LIBDEVFS_AUTOMOUNT=y 9 | - CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y 10 | - CONFIG_LIBVFSCORE_ROOTFS_9PFS=y 11 | - CONFIG_LIBUKLIBPARAM=y 12 | - CONFIG_LIBVFSCORE_ROOTDEV="fs0" 13 | # Select other options needed by sqlite 14 | - CONFIG_LIBUKMMAP=y 15 | - CONFIG_LIBPOSIX_SYSINFO=y 16 | targets: 17 | - architecture: x86_64 18 | platform: kvm 19 | compartments: 20 | - name: comp1 21 | mechanism: 22 | driver: vmept 23 | default: true 24 | - name: comp2 25 | mechanism: 26 | driver: vmept 27 | libraries: 28 | vfscore: 29 | is_core: true 30 | compartment: comp2 31 | ramfs: 32 | is_core: true 33 | compartment: comp2 34 | pthread-embedded: 35 | version: staging 36 | compartment: comp1 37 | newlib: 38 | version: staging 39 | kconfig: 40 | - CONFIG_LIBNEWLIBC=y 41 | compartment: comp1 42 | sqlite: 43 | version: staging 44 | kconfig: 45 | - CONFIG_LIBSQLITE_MAIN_FUNCTION=n 46 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/configs/kraft.yaml.fcalls: -------------------------------------------------------------------------------- 1 | --- 2 | specification: '0.6' 3 | name: sqlite 4 | unikraft: 5 | version: staging 6 | kconfig: 7 | - CONFIG_LIBDEVFS=y 8 | - CONFIG_LIBDEVFS_AUTOMOUNT=y 9 | - CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y 10 | - CONFIG_LIBVFSCORE_ROOTFS_9PFS=y 11 | - CONFIG_LIBUKLIBPARAM=y 12 | - CONFIG_LIBVFSCORE_ROOTDEV="fs0" 13 | # Select other options needed by sqlite 14 | - CONFIG_LIBUKMMAP=y 15 | - CONFIG_LIBPOSIX_SYSINFO=y 16 | targets: 17 | - architecture: x86_64 18 | platform: kvm 19 | compartments: 20 | - name: comp1 21 | mechanism: 22 | driver: fcalls 23 | default: true 24 | libraries: 25 | tlsf: 26 | version: staging 27 | kconfig: 28 | - CONFIG_LIBTLSF=y 29 | pthread-embedded: 30 | version: staging 31 | compartment: comp1 32 | newlib: 33 | version: staging 34 | kconfig: 35 | - CONFIG_LIBNEWLIBC=y 36 | compartment: comp1 37 | sqlite: 38 | version: staging 39 | kconfig: 40 | - CONFIG_LIBSQLITE_MAIN_FUNCTION=n 41 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/configs/kraft.yaml.mpk3: -------------------------------------------------------------------------------- 1 | --- 2 | specification: '0.6' 3 | name: sqlite 4 | unikraft: 5 | version: staging 6 | kconfig: 7 | - CONFIG_LIBDEVFS=y 8 | - CONFIG_LIBDEVFS_AUTOMOUNT=y 9 | - CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y 10 | - CONFIG_LIBVFSCORE_ROOTFS_9PFS=y 11 | - CONFIG_LIBUKLIBPARAM=y 12 | - CONFIG_LIBVFSCORE_ROOTDEV="fs0" 13 | # Select other options needed by sqlite 14 | - CONFIG_LIBUKMMAP=y 15 | - CONFIG_LIBPOSIX_SYSINFO=y 16 | targets: 17 | - architecture: x86_64 18 | platform: kvm 19 | compartments: 20 | - name: comp1 21 | mechanism: 22 | driver: intel-pku 23 | default: true 24 | - name: comp2 25 | mechanism: 26 | driver: intel-pku 27 | - name: comp3 28 | mechanism: 29 | driver: intel-pku 30 | libraries: 31 | uktime: 32 | is_core: true 33 | compartment: comp3 34 | vfscore: 35 | is_core: true 36 | compartment: comp2 37 | ramfs: 38 | is_core: true 39 | compartment: comp2 40 | cpio: 41 | is_core: true 42 | compartment: comp2 43 | tlsf: 44 | version: staging 45 | kconfig: 46 | - CONFIG_LIBTLSF=y 47 | pthread-embedded: 48 | version: staging 49 | compartment: comp1 50 | newlib: 51 | version: staging 52 | kconfig: 53 | - CONFIG_LIBNEWLIBC=y 54 | compartment: comp1 55 | sqlite: 56 | version: staging 57 | kconfig: 58 | - CONFIG_LIBSQLITE_MAIN_FUNCTION=n 59 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/configs/sqlite-flexos-ept2.config: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated file; DO NOT EDIT. 3 | # Unikraft/0.5.0~789bfde-custom Configuration 4 | # 5 | CONFIG_UK_FULLVERSION="0.5.0~789bfde-custom" 6 | CONFIG_UK_CODENAME="Tethys" 7 | CONFIG_UK_ARCH="x86_64" 8 | CONFIG_UK_BASE="/root/.unikraft/unikraft" 9 | CONFIG_UK_APP="/root/.unikraft/apps/sqlite" 10 | CONFIG_UK_DEFNAME="sqlite" 11 | 12 | # 13 | # Architecture Selection 14 | # 15 | CONFIG_ARCH_X86_64=y 16 | # CONFIG_ARCH_ARM_64 is not set 17 | # CONFIG_ARCH_ARM_32 is not set 18 | # CONFIG_MARCH_X86_64_NATIVE is not set 19 | CONFIG_MARCH_X86_64_GENERIC=y 20 | # CONFIG_MARCH_X86_64_NOCONA is not set 21 | # CONFIG_MARCH_X86_64_CORE2 is not set 22 | # CONFIG_MARCH_X86_64_COREI7 is not set 23 | # CONFIG_MARCH_X86_64_COREI7AVX is not set 24 | # CONFIG_MARCH_X86_64_COREI7AVXI is not set 25 | # CONFIG_MARCH_X86_64_ATOM is not set 26 | # CONFIG_MARCH_X86_64_K8 is not set 27 | # CONFIG_MARCH_X86_64_K8SSE3 is not set 28 | # CONFIG_MARCH_X86_64_AMDFAM10 is not set 29 | # CONFIG_MARCH_X86_64_BTVER1 is not set 30 | # CONFIG_MARCH_X86_64_BDVER1 is not set 31 | # CONFIG_MARCH_X86_64_BDVER2 is not set 32 | # CONFIG_MARCH_X86_64_BDVER3 is not set 33 | # CONFIG_MARCH_X86_64_BTVER2 is not set 34 | CONFIG_STACK_SIZE_PAGE_ORDER=4 35 | # end of Architecture Selection 36 | 37 | # 38 | # Platform Configuration 39 | # 40 | CONFIG_PLAT_KVM=y 41 | 42 | # 43 | # Console Options 44 | # 45 | CONFIG_KVM_KERNEL_SERIAL_CONSOLE=y 46 | CONFIG_KVM_KERNEL_VGA_CONSOLE=y 47 | CONFIG_KVM_DEBUG_SERIAL_CONSOLE=y 48 | CONFIG_KVM_DEBUG_VGA_CONSOLE=y 49 | 50 | # 51 | # Serial console configuration 52 | # 53 | CONFIG_KVM_SERIAL_BAUD_115200=y 54 | # CONFIG_KVM_SERIAL_BAUD_57600 is not set 55 | # CONFIG_KVM_SERIAL_BAUD_38400 is not set 56 | # CONFIG_KVM_SERIAL_BAUD_19200 is not set 57 | # end of Serial console configuration 58 | # end of Console Options 59 | 60 | CONFIG_KVM_PCI=y 61 | CONFIG_VIRTIO_BUS=y 62 | 63 | # 64 | # Virtio 65 | # 66 | # CONFIG_VIRTIO_PCI is not set 67 | # end of Virtio 68 | 69 | # CONFIG_PLAT_LINUXU is not set 70 | # CONFIG_PLAT_XEN is not set 71 | 72 | # 73 | # Platform Interface Options 74 | # 75 | CONFIG_UKPLAT_MEMRNAME=y 76 | CONFIG_PT_API=y 77 | CONFIG_DYNAMIC_PT=y 78 | # end of Platform Interface Options 79 | 80 | CONFIG_HZ=100 81 | # end of Platform Configuration 82 | 83 | # 84 | # Library Configuration 85 | # 86 | # CONFIG_LIBDEVFS is not set 87 | # CONFIG_LIBFDT is not set 88 | CONFIG_LIBFLEXOS=y 89 | # CONFIG_LIBFLEXOS_INTELPKU is not set 90 | CONFIG_LIBFLEXOS_VMEPT=y 91 | # CONFIG_LIBFLEXOS_VMEPT_LIBRARY is not set 92 | # CONFIG_LIBFLEXOS_NONE is not set 93 | CONFIG_LIBFLEXOS_COMP_HEAP_SIZE=10000 94 | # CONFIG_LIBFLEXOS_DEBUG is not set 95 | # CONFIG_LIBKASAN is not set 96 | # CONFIG_LIBPOSIX_LIBDL is not set 97 | # CONFIG_LIBPOSIX_MMAP is not set 98 | CONFIG_LIBPOSIX_PROCESS=y 99 | CONFIG_LIBPOSIX_SYSINFO=y 100 | CONFIG_LIBPOSIX_USER=y 101 | CONFIG_LIBRAMFS=y 102 | # CONFIG_LIBSYSCALL_SHIM is not set 103 | # CONFIG_LIBUBSAN is not set 104 | # CONFIG_LIBUK9P is not set 105 | CONFIG_LIBUKALLOC=y 106 | CONFIG_LIBUKALLOC_IFMALLOC=y 107 | # CONFIG_LIBUKALLOC_IFSTATS is not set 108 | CONFIG_LIBUKALLOCBBUDDY=y 109 | # CONFIG_LIBUKALLOCPOOL is not set 110 | # CONFIG_LIBUKALLOCREGION is not set 111 | CONFIG_LIBUKARGPARSE=y 112 | # CONFIG_LIBUKBLKDEV is not set 113 | CONFIG_LIBUKBOOT=y 114 | CONFIG_LIBUKBOOT_BANNER_NONE=y 115 | # CONFIG_LIBUKBOOT_BANNER_MINIMAL is not set 116 | # CONFIG_LIBUKBOOT_BANNER_CLASSIC is not set 117 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY is not set 118 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI is not set 119 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI2 is not set 120 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EA is not set 121 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI is not set 122 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI2 is not set 123 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8 is not set 124 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI is not set 125 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI2 is not set 126 | CONFIG_LIBUKBOOT_MAXNBARGS=60 127 | CONFIG_LIBUKBOOT_INITBBUDDY=y 128 | # CONFIG_LIBUKBOOT_INITREGION is not set 129 | # CONFIG_LIBUKBOOT_INITTLSF is not set 130 | # CONFIG_LIBUKBOOT_NOALLOC is not set 131 | CONFIG_LIBUKBUS=y 132 | CONFIG_LIBUKDEBUG=y 133 | CONFIG_LIBUKDEBUG_PRINTK=y 134 | # CONFIG_LIBUKDEBUG_PRINTK_INFO is not set 135 | # CONFIG_LIBUKDEBUG_PRINTK_WARN is not set 136 | CONFIG_LIBUKDEBUG_PRINTK_ERR=y 137 | # CONFIG_LIBUKDEBUG_PRINTK_CRIT is not set 138 | # CONFIG_LIBUKDEBUG_PRINTD is not set 139 | # CONFIG_LIBUKDEBUG_NOREDIR is not set 140 | CONFIG_LIBUKDEBUG_REDIR_PRINTD=y 141 | # CONFIG_LIBUKDEBUG_REDIR_PRINTK is not set 142 | CONFIG_LIBUKDEBUG_PRINT_TIME=y 143 | # CONFIG_LIBUKDEBUG_PRINT_STACK is not set 144 | CONFIG_LIBUKDEBUG_PRINT_SRCNAME=y 145 | CONFIG_LIBUKDEBUG_ANSI_COLOR=y 146 | # CONFIG_LIBUKDEBUG_ENABLE_ASSERT is not set 147 | # CONFIG_LIBUKDEBUG_TRACEPOINTS is not set 148 | CONFIG_LIBUKLIBPARAM=y 149 | CONFIG_LIBUKLOCK=y 150 | CONFIG_LIBUKLOCK_SEMAPHORE=y 151 | CONFIG_LIBUKLOCK_MUTEX=y 152 | CONFIG_LIBUKMMAP=y 153 | # CONFIG_LIBUKMPI is not set 154 | # CONFIG_LIBUKNETDEV is not set 155 | # CONFIG_LIBUKRING is not set 156 | CONFIG_LIBUKSCHED=y 157 | CONFIG_LIBUKSCHEDCOOP=y 158 | CONFIG_LIBUKSGLIST=y 159 | CONFIG_LIBUKSIGNAL=y 160 | # CONFIG_LIBUKSP is not set 161 | # CONFIG_LIBUKSWRAND is not set 162 | CONFIG_LIBUKTIME=y 163 | CONFIG_LIBUKTIMECONV=y 164 | CONFIG_LIBVFSCORE=y 165 | 166 | # 167 | # vfscore: Configuration 168 | # 169 | CONFIG_LIBCPIO=y 170 | CONFIG_LIBINITRAMFS=y 171 | CONFIG_LIBVFSCORE_PIPE_SIZE_ORDER=16 172 | CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y 173 | CONFIG_LIBVFSCORE_ROOTFS_RAMFS=y 174 | # CONFIG_LIBVFSCORE_ROOTFS_9PFS is not set 175 | # CONFIG_LIBVFSCORE_ROOTFS_CUSTOM is not set 176 | CONFIG_LIBVFSCORE_ROOTFS="ramfs" 177 | # end of vfscore: Configuration 178 | 179 | CONFIG_HAVE_BOOTENTRY=y 180 | CONFIG_HAVE_LIBC=y 181 | CONFIG_HAVE_TIME=y 182 | CONFIG_HAVE_SCHED=y 183 | CONFIG_LIBPTHREAD_EMBEDDED=y 184 | CONFIG_LIBPTHREAD_EMBEDDED_MAX_SIMUL_THREADS=32 185 | CONFIG_LIBPTHREAD_EMBEDDED_MAX_TLS=32 186 | # CONFIG_LIBPTHREAD_EMBEDDED_UTEST is not set 187 | CONFIG_LIBNEWLIBC=y 188 | CONFIG_LIBNEWLIBM=y 189 | # CONFIG_LIBNEWLIBC_WANT_IO_C99_FORMATS is not set 190 | # CONFIG_LIBNEWLIBC_LINUX_ERRNO_EXTENSIONS is not set 191 | CONFIG_LIBNEWLIBC_CRYPT=y 192 | CONFIG_LIBSQLITE=y 193 | # CONFIG_LIBSQLITE_MAIN_FUNCTION is not set 194 | CONFIG_LIBTLSF_INCLUDED=y 195 | # CONFIG_LIBTLSF is not set 196 | # end of Library Configuration 197 | 198 | # 199 | # Build Options 200 | # 201 | # CONFIG_OPTIMIZE_NONE is not set 202 | CONFIG_OPTIMIZE_PERF=y 203 | # CONFIG_OPTIMIZE_SIZE is not set 204 | 205 | # 206 | # Hint: Specify a CPU type to get most benefits from performance optimization 207 | # 208 | # CONFIG_OPTIMIZE_DEADELIM is not set 209 | # CONFIG_OPTIMIZE_LTO is not set 210 | # CONFIG_DEBUG_SYMBOLS_LVL0 is not set 211 | # CONFIG_DEBUG_SYMBOLS_LVL1 is not set 212 | # CONFIG_DEBUG_SYMBOLS_LVL2 is not set 213 | CONFIG_DEBUG_SYMBOLS_LVL3=y 214 | # CONFIG_OPTIMIZE_SYMFILE is not set 215 | CONFIG_OPTIMIZE_COMPRESS=y 216 | # CONFIG_RECORD_BUILDTIME is not set 217 | CONFIG_CROSS_COMPILE="" 218 | # end of Build Options 219 | 220 | # 221 | # Application Options 222 | # 223 | CONFIG_UK_NAME="sqlite" 224 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/configs/sqlite-flexos-fcalls.config: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated file; DO NOT EDIT. 3 | # Unikraft/0.5.0~de4a675-custom Configuration 4 | # 5 | CONFIG_UK_FULLVERSION="0.5.0~de4a675-custom" 6 | CONFIG_UK_CODENAME="Tethys" 7 | CONFIG_UK_ARCH="x86_64" 8 | CONFIG_UK_BASE="/root/.unikraft/unikraft" 9 | CONFIG_UK_APP="/root/.unikraft/apps/sqlite" 10 | CONFIG_UK_DEFNAME="sqlite" 11 | 12 | # 13 | # Architecture Selection 14 | # 15 | CONFIG_ARCH_X86_64=y 16 | # CONFIG_ARCH_ARM_64 is not set 17 | # CONFIG_ARCH_ARM_32 is not set 18 | # CONFIG_MARCH_X86_64_NATIVE is not set 19 | CONFIG_MARCH_X86_64_GENERIC=y 20 | # CONFIG_MARCH_X86_64_NOCONA is not set 21 | # CONFIG_MARCH_X86_64_CORE2 is not set 22 | # CONFIG_MARCH_X86_64_COREI7 is not set 23 | # CONFIG_MARCH_X86_64_COREI7AVX is not set 24 | # CONFIG_MARCH_X86_64_COREI7AVXI is not set 25 | # CONFIG_MARCH_X86_64_ATOM is not set 26 | # CONFIG_MARCH_X86_64_K8 is not set 27 | # CONFIG_MARCH_X86_64_K8SSE3 is not set 28 | # CONFIG_MARCH_X86_64_AMDFAM10 is not set 29 | # CONFIG_MARCH_X86_64_BTVER1 is not set 30 | # CONFIG_MARCH_X86_64_BDVER1 is not set 31 | # CONFIG_MARCH_X86_64_BDVER2 is not set 32 | # CONFIG_MARCH_X86_64_BDVER3 is not set 33 | # CONFIG_MARCH_X86_64_BTVER2 is not set 34 | CONFIG_STACK_SIZE_PAGE_ORDER=4 35 | # end of Architecture Selection 36 | 37 | # 38 | # Platform Configuration 39 | # 40 | CONFIG_PLAT_KVM=y 41 | 42 | # 43 | # Console Options 44 | # 45 | CONFIG_KVM_KERNEL_SERIAL_CONSOLE=y 46 | CONFIG_KVM_KERNEL_VGA_CONSOLE=y 47 | CONFIG_KVM_DEBUG_SERIAL_CONSOLE=y 48 | CONFIG_KVM_DEBUG_VGA_CONSOLE=y 49 | 50 | # 51 | # Serial console configuration 52 | # 53 | CONFIG_KVM_SERIAL_BAUD_115200=y 54 | # CONFIG_KVM_SERIAL_BAUD_57600 is not set 55 | # CONFIG_KVM_SERIAL_BAUD_38400 is not set 56 | # CONFIG_KVM_SERIAL_BAUD_19200 is not set 57 | # end of Serial console configuration 58 | # end of Console Options 59 | 60 | CONFIG_KVM_PCI=y 61 | CONFIG_VIRTIO_BUS=y 62 | 63 | # 64 | # Virtio 65 | # 66 | # CONFIG_VIRTIO_PCI is not set 67 | # end of Virtio 68 | 69 | # CONFIG_PLAT_LINUXU is not set 70 | # CONFIG_PLAT_XEN is not set 71 | 72 | # 73 | # Platform Interface Options 74 | # 75 | CONFIG_UKPLAT_MEMRNAME=y 76 | CONFIG_PT_API=y 77 | CONFIG_DYNAMIC_PT=y 78 | # end of Platform Interface Options 79 | 80 | CONFIG_HZ=100 81 | # end of Platform Configuration 82 | 83 | # 84 | # Library Configuration 85 | # 86 | # CONFIG_LIBDEVFS is not set 87 | # CONFIG_LIBFDT is not set 88 | CONFIG_LIBFLEXOS=y 89 | # CONFIG_LIBFLEXOS_INTELPKU is not set 90 | # CONFIG_LIBFLEXOS_VMEPT is not set 91 | CONFIG_LIBFLEXOS_NONE=y 92 | CONFIG_LIBFLEXOS_COMP_HEAP_SIZE=10000 93 | # CONFIG_LIBFLEXOS_DEBUG is not set 94 | # CONFIG_LIBKASAN is not set 95 | # CONFIG_LIBPOSIX_LIBDL is not set 96 | # CONFIG_LIBPOSIX_MMAP is not set 97 | CONFIG_LIBPOSIX_PROCESS=y 98 | CONFIG_LIBPOSIX_SYSINFO=y 99 | CONFIG_LIBPOSIX_USER=y 100 | CONFIG_LIBRAMFS=y 101 | # CONFIG_LIBSYSCALL_SHIM is not set 102 | # CONFIG_LIBUBSAN is not set 103 | # CONFIG_LIBUK9P is not set 104 | CONFIG_LIBUKALLOC=y 105 | CONFIG_LIBUKALLOC_IFMALLOC=y 106 | # CONFIG_LIBUKALLOC_IFSTATS is not set 107 | CONFIG_LIBUKALLOCBBUDDY=y 108 | # CONFIG_LIBUKALLOCPOOL is not set 109 | # CONFIG_LIBUKALLOCREGION is not set 110 | CONFIG_LIBUKARGPARSE=y 111 | # CONFIG_LIBUKBLKDEV is not set 112 | CONFIG_LIBUKBOOT=y 113 | # CONFIG_LIBUKBOOT_BANNER_NONE is not set 114 | # CONFIG_LIBUKBOOT_BANNER_MINIMAL is not set 115 | # CONFIG_LIBUKBOOT_BANNER_CLASSIC is not set 116 | CONFIG_LIBUKBOOT_BANNER_POWEREDBY=y 117 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI is not set 118 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI2 is not set 119 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EA is not set 120 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI is not set 121 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI2 is not set 122 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8 is not set 123 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI is not set 124 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI2 is not set 125 | CONFIG_LIBUKBOOT_MAXNBARGS=60 126 | # CONFIG_LIBUKBOOT_INITBBUDDY is not set 127 | # CONFIG_LIBUKBOOT_INITREGION is not set 128 | CONFIG_LIBUKBOOT_INITTLSF=y 129 | # CONFIG_LIBUKBOOT_NOALLOC is not set 130 | CONFIG_LIBUKBUS=y 131 | CONFIG_LIBUKDEBUG=y 132 | CONFIG_LIBUKDEBUG_PRINTK=y 133 | # CONFIG_LIBUKDEBUG_PRINTK_INFO is not set 134 | # CONFIG_LIBUKDEBUG_PRINTK_WARN is not set 135 | CONFIG_LIBUKDEBUG_PRINTK_ERR=y 136 | # CONFIG_LIBUKDEBUG_PRINTK_CRIT is not set 137 | # CONFIG_LIBUKDEBUG_PRINTD is not set 138 | # CONFIG_LIBUKDEBUG_NOREDIR is not set 139 | CONFIG_LIBUKDEBUG_REDIR_PRINTD=y 140 | # CONFIG_LIBUKDEBUG_REDIR_PRINTK is not set 141 | CONFIG_LIBUKDEBUG_PRINT_TIME=y 142 | # CONFIG_LIBUKDEBUG_PRINT_STACK is not set 143 | CONFIG_LIBUKDEBUG_PRINT_SRCNAME=y 144 | # CONFIG_LIBUKDEBUG_ANSI_COLOR is not set 145 | # CONFIG_LIBUKDEBUG_ENABLE_ASSERT is not set 146 | # CONFIG_LIBUKDEBUG_TRACEPOINTS is not set 147 | CONFIG_LIBUKLIBPARAM=y 148 | CONFIG_LIBUKLOCK=y 149 | CONFIG_LIBUKLOCK_SEMAPHORE=y 150 | CONFIG_LIBUKLOCK_MUTEX=y 151 | CONFIG_LIBUKMMAP=y 152 | # CONFIG_LIBUKMPI is not set 153 | # CONFIG_LIBUKNETDEV is not set 154 | # CONFIG_LIBUKRING is not set 155 | CONFIG_LIBUKSCHED=y 156 | CONFIG_LIBUKSCHEDCOOP=y 157 | CONFIG_LIBUKSGLIST=y 158 | CONFIG_LIBUKSIGNAL=y 159 | # CONFIG_LIBUKSP is not set 160 | # CONFIG_LIBUKSWRAND is not set 161 | CONFIG_LIBUKTIME=y 162 | CONFIG_LIBUKTIMECONV=y 163 | CONFIG_LIBVFSCORE=y 164 | 165 | # 166 | # vfscore: Configuration 167 | # 168 | CONFIG_LIBCPIO=y 169 | CONFIG_LIBINITRAMFS=y 170 | CONFIG_LIBVFSCORE_PIPE_SIZE_ORDER=16 171 | CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y 172 | CONFIG_LIBVFSCORE_ROOTFS_RAMFS=y 173 | # CONFIG_LIBVFSCORE_ROOTFS_9PFS is not set 174 | # CONFIG_LIBVFSCORE_ROOTFS_CUSTOM is not set 175 | CONFIG_LIBVFSCORE_ROOTFS="ramfs" 176 | # end of vfscore: Configuration 177 | 178 | CONFIG_HAVE_BOOTENTRY=y 179 | CONFIG_HAVE_LIBC=y 180 | CONFIG_HAVE_TIME=y 181 | CONFIG_HAVE_SCHED=y 182 | CONFIG_LIBPTHREAD_EMBEDDED=y 183 | CONFIG_LIBPTHREAD_EMBEDDED_MAX_SIMUL_THREADS=32 184 | CONFIG_LIBPTHREAD_EMBEDDED_MAX_TLS=32 185 | # CONFIG_LIBPTHREAD_EMBEDDED_UTEST is not set 186 | CONFIG_LIBNEWLIBC=y 187 | CONFIG_LIBNEWLIBM=y 188 | # CONFIG_LIBNEWLIBC_WANT_IO_C99_FORMATS is not set 189 | # CONFIG_LIBNEWLIBC_LINUX_ERRNO_EXTENSIONS is not set 190 | CONFIG_LIBNEWLIBC_CRYPT=y 191 | CONFIG_LIBSQLITE=y 192 | # CONFIG_LIBSQLITE_MAIN_FUNCTION is not set 193 | CONFIG_LIBTLSF_INCLUDED=y 194 | CONFIG_LIBTLSF=y 195 | CONFIG_TLSF_LOG2_SLI=5 196 | # end of Library Configuration 197 | 198 | # 199 | # Build Options 200 | # 201 | # CONFIG_OPTIMIZE_NONE is not set 202 | CONFIG_OPTIMIZE_PERF=y 203 | # CONFIG_OPTIMIZE_SIZE is not set 204 | 205 | # 206 | # Hint: Specify a CPU type to get most benefits from performance optimization 207 | # 208 | # CONFIG_OPTIMIZE_DEADELIM is not set 209 | # CONFIG_OPTIMIZE_LTO is not set 210 | # CONFIG_DEBUG_SYMBOLS_LVL0 is not set 211 | # CONFIG_DEBUG_SYMBOLS_LVL1 is not set 212 | # CONFIG_DEBUG_SYMBOLS_LVL2 is not set 213 | CONFIG_DEBUG_SYMBOLS_LVL3=y 214 | # CONFIG_OPTIMIZE_SYMFILE is not set 215 | CONFIG_OPTIMIZE_COMPRESS=y 216 | # CONFIG_RECORD_BUILDTIME is not set 217 | CONFIG_CROSS_COMPILE="" 218 | CONFIG_LLVM_TARGET_ARCH="" 219 | # end of Build Options 220 | 221 | # 222 | # Application Options 223 | # 224 | CONFIG_UK_NAME="sqlite" 225 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/configs/sqlite-kvm.config: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated file; DO NOT EDIT. 3 | # Unikraft/0.5.0~fd57791 Configuration 4 | # 5 | CONFIG_UK_FULLVERSION="0.5.0~fd57791" 6 | CONFIG_UK_CODENAME="Tethys" 7 | CONFIG_UK_ARCH="x86_64" 8 | CONFIG_UK_BASE="/root/unikraft-mainline/unikraft" 9 | CONFIG_UK_APP="/root/unikraft-mainline/apps/app-sqlite-kvm" 10 | CONFIG_UK_DEFNAME="app-sqlite-kvm" 11 | 12 | # 13 | # Architecture Selection 14 | # 15 | CONFIG_ARCH_X86_64=y 16 | # CONFIG_ARCH_ARM_64 is not set 17 | # CONFIG_ARCH_ARM_32 is not set 18 | # CONFIG_MARCH_X86_64_NATIVE is not set 19 | CONFIG_MARCH_X86_64_GENERIC=y 20 | # CONFIG_MARCH_X86_64_NOCONA is not set 21 | # CONFIG_MARCH_X86_64_CORE2 is not set 22 | # CONFIG_MARCH_X86_64_COREI7 is not set 23 | # CONFIG_MARCH_X86_64_COREI7AVX is not set 24 | # CONFIG_MARCH_X86_64_COREI7AVXI is not set 25 | # CONFIG_MARCH_X86_64_ATOM is not set 26 | # CONFIG_MARCH_X86_64_K8 is not set 27 | # CONFIG_MARCH_X86_64_K8SSE3 is not set 28 | # CONFIG_MARCH_X86_64_AMDFAM10 is not set 29 | # CONFIG_MARCH_X86_64_BTVER1 is not set 30 | # CONFIG_MARCH_X86_64_BDVER1 is not set 31 | # CONFIG_MARCH_X86_64_BDVER2 is not set 32 | # CONFIG_MARCH_X86_64_BDVER3 is not set 33 | # CONFIG_MARCH_X86_64_BTVER2 is not set 34 | CONFIG_STACK_SIZE_PAGE_ORDER=4 35 | # end of Architecture Selection 36 | 37 | # 38 | # Platform Configuration 39 | # 40 | CONFIG_PLAT_KVM=y 41 | 42 | # 43 | # Console Options 44 | # 45 | CONFIG_KVM_KERNEL_SERIAL_CONSOLE=y 46 | CONFIG_KVM_KERNEL_VGA_CONSOLE=y 47 | CONFIG_KVM_DEBUG_SERIAL_CONSOLE=y 48 | CONFIG_KVM_DEBUG_VGA_CONSOLE=y 49 | 50 | # 51 | # Serial console configuration 52 | # 53 | CONFIG_KVM_SERIAL_BAUD_115200=y 54 | # CONFIG_KVM_SERIAL_BAUD_57600 is not set 55 | # CONFIG_KVM_SERIAL_BAUD_38400 is not set 56 | # CONFIG_KVM_SERIAL_BAUD_19200 is not set 57 | # end of Serial console configuration 58 | # end of Console Options 59 | 60 | CONFIG_KVM_PCI=y 61 | CONFIG_VIRTIO_BUS=y 62 | 63 | # 64 | # Virtio 65 | # 66 | # CONFIG_VIRTIO_PCI is not set 67 | # end of Virtio 68 | 69 | # CONFIG_PLAT_LINUXU is not set 70 | # CONFIG_PLAT_XEN is not set 71 | 72 | # 73 | # Platform Interface Options 74 | # 75 | # CONFIG_UKPLAT_MEMRNAME is not set 76 | # end of Platform Interface Options 77 | 78 | CONFIG_HZ=100 79 | # end of Platform Configuration 80 | 81 | # 82 | # Library Configuration 83 | # 84 | # CONFIG_LIBDEVFS is not set 85 | # CONFIG_LIBFDT is not set 86 | # CONFIG_LIBPOSIX_LIBDL is not set 87 | CONFIG_LIBPOSIX_PROCESS=y 88 | CONFIG_LIBPOSIX_SYSINFO=y 89 | CONFIG_LIBPOSIX_USER=y 90 | CONFIG_LIBRAMFS=y 91 | # CONFIG_LIBSYSCALL_SHIM is not set 92 | # CONFIG_LIBUK9P is not set 93 | CONFIG_LIBUKALLOC=y 94 | CONFIG_LIBUKALLOC_IFMALLOC=y 95 | # CONFIG_LIBUKALLOC_IFSTATS is not set 96 | CONFIG_LIBUKALLOCBBUDDY=y 97 | # CONFIG_LIBUKALLOCPOOL is not set 98 | # CONFIG_LIBUKALLOCREGION is not set 99 | CONFIG_LIBUKARGPARSE=y 100 | # CONFIG_LIBUKBLKDEV is not set 101 | CONFIG_LIBUKBOOT=y 102 | # CONFIG_LIBUKBOOT_BANNER_NONE is not set 103 | # CONFIG_LIBUKBOOT_BANNER_MINIMAL is not set 104 | # CONFIG_LIBUKBOOT_BANNER_CLASSIC is not set 105 | CONFIG_LIBUKBOOT_BANNER_POWEREDBY=y 106 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI is not set 107 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI2 is not set 108 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EA is not set 109 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI is not set 110 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI2 is not set 111 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8 is not set 112 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI is not set 113 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI2 is not set 114 | CONFIG_LIBUKBOOT_MAXNBARGS=60 115 | # CONFIG_LIBUKBOOT_INITBBUDDY is not set 116 | # CONFIG_LIBUKBOOT_INITREGION is not set 117 | CONFIG_LIBUKBOOT_INITTLSF=y 118 | # CONFIG_LIBUKBOOT_NOALLOC is not set 119 | CONFIG_LIBUKBUS=y 120 | CONFIG_LIBUKDEBUG=y 121 | # CONFIG_LIBUKDEBUG_PRINTK is not set 122 | # CONFIG_LIBUKDEBUG_PRINTD is not set 123 | # CONFIG_LIBUKDEBUG_NOREDIR is not set 124 | CONFIG_LIBUKDEBUG_REDIR_PRINTD=y 125 | # CONFIG_LIBUKDEBUG_PRINT_TIME is not set 126 | # CONFIG_LIBUKDEBUG_PRINT_STACK is not set 127 | CONFIG_LIBUKDEBUG_PRINT_SRCNAME=y 128 | # CONFIG_LIBUKDEBUG_ANSI_COLOR is not set 129 | # CONFIG_LIBUKDEBUG_ENABLE_ASSERT is not set 130 | # CONFIG_LIBUKDEBUG_TRACEPOINTS is not set 131 | CONFIG_LIBUKLIBPARAM=y 132 | CONFIG_LIBUKLOCK=y 133 | CONFIG_LIBUKLOCK_SEMAPHORE=y 134 | CONFIG_LIBUKLOCK_MUTEX=y 135 | CONFIG_LIBUKMMAP=y 136 | # CONFIG_LIBUKMPI is not set 137 | # CONFIG_LIBUKNETDEV is not set 138 | # CONFIG_LIBUKRING is not set 139 | CONFIG_LIBUKSCHED=y 140 | CONFIG_LIBUKSCHEDCOOP=y 141 | CONFIG_LIBUKSGLIST=y 142 | CONFIG_LIBUKSIGNAL=y 143 | # CONFIG_LIBUKSP is not set 144 | # CONFIG_LIBUKSWRAND is not set 145 | CONFIG_LIBUKTIME=y 146 | CONFIG_LIBUKTIMECONV=y 147 | CONFIG_LIBVFSCORE=y 148 | 149 | # 150 | # vfscore: Configuration 151 | # 152 | CONFIG_LIBCPIO=y 153 | CONFIG_LIBINITRAMFS=y 154 | CONFIG_LIBVFSCORE_PIPE_SIZE_ORDER=16 155 | CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y 156 | CONFIG_LIBVFSCORE_ROOTFS_RAMFS=y 157 | # CONFIG_LIBVFSCORE_ROOTFS_9PFS is not set 158 | # CONFIG_LIBVFSCORE_ROOTFS_CUSTOM is not set 159 | CONFIG_LIBVFSCORE_ROOTFS="ramfs" 160 | # end of vfscore: Configuration 161 | 162 | CONFIG_HAVE_BOOTENTRY=y 163 | CONFIG_HAVE_LIBC=y 164 | CONFIG_HAVE_TIME=y 165 | CONFIG_HAVE_SCHED=y 166 | CONFIG_LIBPTHREAD_EMBEDDED=y 167 | CONFIG_LIBPTHREAD_EMBEDDED_MAX_SIMUL_THREADS=32 168 | CONFIG_LIBPTHREAD_EMBEDDED_MAX_TLS=32 169 | # CONFIG_LIBPTHREAD_EMBEDDED_UTEST is not set 170 | CONFIG_LIBNEWLIBM=y 171 | CONFIG_LIBNEWLIBC=y 172 | # CONFIG_LIBNEWLIBC_WANT_IO_C99_FORMATS is not set 173 | # CONFIG_LIBNEWLIBC_LINUX_ERRNO_EXTENSIONS is not set 174 | CONFIG_LIBNEWLIBC_CRYPT=y 175 | CONFIG_LIBSQLITE=y 176 | # CONFIG_LIBSQLITE_MAIN_FUNCTION is not set 177 | CONFIG_LIBTLSF_INCLUDED=y 178 | CONFIG_LIBTLSF=y 179 | CONFIG_TLSF_LOG2_SLI=5 180 | # end of Library Configuration 181 | 182 | # 183 | # Build Options 184 | # 185 | # CONFIG_OPTIMIZE_NONE is not set 186 | CONFIG_OPTIMIZE_PERF=y 187 | # CONFIG_OPTIMIZE_SIZE is not set 188 | 189 | # 190 | # Hint: Specify a CPU type to get most benefits from performance optimization 191 | # 192 | # CONFIG_OPTIMIZE_DEADELIM is not set 193 | # CONFIG_OPTIMIZE_LTO is not set 194 | # CONFIG_DEBUG_SYMBOLS_LVL0 is not set 195 | # CONFIG_DEBUG_SYMBOLS_LVL1 is not set 196 | # CONFIG_DEBUG_SYMBOLS_LVL2 is not set 197 | CONFIG_DEBUG_SYMBOLS_LVL3=y 198 | # CONFIG_OPTIMIZE_SYMFILE is not set 199 | CONFIG_OPTIMIZE_COMPRESS=y 200 | # CONFIG_RECORD_BUILDTIME is not set 201 | CONFIG_CROSS_COMPILE="" 202 | # end of Build Options 203 | 204 | # 205 | # Application Options 206 | # 207 | CONFIG_UK_NAME="app-sqlite" 208 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/configs/sqlite-linuxu.config: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated file; DO NOT EDIT. 3 | # Unikraft/0.5.0~fd57791-custom Configuration 4 | # 5 | CONFIG_UK_FULLVERSION="0.5.0~fd57791-custom" 6 | CONFIG_UK_CODENAME="Tethys" 7 | CONFIG_UK_ARCH="x86_64" 8 | CONFIG_UK_BASE="/root/unikraft-mainline/unikraft" 9 | CONFIG_UK_APP="/root/unikraft-mainline/apps/app-sqlite-linuxu" 10 | CONFIG_UK_DEFNAME="app-sqlite-kvm" 11 | 12 | # 13 | # Architecture Selection 14 | # 15 | CONFIG_ARCH_X86_64=y 16 | # CONFIG_ARCH_ARM_64 is not set 17 | # CONFIG_ARCH_ARM_32 is not set 18 | # CONFIG_MARCH_X86_64_NATIVE is not set 19 | CONFIG_MARCH_X86_64_GENERIC=y 20 | # CONFIG_MARCH_X86_64_NOCONA is not set 21 | # CONFIG_MARCH_X86_64_CORE2 is not set 22 | # CONFIG_MARCH_X86_64_COREI7 is not set 23 | # CONFIG_MARCH_X86_64_COREI7AVX is not set 24 | # CONFIG_MARCH_X86_64_COREI7AVXI is not set 25 | # CONFIG_MARCH_X86_64_ATOM is not set 26 | # CONFIG_MARCH_X86_64_K8 is not set 27 | # CONFIG_MARCH_X86_64_K8SSE3 is not set 28 | # CONFIG_MARCH_X86_64_AMDFAM10 is not set 29 | # CONFIG_MARCH_X86_64_BTVER1 is not set 30 | # CONFIG_MARCH_X86_64_BDVER1 is not set 31 | # CONFIG_MARCH_X86_64_BDVER2 is not set 32 | # CONFIG_MARCH_X86_64_BDVER3 is not set 33 | # CONFIG_MARCH_X86_64_BTVER2 is not set 34 | CONFIG_STACK_SIZE_PAGE_ORDER=4 35 | # end of Architecture Selection 36 | 37 | # 38 | # Platform Configuration 39 | # 40 | # CONFIG_PLAT_KVM is not set 41 | CONFIG_PLAT_LINUXU=y 42 | CONFIG_LINUXU_DEFAULT_HEAPMB=1000 43 | # CONFIG_PLAT_XEN is not set 44 | 45 | # 46 | # Platform Interface Options 47 | # 48 | # CONFIG_UKPLAT_MEMRNAME is not set 49 | # end of Platform Interface Options 50 | 51 | CONFIG_HZ=100 52 | # end of Platform Configuration 53 | 54 | # 55 | # Library Configuration 56 | # 57 | # CONFIG_LIBDEVFS is not set 58 | # CONFIG_LIBFDT is not set 59 | # CONFIG_LIBPOSIX_LIBDL is not set 60 | CONFIG_LIBPOSIX_PROCESS=y 61 | CONFIG_LIBPOSIX_SYSINFO=y 62 | CONFIG_LIBPOSIX_USER=y 63 | CONFIG_LIBRAMFS=y 64 | # CONFIG_LIBSYSCALL_SHIM is not set 65 | # CONFIG_LIBUK9P is not set 66 | CONFIG_LIBUKALLOC=y 67 | CONFIG_LIBUKALLOC_IFMALLOC=y 68 | # CONFIG_LIBUKALLOC_IFSTATS is not set 69 | CONFIG_LIBUKALLOCBBUDDY=y 70 | # CONFIG_LIBUKALLOCPOOL is not set 71 | # CONFIG_LIBUKALLOCREGION is not set 72 | CONFIG_LIBUKARGPARSE=y 73 | # CONFIG_LIBUKBLKDEV is not set 74 | CONFIG_LIBUKBOOT=y 75 | # CONFIG_LIBUKBOOT_BANNER_NONE is not set 76 | # CONFIG_LIBUKBOOT_BANNER_MINIMAL is not set 77 | # CONFIG_LIBUKBOOT_BANNER_CLASSIC is not set 78 | CONFIG_LIBUKBOOT_BANNER_POWEREDBY=y 79 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI is not set 80 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI2 is not set 81 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EA is not set 82 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI is not set 83 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI2 is not set 84 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8 is not set 85 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI is not set 86 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI2 is not set 87 | CONFIG_LIBUKBOOT_MAXNBARGS=60 88 | # CONFIG_LIBUKBOOT_INITBBUDDY is not set 89 | # CONFIG_LIBUKBOOT_INITREGION is not set 90 | CONFIG_LIBUKBOOT_INITTLSF=y 91 | # CONFIG_LIBUKBOOT_NOALLOC is not set 92 | CONFIG_LIBUKBUS=y 93 | CONFIG_LIBUKDEBUG=y 94 | # CONFIG_LIBUKDEBUG_PRINTK is not set 95 | # CONFIG_LIBUKDEBUG_PRINTD is not set 96 | # CONFIG_LIBUKDEBUG_NOREDIR is not set 97 | CONFIG_LIBUKDEBUG_REDIR_PRINTD=y 98 | # CONFIG_LIBUKDEBUG_PRINT_TIME is not set 99 | # CONFIG_LIBUKDEBUG_PRINT_STACK is not set 100 | # CONFIG_LIBUKDEBUG_PRINT_SRCNAME is not set 101 | # CONFIG_LIBUKDEBUG_ANSI_COLOR is not set 102 | # CONFIG_LIBUKDEBUG_ENABLE_ASSERT is not set 103 | # CONFIG_LIBUKDEBUG_TRACEPOINTS is not set 104 | CONFIG_LIBUKLIBPARAM=y 105 | CONFIG_LIBUKLOCK=y 106 | CONFIG_LIBUKLOCK_SEMAPHORE=y 107 | CONFIG_LIBUKLOCK_MUTEX=y 108 | CONFIG_LIBUKMMAP=y 109 | # CONFIG_LIBUKMPI is not set 110 | # CONFIG_LIBUKNETDEV is not set 111 | # CONFIG_LIBUKRING is not set 112 | CONFIG_LIBUKSCHED=y 113 | CONFIG_LIBUKSCHEDCOOP=y 114 | CONFIG_LIBUKSGLIST=y 115 | CONFIG_LIBUKSIGNAL=y 116 | # CONFIG_LIBUKSP is not set 117 | # CONFIG_LIBUKSWRAND is not set 118 | CONFIG_LIBUKTIME=y 119 | CONFIG_LIBUKTIMECONV=y 120 | CONFIG_LIBVFSCORE=y 121 | 122 | # 123 | # vfscore: Configuration 124 | # 125 | # CONFIG_LIBCPIO is not set 126 | # CONFIG_LIBINITRAMFS is not set 127 | CONFIG_LIBVFSCORE_PIPE_SIZE_ORDER=16 128 | CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y 129 | CONFIG_LIBVFSCORE_ROOTFS_RAMFS=y 130 | # CONFIG_LIBVFSCORE_ROOTFS_9PFS is not set 131 | # CONFIG_LIBVFSCORE_ROOTFS_CUSTOM is not set 132 | CONFIG_LIBVFSCORE_ROOTFS="ramfs" 133 | # end of vfscore: Configuration 134 | 135 | CONFIG_HAVE_BOOTENTRY=y 136 | CONFIG_HAVE_LIBC=y 137 | CONFIG_HAVE_TIME=y 138 | CONFIG_HAVE_SCHED=y 139 | CONFIG_LIBPTHREAD_EMBEDDED=y 140 | CONFIG_LIBPTHREAD_EMBEDDED_MAX_SIMUL_THREADS=32 141 | CONFIG_LIBPTHREAD_EMBEDDED_MAX_TLS=32 142 | # CONFIG_LIBPTHREAD_EMBEDDED_UTEST is not set 143 | CONFIG_LIBNEWLIBM=y 144 | CONFIG_LIBNEWLIBC=y 145 | # CONFIG_LIBNEWLIBC_WANT_IO_C99_FORMATS is not set 146 | # CONFIG_LIBNEWLIBC_LINUX_ERRNO_EXTENSIONS is not set 147 | CONFIG_LIBNEWLIBC_CRYPT=y 148 | CONFIG_LIBSQLITE=y 149 | # CONFIG_LIBSQLITE_MAIN_FUNCTION is not set 150 | CONFIG_LIBTLSF_INCLUDED=y 151 | CONFIG_LIBTLSF=y 152 | CONFIG_TLSF_LOG2_SLI=5 153 | # end of Library Configuration 154 | 155 | # 156 | # Build Options 157 | # 158 | # CONFIG_OPTIMIZE_NONE is not set 159 | CONFIG_OPTIMIZE_PERF=y 160 | # CONFIG_OPTIMIZE_SIZE is not set 161 | 162 | # 163 | # Hint: Specify a CPU type to get most benefits from performance optimization 164 | # 165 | # CONFIG_OPTIMIZE_DEADELIM is not set 166 | # CONFIG_OPTIMIZE_LTO is not set 167 | # CONFIG_DEBUG_SYMBOLS_LVL0 is not set 168 | # CONFIG_DEBUG_SYMBOLS_LVL1 is not set 169 | # CONFIG_DEBUG_SYMBOLS_LVL2 is not set 170 | CONFIG_DEBUG_SYMBOLS_LVL3=y 171 | # CONFIG_OPTIMIZE_SYMFILE is not set 172 | CONFIG_OPTIMIZE_COMPRESS=y 173 | # CONFIG_RECORD_BUILDTIME is not set 174 | CONFIG_CROSS_COMPILE="" 175 | # end of Build Options 176 | 177 | # 178 | # Application Options 179 | # 180 | CONFIG_UK_NAME="app-sqlite" 181 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/patches/cpio-patches/01.patch: -------------------------------------------------------------------------------- 1 | diff --git a/plat/linuxu/include/linuxu/syscall-arm_32.h b/plat/linuxu/include/linuxu/syscall-arm_32.h 2 | index ef9323b..5d1b1e2 100644 3 | --- a/plat/linuxu/include/linuxu/syscall-arm_32.h 4 | +++ b/plat/linuxu/include/linuxu/syscall-arm_32.h 5 | @@ -46,6 +46,7 @@ 6 | #define __SC_MUNMAP 91 7 | #define __SC_EXIT 1 8 | #define __SC_IOCTL 54 9 | +#define __SC_FSTAT 108 10 | #define __SC_RT_SIGPROCMASK 126 11 | #define __SC_ARCH_PRCTL 172 12 | #define __SC_RT_SIGACTION 174 13 | diff --git a/plat/linuxu/include/linuxu/syscall-x86_64.h b/plat/linuxu/include/linuxu/syscall-x86_64.h 14 | index 553f0ba..0dd280e 100644 15 | --- a/plat/linuxu/include/linuxu/syscall-x86_64.h 16 | +++ b/plat/linuxu/include/linuxu/syscall-x86_64.h 17 | @@ -42,6 +42,7 @@ 18 | #define __SC_WRITE 1 19 | #define __SC_OPEN 2 20 | #define __SC_CLOSE 3 21 | +#define __SC_FSTAT 5 22 | #define __SC_MMAP 9 23 | #define __SC_MUNMAP 11 24 | #define __SC_RT_SIGACTION 13 25 | diff --git a/plat/linuxu/include/linuxu/syscall.h b/plat/linuxu/include/linuxu/syscall.h 26 | index 0dca7c5..c703b32 100644 27 | --- a/plat/linuxu/include/linuxu/syscall.h 28 | +++ b/plat/linuxu/include/linuxu/syscall.h 29 | @@ -48,6 +48,13 @@ 30 | #error "Unsupported architecture" 31 | #endif 32 | 33 | + 34 | +static inline int sys_open(const char *pathname, int flags, mode_t mode) 35 | +{ 36 | + return (int)syscall3(__SC_OPEN, (long)pathname, (long)flags, 37 | + (long)mode); 38 | +} 39 | + 40 | static inline ssize_t sys_read(int fd, const char *buf, size_t len) 41 | { 42 | return (ssize_t) syscall3(__SC_READ, 43 | @@ -64,6 +71,13 @@ static inline ssize_t sys_write(int fd, const char *buf, size_t len) 44 | (long) (len)); 45 | } 46 | 47 | +struct stat; 48 | + 49 | +static inline int sys_fstat(int fd, struct stat *statbuf) 50 | +{ 51 | + return (int)syscall2(__SC_FSTAT, (long)(fd), (long)(statbuf)); 52 | +} 53 | + 54 | static inline int sys_exit(int status) 55 | { 56 | return (int) syscall1(__SC_EXIT, 57 | @@ -81,6 +95,7 @@ static inline int sys_clock_gettime(k_clockid_t clk_id, struct k_timespec *tp) 58 | * Please note that on failure sys_mmap() is returning -errno 59 | */ 60 | #define MAP_SHARED (0x01) 61 | +#define MAP_PRIVATE (0x02) 62 | #define MAP_ANONYMOUS (0x20) 63 | #define PROT_NONE (0x0) 64 | #define PROT_READ (0x1) 65 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/patches/cpio-patches/02.patch: -------------------------------------------------------------------------------- 1 | diff --git a/plat/linuxu/include/linuxu/setup.h b/plat/linuxu/include/linuxu/setup.h 2 | index 571d66c..5d2c3a6 100644 3 | --- a/plat/linuxu/include/linuxu/setup.h 4 | +++ b/plat/linuxu/include/linuxu/setup.h 5 | @@ -38,11 +38,14 @@ 6 | 7 | #include 8 | 9 | +struct liblinuxuplat_memregion { 10 | + void *base; 11 | + size_t len; 12 | +}; 13 | + 14 | struct liblinuxuplat_opts { 15 | - struct { 16 | - void *base; 17 | - size_t len; 18 | - } heap; 19 | + struct liblinuxuplat_memregion heap; 20 | + struct liblinuxuplat_memregion initrd; 21 | }; 22 | 23 | extern struct liblinuxuplat_opts _liblinuxuplat_opts; 24 | diff --git a/plat/linuxu/memory.c b/plat/linuxu/memory.c 25 | index 9b5479e..842debe 100644 26 | --- a/plat/linuxu/memory.c 27 | +++ b/plat/linuxu/memory.c 28 | @@ -42,11 +42,19 @@ 29 | #include 30 | #include 31 | 32 | -#define MB2B (1024 * 1024) 33 | +#include 34 | +#include 35 | +#include 36 | +#include 37 | + 38 | +#define MB2B (1024 * 1024) 39 | 40 | static __u32 heap_size = CONFIG_LINUXU_DEFAULT_HEAPMB; 41 | UK_LIB_PARAM(heap_size, __u32); 42 | 43 | +static const char *initrd_file = NULL; 44 | +UK_LIB_PARAM_STR(initrd_file); 45 | + 46 | static int __linuxu_plat_heap_init(void) 47 | { 48 | void *pret; 49 | @@ -63,32 +71,86 @@ static int __linuxu_plat_heap_init(void) 50 | if (PTRISERR(pret)) { 51 | rc = PTR2ERR(pret); 52 | uk_pr_err("Failed to allocate memory for heap: %d\n", 53 | - rc); 54 | + rc); 55 | } else 56 | _liblinuxuplat_opts.heap.base = pret; 57 | } 58 | 59 | return rc; 60 | +} 61 | 62 | +static int __linuxu_plat_initrd_init(void) 63 | +{ 64 | + void *pret; 65 | + int rc = 0; 66 | + struct stat file_info; 67 | + 68 | + if (initrd_file == NULL) { 69 | + uk_pr_debug("No initrd present.\n"); 70 | + } else { 71 | + uk_pr_debug("Mapping in initrd file: %s\n", initrd_file); 72 | + int initrd_fd = sys_open(initrd_file, O_RDONLY, 0); 73 | + 74 | + if (initrd_fd < 0) { 75 | + uk_pr_err("Failed to open intrd file"); 76 | + return -1; 77 | + } 78 | + 79 | + /** 80 | + * Find initrd file size 81 | + */ 82 | + if (sys_fstat(initrd_fd, &file_info) < 0) { 83 | + uk_pr_err("sys_fstat failed for initrd file"); 84 | + close(initrd_fd); 85 | + return -1; 86 | + } 87 | + _liblinuxuplat_opts.initrd.len = file_info.st_size; 88 | + /** 89 | + * Allocate initrd memory 90 | + */ 91 | + if (_liblinuxuplat_opts.initrd.len > 0) { 92 | + pret = sys_mmap((void *)_liblinuxuplat_opts.heap.len, 93 | + _liblinuxuplat_opts.initrd.len, 94 | + PROT_READ | PROT_WRITE | PROT_EXEC, 95 | + MAP_PRIVATE, initrd_fd, 0); 96 | + if (PTRISERR(pret)) { 97 | + rc = PTR2ERR(pret); 98 | + uk_pr_err("Failed to allocate memory for initrd: %d\n", 99 | + rc); 100 | + close(initrd_fd); 101 | + return -1; 102 | + } 103 | + _liblinuxuplat_opts.initrd.base = pret; 104 | + } else { 105 | + uk_pr_err("Empty initrd file given.\n"); 106 | + close(initrd_fd); 107 | + return -1; 108 | + } 109 | + } 110 | + return rc; 111 | } 112 | 113 | int ukplat_memregion_count(void) 114 | { 115 | static int have_heap = 0; 116 | + static int have_initrd = 0; 117 | int rc = 0; 118 | 119 | + /* 120 | + * NOTE: The heap size and initrd file can be changed by a 121 | + * library parameter. We assume that those ones are processed 122 | + * by the boot library shortly before memory regions are 123 | + * scanned. This is why we initialize the heap here. 124 | + */ 125 | if (!have_heap) { 126 | - /* 127 | - * NOTE: The heap size can be changed by a library parameter. 128 | - * We assume that those ones are processed by the boot library 129 | - * shortly before memory regions are scanned. This is why 130 | - * we initialize the heap here. 131 | - */ 132 | rc = __linuxu_plat_heap_init(); 133 | have_heap = (rc == 0) ? 1 : 0; 134 | } 135 | - 136 | - return (have_heap) ? 1 : 0; 137 | + if (!have_initrd) { 138 | + rc = __linuxu_plat_initrd_init(); 139 | + have_initrd = (rc == 0) ? 1 : 0; 140 | + } 141 | + return have_heap + have_initrd; 142 | } 143 | 144 | int ukplat_memregion_get(int i, struct ukplat_memregion_desc *m) 145 | @@ -98,20 +160,31 @@ int ukplat_memregion_get(int i, struct ukplat_memregion_desc *m) 146 | UK_ASSERT(m); 147 | 148 | if (i == 0 && _liblinuxuplat_opts.heap.base) { 149 | - m->base = _liblinuxuplat_opts.heap.base; 150 | - m->len = _liblinuxuplat_opts.heap.len; 151 | + m->base = _liblinuxuplat_opts.heap.base; 152 | + m->len = _liblinuxuplat_opts.heap.len; 153 | m->flags = UKPLAT_MEMRF_ALLOCATABLE; 154 | #if CONFIG_UKPLAT_MEMRNAME 155 | - m->name = "heap"; 156 | + m->name = "heap"; 157 | +#endif 158 | + ret = 0; 159 | + } else if ((i == 0 && !_liblinuxuplat_opts.heap.base 160 | + && _liblinuxuplat_opts.initrd.base) 161 | + || (i == 1 && _liblinuxuplat_opts.heap.base 162 | + && _liblinuxuplat_opts.initrd.base)) { 163 | + m->base = _liblinuxuplat_opts.initrd.base; 164 | + m->len = _liblinuxuplat_opts.initrd.len; 165 | + m->flags = UKPLAT_MEMRF_INITRD | UKPLAT_MEMRF_WRITABLE; 166 | +#if CONFIG_UKPLAT_MEMRNAME 167 | + m->name = "initrd"; 168 | #endif 169 | ret = 0; 170 | } else { 171 | /* invalid memory region index or no heap allocated */ 172 | - m->base = __NULL; 173 | - m->len = 0; 174 | + m->base = __NULL; 175 | + m->len = 0; 176 | m->flags = 0x0; 177 | #if CONFIG_UKPLAT_MEMRNAME 178 | - m->name = __NULL; 179 | + m->name = __NULL; 180 | #endif 181 | ret = -1; 182 | } 183 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/patches/cpio-patches/03.patch: -------------------------------------------------------------------------------- 1 | diff --git a/lib/Makefile.uk b/lib/Makefile.uk 2 | index aa7e730..1503e73 100644 3 | --- a/lib/Makefile.uk 4 | +++ b/lib/Makefile.uk 5 | @@ -20,6 +20,7 @@ $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/fdt)) 6 | $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/syscall_shim)) 7 | $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/vfscore)) 8 | $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ramfs)) 9 | +$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/cpio)) 10 | $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/devfs)) 11 | $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/9pfs)) 12 | $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/uklock)) 13 | diff --git a/lib/cpio/Makefile.uk b/lib/cpio/Makefile.uk 14 | new file mode 100644 15 | index 0000000..c3411bf 16 | --- /dev/null 17 | +++ b/lib/cpio/Makefile.uk 18 | @@ -0,0 +1,7 @@ 19 | +$(eval $(call addlib_s,libcpio,$(CONFIG_LIBCPIO))) 20 | + 21 | +# LIBCPIO_CFLAGS-$(call gcc_version_ge,8,0) += -Wno-cast-function-type 22 | + 23 | +CINCLUDES-$(CONFIG_LIBCPIO) += -I$(LIBCPIO_BASE)/include 24 | +CXXINCLUDES-$(CONFIG_LIBCPIO) += -I$(LIBCPIO_BASE)/include 25 | +LIBCPIO_SRCS-y += $(LIBCPIO_BASE)/cpio.c 26 | diff --git a/lib/cpio/cpio.c b/lib/cpio/cpio.c 27 | new file mode 100644 28 | index 0000000..e69de29 29 | diff --git a/lib/cpio/exportsyms.uk b/lib/cpio/exportsyms.uk 30 | new file mode 100644 31 | index 0000000..b0047fa 32 | --- /dev/null 33 | +++ b/lib/cpio/exportsyms.uk 34 | @@ -0,0 +1 @@ 35 | +None 36 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/patches/cpio-patches/05.patch: -------------------------------------------------------------------------------- 1 | diff --git a/lib/vfscore/Config.uk b/lib/vfscore/Config.uk 2 | index f64810f..e3b305e 100644 3 | --- a/lib/vfscore/Config.uk 4 | +++ b/lib/vfscore/Config.uk 5 | @@ -9,6 +9,18 @@ config LIBVFSCORE 6 | if LIBVFSCORE 7 | menu "vfscore: Configuration" 8 | 9 | +config LIBCPIO 10 | + bool "cpio: general cpio archive extraction" 11 | + default n 12 | + 13 | +config LIBINITRAMFS 14 | + bool "initramfs: extract the given cpio file to /" 15 | + default n 16 | + select LIBRAMFS 17 | + select LIBUKLIBPARAM 18 | + select LIBVFSCORE_AUTOMOUNT_ROOTFS 19 | + select LIBCPIO 20 | + 21 | config LIBVFSCORE_PIPE_SIZE_ORDER 22 | int "Pipe size order" 23 | default 16 24 | diff --git a/lib/vfscore/rootfs.c b/lib/vfscore/rootfs.c 25 | index 4b9512a..78dbe3a 100644 26 | --- a/lib/vfscore/rootfs.c 27 | +++ b/lib/vfscore/rootfs.c 28 | @@ -42,6 +42,11 @@ 29 | #include 30 | #include 31 | #include 32 | +#ifdef CONFIG_LIBINITRAMFS 33 | +#include 34 | +#include 35 | +#include 36 | +#endif 37 | 38 | static const char *rootfs = CONFIG_LIBVFSCORE_ROOTFS; 39 | 40 | @@ -80,17 +85,32 @@ static int vfscore_rootfs(void) 41 | return -1; 42 | } 43 | 44 | +#ifdef CONFIG_LIBINITRAMFS 45 | + struct ukplat_memregion_desc memregion_desc; 46 | + int initrd; 47 | + enum cpio_error error; 48 | + 49 | + initrd = ukplat_memregion_find_initrd0(&memregion_desc); 50 | + if (initrd != -1) { 51 | + ukplat_memregion_get(initrd, &memregion_desc); 52 | + if (mount("", "/", "ramfs", 0, NULL) < 0) 53 | + return -CPIO_MOUNT_FAILED; 54 | + 55 | + error = 56 | + cpio_extract("/", memregion_desc.base, memregion_desc.len); 57 | + if (error < 0) 58 | + uk_pr_err("Failed to mount initrd\n"); 59 | + return error; 60 | + } 61 | + uk_pr_err("Failed to mount initrd\n"); 62 | + return -CPIO_NO_MEMREGION; 63 | +#else 64 | uk_pr_info("Mount %s to /...\n", rootfs); 65 | if (mount(rootdev, "/", rootfs, rootflags, rootopts) != 0) { 66 | uk_pr_crit("Failed to mount /: %d\n", errno); 67 | return -1; 68 | } 69 | - 70 | - /* 71 | - * TODO: Alternatively we could extract an archive found 72 | - * as initrd to a ramfs '/' if we have got fsname 'initrd' 73 | - */ 74 | - 75 | +#endif 76 | return 0; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/patches/flexos-ept2.diff: -------------------------------------------------------------------------------- 1 | diff --git a/main.c b/main.c 2 | index f1c2f3f..7183fda 100644 3 | --- a/main.c 4 | +++ b/main.c 5 | @@ -6,6 +6,11 @@ 6 | #include 7 | #include 8 | #include 9 | +#include 10 | +#include 11 | +#include 12 | +#include 13 | +#include 14 | 15 | #define ISSPACE(X) isspace((unsigned char)(X)) 16 | #define ISDIGIT(X) isdigit((unsigned char)(X)) 17 | @@ -29,7 +34,7 @@ static struct Global { 18 | static void fatal_error(const char *zMsg, ...){ 19 | va_list ap; 20 | va_start(ap, zMsg); 21 | - vfprintf(stderr, zMsg, ap); 22 | + uk_pr_crit(stderr, zMsg, ap); 23 | va_end(ap); 24 | exit(1); 25 | } 26 | @@ -146,43 +151,43 @@ int speedtest1_numbername(unsigned int n, char *zOut, int nOut){ 27 | 28 | if( n>=1000000000 ){ 29 | i += speedtest1_numbername(n/1000000000, zOut+i, nOut-i); 30 | - sqlite3_snprintf(nOut-i, zOut+i, " billion"); 31 | + //sqlite3_snprintf(nOut-i, zOut+i, " billion"); 32 | i += (int)strlen(zOut+i); 33 | n = n % 1000000000; 34 | } 35 | if( n>=1000000 ){ 36 | if( i && i=1000 ){ 44 | if( i && i=100 ){ 52 | if( i && i=20 ){ 59 | if( i && i0 ){ 66 | if( i && i0 && (zSql[n-1]==';' || ISSPACE(zSql[n-1])) ) n--; 108 | - fprintf(stderr,"%.*s;\n", n, zSql); 109 | + //fprintf(stderr,"%.*s;\n", n, zSql); 110 | } 111 | #endif /* SQLITE_OMIT_DEPRECATED */ 112 | 113 | @@ -316,7 +321,6 @@ void testset_main(void){ 114 | n = 5000; 115 | speedtest1_begin_test(100, "%d INSERTs into table with no index", n); 116 | //speedtest1_exec("BEGIN"); 117 | - //speedtest1_exec("CREATE TABLE tab (id INTEGER PRIMARY KEY, text TEXT NOT NULL);"); 118 | speedtest1_prepare("INSERT INTO tab VALUES (null, 'value');"); 119 | for(i=1; i<=n; i++){ 120 | speedtest1_run(); 121 | @@ -329,7 +333,8 @@ void testset_main(void){ 122 | # define sqlite3_sourceid(X) "(before 3.6.18)" 123 | #endif 124 | 125 | -int main(int argc, char **argv){ 126 | +int main(int argc, char *argv[]) 127 | +{ 128 | int mmapSize = 0; /* How big of a memory map to use */ 129 | const char *zTSet = "main"; /* Which --testset torun */ 130 | const char *zDbName = 0; /* Name of the test database */ 131 | @@ -338,7 +343,7 @@ int main(int argc, char **argv){ 132 | int rc; /* API return code */ 133 | 134 | /* Display the version of SQLite being tested */ 135 | - printf("-- Speedtest1 for SQLite %s %.50s\n", 136 | + uk_pr_err("-- Speedtest1 for SQLite %s %.50s\n", 137 | sqlite3_libversion(), sqlite3_sourceid()); 138 | 139 | /* Process command-line arguments */ 140 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Authors: Hugo Lefeuvre 4 | 5 | SECONDS=0 6 | 7 | # Run SQLite benchmark for Linux (userland process), Unikraft 0.5 (linuxu and 8 | # kvm), FlexOS (kvm), CubicleOS (linuxu). 9 | 10 | CPU_ISOLED1=$1 11 | CPU_ISOLED2=$2 12 | 13 | die() { echo "$*" 1>&2 ; exit 1; } 14 | 15 | if [ -z "$CPU_ISOLED1" ] 16 | then 17 | die "isolated CPU list not provided (read the main README!)" 18 | fi 19 | 20 | if [ -z "$CPU_ISOLED2" ] 21 | then 22 | die "isolated CPU list not provided (read the main README!)" 23 | fi 24 | 25 | apt install -y bc 26 | 27 | mkdir -p /out/results 28 | final=/out/results/sqlite.dat 29 | rm $final && touch $final 30 | 31 | tmp=$(mktemp) 32 | touch $tmp 33 | 34 | # --------- 35 | # CONSTANTS 36 | # --------- 37 | 38 | # number of reps in this benchmark 39 | REPS=10 40 | 41 | # ------- 42 | # HELPERS 43 | # ------- 44 | 45 | total=0 46 | runs=0 47 | 48 | header() { 49 | head="${1} ${2}" 50 | printf "%0.s-" $(seq 1 ${#head}) >> $tmp 51 | echo "" >> $tmp 52 | echo $head >> $tmp 53 | echo -e "run\ttime (s)" >> $tmp 54 | } 55 | 56 | parse_output() { 57 | # remove everything before TOTAL in case one of the images uses uk_pr_* functions 58 | res=`cat .out | tr -dc '[:alnum:]\n\r .' | sed "s/.*TOTAL/TOTAL/g" \ 59 | | awk -e '$0 ~ /TOTAL.../ {print $2}' | sed 's/[a-zA-Z]//g' | tr -d '\r'` 60 | if [ -z "$res" ] 61 | then 62 | echo -e "${1}\tERROR" >> $tmp 63 | else 64 | echo -e "${1}\t$res" >> $tmp 65 | runs=$((runs+1)) 66 | total=$(echo "$total + $res" | bc -l) 67 | fi 68 | } 69 | 70 | 71 | output_avg() { 72 | avg=$(echo "scale=3; $total / $runs" | bc -l | awk '{printf "%f", $0}') 73 | echo -e "AVERAGE = ${avg}s (${total}/${runs})" >> $tmp 74 | echo "$1 $2 $avg" >> $final 75 | total=0 76 | runs=0 77 | } 78 | 79 | benchmark_process() { 80 | header $1 "process" 81 | for j in $( seq 0 $REPS ); do 82 | script .out -c "./process-start.sh ${CPU_ISOLED1} ${CPU_ISOLED2}" 83 | parse_output $j 84 | done 85 | output_avg $2 $3 86 | } 87 | 88 | benchmark_linuxu() { 89 | header $1 "linuxu" 90 | for j in $( seq 0 $REPS ); do 91 | script .out -c "./linuxu-start.sh ${CPU_ISOLED1} ${CPU_ISOLED2}" 92 | parse_output $j 93 | done 94 | output_avg $2 $3 95 | } 96 | 97 | benchmark_kvm() { 98 | header $1 "KVM" 99 | for j in $( seq 0 $REPS ); do 100 | { 101 | sleep 3 102 | killall -9 qemu-system-x86 103 | } & 104 | script .out -c "./kvm-start.sh ${CPU_ISOLED1} ${CPU_ISOLED2}" 105 | wait 106 | parse_output $j 107 | done 108 | output_avg $2 $3 109 | } 110 | 111 | benchmark_genode() { 112 | header $1 "KVM" 113 | for j in $( seq 0 $REPS ); do 114 | script .out -c "make -C /genode/build/x86_64 KERNEL=sel4 BOARD=pc run/sqlite" 115 | parse_output $j 116 | done 117 | output_avg $2 $3 118 | } 119 | 120 | # --------- 121 | # BENCHMARK 122 | # --------- 123 | 124 | # Unikraft 0.5 125 | 126 | pushd unikraft-mainline/apps 127 | pushd app-sqlite-kvm 128 | benchmark_kvm "unikraft-mainline" 1 "\"NONE\"" 129 | popd 130 | pushd app-sqlite-linuxu 131 | benchmark_linuxu "unikraft-mainline" 2 "\"NONE\"" 132 | popd 133 | popd 134 | 135 | # FlexOS NONE 136 | 137 | pushd flexos/apps/sqlite-fcalls 138 | benchmark_kvm "flexos-nompk" 4 "\"NONE\"" 139 | popd 140 | 141 | # FlexOS MPK 3 COMP 142 | 143 | pushd flexos/apps/sqlite-mpk3 144 | benchmark_kvm "flexos-mpk3" 5 "\"MPK3\"" 145 | popd 146 | 147 | # FlexOS EPT 2 COMP 148 | 149 | pushd flexos/apps/sqlite-ept2 150 | benchmark_kvm "flexos-ept2" 6 "\"EPT2\"" 151 | popd 152 | 153 | # Linux userland 154 | 155 | pushd linux-userland 156 | benchmark_process "linux-userland" 8 "\"PT2\"" 157 | popd 158 | 159 | # SeL4 160 | 161 | benchmark_genode "genode-sel4" 10 "PT3" 162 | 163 | # CubicleOS NO MPK 164 | 165 | pushd cubicleos/CubicleOS/CubicleOS/app-sqlite 166 | benchmark_linuxu "cubicleos-nompk" 12 "\"NONE\"" 167 | popd 168 | 169 | # CubicleOS MPK 3 COMP 170 | 171 | pushd cubicleos/CubicleOS/CubicleOS/kernel 172 | # pre-configured for the 3-compartment scenario 173 | benchmark_linuxu "cubicleos-mpk3" 13 "\"MPK3\"" 174 | popd 175 | 176 | # some of the KVM experiments mess the terminal up 177 | reset 178 | 179 | cat $tmp 180 | 181 | duration=$SECONDS 182 | echo "Runtime: $(($duration / 60)) minutes and $(($duration % 60)) seconds." 183 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/sqlite.cpio: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/project-flexos/asplos22-ae/11a77fce56566e5ecc6be3946a60fcaeae864bf3/experiments/fig-10_sqlite-exec-time/docker-data/sqlite.cpio -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/start-scripts/kvm-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CPU_ISOLED1=$1 4 | CPU_ISOLED2=$2 5 | 6 | # verbose output 7 | set -x 8 | 9 | function cleanup { 10 | # kill all children (evil) 11 | pkill qemu-system-x86 12 | pkill -P $$ 13 | } 14 | 15 | trap "cleanup" EXIT 16 | 17 | taskset -c $CPU_ISOLED1 /root/qemu-guest -p $CPU_ISOLED2 \ 18 | -k /root/unikraft-mainline/apps/app-sqlite-kvm/build/app-sqlite_kvm-x86_64 \ 19 | -m 1000 -a "-mmap 0 database.db" -i /root/flexos/apps/sqlite-fcalls/sqlite.cpio 20 | 21 | # stop server 22 | pkill qemu-system-x86 23 | pkill qemu 24 | pkill qemu* 25 | 26 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/start-scripts/kvmflexosept2-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CPU_ISOLED1=$1 4 | CPU_ISOLED2=$2 5 | 6 | # ----- 7 | 8 | # EDIT ME if you run me elsewhere 9 | 10 | QEMU_BIN="/root/qemu-system-ept" 11 | 12 | # ----- 13 | 14 | # you should not need to edit these 15 | 16 | MEM=2G 17 | 18 | run() { 19 | # run compartment 1 (with delay) 20 | sleep 3 && taskset -c $CPU_ISOLED1 $QEMU_BIN -enable-kvm -daemonize -display none \ 21 | -device myshmem,file=/data_shared,size=0x2000,paddr=0x105000 \ 22 | -device myshmem,file=/rpc_page,size=0x100000,paddr=0x800000000 \ 23 | -device myshmem,file=/heap,size=0x8000000,paddr=0x4000000000 \ 24 | -initrd /root/flexos/apps/sqlite-fcalls/sqlite.cpio -kernel ${1}.comp1 \ 25 | -m $MEM -L /root/pc-bios & 26 | 27 | # run compartment 0 28 | taskset -c $CPU_ISOLED2 $QEMU_BIN -enable-kvm -nographic \ 29 | -device myshmem,file=/data_shared,size=0x2000,paddr=0x105000 \ 30 | -device myshmem,file=/rpc_page,size=0x100000,paddr=0x800000000 \ 31 | -device myshmem,file=/heap,size=0x8000000,paddr=0x4000000000 \ 32 | -kernel ${1}.comp0 -m $MEM -append "database.db" -L /root/pc-bios 33 | 34 | pkill -9 qemu-system-x86 35 | pkill -9 qemu-system-ept 36 | } 37 | 38 | run /root/flexos/apps/sqlite-ept2/build/sqlite_kvm-x86_64 39 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/start-scripts/kvmflexosfcalls-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CPU_ISOLED1=$1 4 | CPU_ISOLED2=$2 5 | 6 | # verbose output 7 | set -x 8 | 9 | function cleanup { 10 | # kill all children (evil) 11 | pkill qemu-system-x86 12 | pkill -P $$ 13 | } 14 | 15 | trap "cleanup" EXIT 16 | 17 | taskset -c $CPU_ISOLED1 /root/qemu-guest -p $CPU_ISOLED2 \ 18 | -k /root/flexos/apps/sqlite-fcalls/build/sqlite_kvm-x86_64 \ 19 | -m 1000 -a "-mmap 0 database.db" -i /root/flexos/apps/sqlite-fcalls/sqlite.cpio 20 | 21 | # stop server 22 | pkill qemu-system-x86 23 | pkill qemu 24 | pkill qemu* 25 | 26 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/start-scripts/kvmflexosmpk3-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CPU_ISOLED1=$1 4 | CPU_ISOLED2=$2 5 | 6 | # verbose output 7 | set -x 8 | 9 | function cleanup { 10 | # kill all children (evil) 11 | pkill qemu-system-x86 12 | pkill -P $$ 13 | } 14 | 15 | trap "cleanup" EXIT 16 | 17 | taskset -c $CPU_ISOLED1 /root/qemu-guest -p $CPU_ISOLED2 \ 18 | -k /root/flexos/apps/sqlite-mpk3/build/sqlite_kvm-x86_64 \ 19 | -m 1000 -a "-mmap 0 database.db" -i /root/flexos/apps/sqlite-mpk3/sqlite.cpio 20 | 21 | # stop server 22 | pkill qemu-system-x86 23 | pkill qemu 24 | pkill qemu* 25 | 26 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/start-scripts/linuxu-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CPU_ISOLED1=$1 4 | CPU_ISOLED2=$2 5 | 6 | # verbose output 7 | set -x 8 | 9 | function cleanup { 10 | # kill all children (evil) 11 | pkill -P $$ 12 | } 13 | 14 | trap "cleanup" EXIT 15 | 16 | taskset -c $CPU_ISOLED1 \ 17 | /root/unikraft-mainline/apps/app-sqlite-linuxu/build/app-sqlite_linuxu-x86_64 \ 18 | -mmap 0 database.db 19 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/docker-data/start-scripts/process-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CPU_ISOLED1=$1 4 | CPU_ISOLED2=$2 5 | 6 | # verbose output 7 | set -x 8 | 9 | function cleanup { 10 | # kill all children (evil) 11 | pkill -P $$ 12 | } 13 | 14 | trap "cleanup" EXIT 15 | 16 | if mount | grep /tmp | grep tmpfs >/dev/null; then 17 | ram_disk=/tmp/sqlite_ramdisk 18 | >&2 echo "/tmp on tmpfs, running experiment from $ram_disk" 19 | mkdir /tmp/sqlite_ramdisk 20 | else 21 | ram_disk=/mnt/sqlite_ramdisk 22 | >&2 echo "We'll mount a RAM disk at $ram_disk" 23 | mkdir /mnt/sqlite_ramdisk 24 | mount -t tmpfs none /mnt/sqlite_ramdisk 25 | fi 26 | 27 | rm ${ram_disk}/database.db 28 | touch ${ram_disk}/database.db 29 | 30 | taskset -c $CPU_ISOLED1 /root/linux-userland/sqlite-benchmark ${ram_disk}/database.db 31 | 32 | if [ "$ram_disk" = "/mnt/sqlite_ramdisk" ]; then 33 | >&2 echo "Unmounting RAM disk" 34 | umount "$ram_disk" 35 | fi 36 | >&2 echo "Removing $ram_disk" 37 | rmdir "$ram_disk" 38 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/flexos-sqlite.dockerfile: -------------------------------------------------------------------------------- 1 | # You can easily build it with the following command: 2 | # $ docker build --tag flexos-sqlite -f flexos-sqlite.dockerfile . 3 | # 4 | # If the build fails because you are rate-limited by GitHub, generate an app 5 | # token () and run instead: 6 | # $ docker build --build-arg UK_KRAFT_GITHUB_TOKEN="" --tag flexos-sqlite 7 | # 8 | # and run with: 9 | # $ docker run --privileged --security-opt seccomp:unconfined -ti flexos-sqlite bash 10 | # 11 | # (--security-opt seccomp:unconfined to limit docker overhead) 12 | 13 | FROM ghcr.io/project-flexos/flexos-ae-base:latest 14 | 15 | ARG GITHUB_TOKEN= 16 | ENV UK_KRAFT_GITHUB_TOKEN=${GITHUB_TOKEN} 17 | 18 | ############## 19 | # FlexOS (KVM) 20 | 21 | WORKDIR /root 22 | 23 | # build flexos with 3 compartments (vfscore+ramfs/uktime/rest) 24 | RUN kraftcleanup 25 | RUN cd /root/.unikraft/unikraft && git checkout 66f546dc6a2d8e13b47846ee29450f75b3ad388a 26 | COPY docker-data/configs/sqlite-flexos-mpk3.config /root/.unikraft/apps/sqlite/.config 27 | COPY docker-data/sqlite.cpio /root/.unikraft/apps/sqlite/ 28 | COPY docker-data/configs/kraft.yaml.mpk3 /root/.unikraft/apps/sqlite/kraft.yaml 29 | RUN cd /root/.unikraft/apps/sqlite && make prepare && \ 30 | kraft -v build --no-progress --fast --compartmentalize 31 | COPY docker-data/start-scripts/kvmflexosmpk3-start.sh /root/.unikraft/apps/sqlite/kvm-start.sh 32 | RUN mv /root/.unikraft/apps/sqlite /root/.unikraft/apps/sqlite-mpk3 33 | 34 | # build flexos with 2 compartments (EPT, vfscore/rest) 35 | RUN kraftcleanup 36 | RUN mv /root/.unikraft/apps/sqlite /root/.unikraft/apps/sqlite-ept2 37 | COPY docker-data/configs/sqlite-flexos-ept2.config /root/.unikraft/apps/sqlite-ept2/.config 38 | COPY docker-data/configs/kraft.yaml.ept2 /root/.unikraft/apps/sqlite-ept2/kraft.yaml 39 | COPY docker-data/patches/flexos-ept2.diff /root/.unikraft/apps/sqlite-ept2/ 40 | COPY docker-data/patches/flexos-ept2.diff.2 /root/.unikraft/apps/sqlite-ept2/ 41 | RUN cd /root/.unikraft/unikraft && git checkout 66f546dc6a2d8e13b47846ee29450f75b3ad388a && \ 42 | git apply /root/.unikraft/apps/sqlite-ept2/flexos-ept2.diff.2 43 | # no --no-progress here 44 | RUN cd /root/.unikraft/apps/sqlite-ept2 && git apply flexos-ept2.diff && \ 45 | make prepare && kraft -v build --fast --compartmentalize 46 | COPY docker-data/start-scripts/kvmflexosept2-start.sh /root/.unikraft/apps/sqlite-ept2/kvm-start.sh 47 | 48 | # build flexos with no compartments 49 | RUN kraftcleanup 50 | RUN cd /root/.unikraft/unikraft && git checkout 66f546dc6a2d8e13b47846ee29450f75b3ad388a 51 | RUN mv /root/.unikraft/apps/sqlite /root/.unikraft/apps/sqlite-fcalls 52 | COPY docker-data/configs/sqlite-flexos-fcalls.config /root/.unikraft/apps/sqlite-fcalls/.config 53 | COPY docker-data/sqlite.cpio /root/.unikraft/apps/sqlite-fcalls/ 54 | COPY docker-data/configs/kraft.yaml.fcalls /root/.unikraft/apps/sqlite-fcalls/kraft.yaml 55 | RUN cd /root/.unikraft/apps/sqlite-fcalls && make prepare && \ 56 | kraft -v build --no-progress --fast --compartmentalize 57 | COPY docker-data/start-scripts/kvmflexosfcalls-start.sh /root/.unikraft/apps/sqlite-fcalls/kvm-start.sh 58 | 59 | RUN mv /root/.unikraft /root/flexos 60 | 61 | ############## 62 | # Unikraft 0.5 (KVM and linuxu) 63 | # Performance is similar to Unikraft 0.4, so omit it. 64 | 65 | WORKDIR /root/unikraft-mainline/unikraft/ 66 | 67 | # apply cpio patches 68 | 69 | COPY docker-data/patches/cpio-patches/ cpio-patches/ 70 | RUN patch -p1 < cpio-patches/01.patch 71 | RUN patch -p1 < cpio-patches/02.patch 72 | RUN patch -p1 < cpio-patches/03.patch 73 | RUN patch -p1 < cpio-patches/04.patch 74 | RUN patch -p1 < cpio-patches/05.patch 75 | 76 | WORKDIR /root/unikraft-mainline/libs 77 | 78 | RUN git clone https://github.com/unikraft/lib-newlib.git 79 | RUN cd lib-newlib && git checkout ddc25cf1f361e33d1003ce1842212e8ff37b1e08 80 | 81 | RUN git clone https://github.com/unikraft/lib-pthread-embedded.git 82 | RUN cd lib-pthread-embedded && git checkout 2dd71294ab5fac328e62932992550405c866c7e8 83 | 84 | RUN git clone https://github.com/unikraft/lib-sqlite.git 85 | RUN cd lib-sqlite && git checkout 21ec31d578295982619a164de96b653e93e7cf9c 86 | 87 | RUN git clone https://github.com/unikraft/lib-tlsf.git 88 | RUN cd lib-tlsf && git checkout ae4f7402a2c5ee6040dab799b397537177306cc9 89 | 90 | WORKDIR /root/unikraft-mainline/apps 91 | 92 | RUN mkdir -p app-sqlite-kvm 93 | 94 | RUN cd app-sqlite-kvm && \ 95 | echo "\$(eval \$(call addlib,appsqlite))" > Makefile.uk 96 | RUN cd app-sqlite-kvm && \ 97 | echo "APPSQLITE_SRCS-y += \$(APPSQLITE_BASE)/main.c" >> Makefile.uk 98 | RUN cd app-sqlite-kvm && \ 99 | echo "APPSQLITE_CINCLUDES-y += -I\$(APPSQLITE_BASE)/include" >> Makefile.uk 100 | 101 | COPY docker-data/Makefile app-sqlite-kvm/ 102 | COPY docker-data/main.c app-sqlite-kvm/ 103 | COPY docker-data/include app-sqlite-kvm/ 104 | 105 | RUN cp -r app-sqlite-kvm app-sqlite-linuxu 106 | RUN sed -i -e "s/#if 1/#if 0/g" app-sqlite-kvm/main.c 107 | 108 | COPY docker-data/configs/sqlite-kvm.config app-sqlite-kvm/.config 109 | COPY docker-data/start-scripts/kvm-start.sh app-sqlite-kvm/ 110 | RUN cd app-sqlite-kvm && make prepare && make -j 111 | 112 | COPY docker-data/configs/sqlite-linuxu.config app-sqlite-linuxu/.config 113 | COPY docker-data/start-scripts/linuxu-start.sh app-sqlite-linuxu/ 114 | RUN cd app-sqlite-linuxu && make prepare && make -j 115 | 116 | ############## 117 | # CubicleOS (linuxu) w/ and w/o MPK 118 | 119 | RUN mkdir -p /root/cubicleos 120 | WORKDIR /root/cubicleos 121 | 122 | RUN git clone https://github.com/lsds/CubicleOS.git && cd CubicleOS && \ 123 | git checkout ASPLOS_AE 124 | 125 | COPY docker-data/patches/cubicleos.diff /root/cubicleos/ 126 | RUN cd CubicleOS/ && patch -p1 < /root/cubicleos/cubicleos.diff 127 | RUN cd CubicleOS/CubicleOS/app-sqlite/ && make 128 | RUN cd CubicleOS/CubicleOS/kernel/ && make sqlite 129 | RUN mv CubicleOS/CubicleOS/kernel/run.sh CubicleOS/CubicleOS/kernel/linuxu-start.sh 130 | RUN mv CubicleOS/CubicleOS/app-sqlite/run.sh CubicleOS/CubicleOS/app-sqlite/linuxu-start.sh 131 | 132 | ############## 133 | # Linux (process) 134 | 135 | RUN mkdir -p /root/linux-userland 136 | WORKDIR /root/linux-userland 137 | COPY docker-data/main.c . 138 | COPY docker-data/start-scripts/process-start.sh . 139 | RUN gcc main.c -lsqlite3 -O2 -o ./sqlite-benchmark 140 | 141 | 142 | ############## 143 | # Genode (KVM) 3 compartments 144 | 145 | ADD https://www.doc.ic.ac.uk/~vsartako/asplos/genode.tar.gz /root 146 | ADD https://www.doc.ic.ac.uk/~vsartako/asplos/tch.tar.xz /root 147 | RUN cd / && tar -xf /root/tch.tar.xz 148 | RUN cd / && tar -xf /root/genode.tar.gz 149 | WORKDIR /genode 150 | RUN mv /root/genode.tar.gz . 151 | RUN mv /root/tch.tar.xz . 152 | COPY docker-data/main.c repos/sqlite/src/sqlite/main.c 153 | RUN sed -i '//d' repos/sqlite/run/sqlite.run 154 | RUN sed -i '//d' repos/sqlite/run/sqlite.run 155 | RUN sed -i '//d' repos/sqlite/run/sqlite.run 156 | # this triggers warnings that skew results 157 | RUN sed -i 's/osFchown(fd,uid,gid)/0/g' /genode/repos/sqlite/src/sqlite/sqlite3.c 158 | RUN ./tool/create_builddir x86_64 159 | COPY docker-data/configs/genode.conf build/x86_64/etc/build.conf 160 | 161 | ############## 162 | # Finish 163 | 164 | WORKDIR /root 165 | 166 | COPY docker-data/run.sh . 167 | RUN chmod u+x run.sh 168 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/results/sqlite.dat: -------------------------------------------------------------------------------- 1 | 1 "NONE" 0.052000 2 | 2 "NONE" 0.702000 3 | 4 "NONE" 0.054000 4 | 5 "MPK3" 0.106000 5 | 6 "EPT2" 0.173000 6 | 8 "PT2" 0.177000 7 | 10 PT3 0.333000 8 | 12 "NONE" 0.657000 9 | 13 "MPK3" 1.557000 10 | -------------------------------------------------------------------------------- /experiments/fig-10_sqlite-exec-time/sqlite.plot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | 3 | reset 4 | 5 | set terminal svg enhanced size 650,250 font 'Arial,20' 6 | set output '/out/sqlite.svg' 7 | 8 | set grid 9 | 10 | # Make the x axis labels easier to read. 11 | set xtics font ",16" nomirror rotate by 20 scale 0 right 12 | set ytics nomirror 13 | 14 | # remove useless margins 15 | set bmargin 1.5 16 | set lmargin 7 17 | set rmargin 1 18 | #set tmargin 0.5 19 | 20 | # offsets reduces the space at the extreme left & right borders 21 | # to minimize white space 22 | set offsets -0.5, -0.5, 0, 0 23 | 24 | # Select histogram data 25 | set style histogram rowstacked 26 | set style data histogram 27 | 28 | # Bar style 29 | set style fill pattern border -1 30 | set boxwidth 0.5 31 | 32 | # make sure that the legend doesn't take too much space 33 | unset key 34 | set key samplen 1.5 outside above center horizontal font ",18" 35 | 36 | # important to display labels 37 | set datafile missing '-' 38 | 39 | # uncomment this to get the title 40 | #set title "Time to perform 5000 INSERTs in SQLite." 41 | 42 | # ensure that y label doesn't take too much space 43 | set ylabel "SQLite execution time (s)" offset 2,0 44 | set lmargin 7 45 | 46 | set yrange [0:2.5] 47 | set xrange [0:14] 48 | 49 | set label "Unikraft" at 0.750,2.25 font ",18" 50 | set label "FlexOS" at 4.220,2.25 font ",18" 51 | set label "Linux" at 7.450,2.25 font ",18" 52 | set label "SeL4/" at 9.400,2.25 font ",18" 53 | set label "Genode" at 9.200,2.00 font ",18" 54 | set label "CubicleOS" at 11.45,2.25 font ",18" 55 | 56 | set label ".052" at 0.600,0.242 font ",16" 57 | set label ".702" at 1.550,0.892 font ",16" 58 | set label ".054" at 3.550,0.244 font ",16" 59 | set label ".106" at 4.550,0.296 font ",16" 60 | set label ".173" at 5.550,0.363 font ",16" 61 | set label ".177" at 7.550,0.367 font ",16" 62 | set label ".333" at 9.550,0.523 font ",16" 63 | set label ".657" at 11.55,0.847 font ",16" 64 | set label "1.557" at 12.5,1.747 font ",16" 65 | 66 | set arrow from 3, graph 0 to 3, graph 1 nohead 67 | set arrow from 7, graph 0 to 7, graph 1 nohead 68 | set arrow from 9, graph 0 to 9, graph 1 nohead 69 | set arrow from 11, graph 0 to 11, graph 1 nohead 70 | 71 | plot "/out/results/sqlite.dat" \ 72 | every 9::0 using 1:3:xtic(2) with boxes fs pattern 1 lc "#91c6e7" title "QEMU/KVM", \ 73 | "" every 9::1 using 1:3:xtic(2) with boxes fs pattern 6 lc "#a2d9d1" notitle, \ 74 | "" every 9::2 using 1:3:xtic(2) with boxes fs pattern 1 lc "#91c6e7" notitle, \ 75 | "" every 9::3 using 1:3:xtic(2) with boxes fs pattern 1 lc "#91c6e7" notitle, \ 76 | "" every 9::4 using 1:3:xtic(2) with boxes fs pattern 6 lc "#a2d9d1" title "linuxu", \ 77 | "" every 9::5 using 1:3:xtic(2) with boxes fs pattern 2 lc "#d18282" title "Process", \ 78 | "" every 9::6 using 1:3:xtic(2) with boxes fs pattern 1 lc "#91c6e7" notitle, \ 79 | "" every 9::7 using 1:3:xtic(2) with boxes fs pattern 6 lc "#a2d9d1" notitle, \ 80 | "" every 9::8 using 1:3:xtic(2) with boxes fs pattern 6 lc "#a2d9d1" notitle 81 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/.gitignore: -------------------------------------------------------------------------------- 1 | linux-latency/ 2 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Files and directories 3 | # 4 | WORKDIR ?= $(CURDIR) 5 | RESULTS ?= $(WORKDIR)/results 6 | PLOT_FORMAT ?= svg 7 | PLOT-DSS ?= $(WORKDIR)/$(notdir $(WORKDIR))-a.$(PLOT_FORMAT) 8 | PLOT-LATENCY ?= $(WORKDIR)/$(notdir $(WORKDIR))-b.$(PLOT_FORMAT) 9 | 10 | # 11 | # Parameters 12 | # 13 | KRAFT_TOKEN ?= 14 | ISOLED_CPU1 ?= 5 15 | ISOLED_CPU2 ?= 6 16 | 17 | # 18 | # Tools 19 | # 20 | GNUPLOT ?= gnuplot 21 | DOCKER ?= docker 22 | TIME ?= /usr/bin/time 23 | 24 | # 25 | # Targets 26 | # 27 | .PHONY: all 28 | all: prepare run plot 29 | 30 | .PHONY: prepare-flexos 31 | prepare-flexos: 32 | $(TIME) $(DOCKER) build -f $(WORKDIR)/flexos-microbenchmarks.dockerfile \ 33 | --build-arg GITHUB_TOKEN="$(KRAFT_TOKEN)" \ 34 | --tag flexos-microbenchmarks $(WORKDIR) 35 | 36 | linux-latency: 37 | git clone https://github.com/project-flexos/app-flexos-microbenchmarks.git 38 | mv app-flexos-microbenchmarks linux-latency 39 | 40 | .PHONY: prepare-linux 41 | prepare-linux: linux-latency 42 | $(TIME) make linux -C linux-latency 43 | 44 | .PHONY: prepare 45 | prepare: prepare-flexos prepare-linux 46 | 47 | .PHONY: run-flexos 48 | run-flexos: 49 | $(DOCKER) run --rm -v $(WORKDIR):/out --privileged \ 50 | --security-opt seccomp:unconfined -ti flexos-microbenchmarks \ 51 | /root/run.sh $(ISOLED_CPU1) $(ISOLED_CPU2) 52 | 53 | .PHONY: run-linux 54 | run-linux: 55 | mkdir -p $(RESULTS) 56 | $(WORKDIR)/tools/benchmark_linux.sh $(RESULTS) $(WORKDIR)/linux-latency $(ISOLED_CPU1) 57 | 58 | .PHONY: run 59 | run: run-flexos run-linux 60 | 61 | .PHONY: plot 62 | plot: 63 | rm -rf $(PLOT-LATENCY) $(PLOT-DSS) 64 | $(DOCKER) run --rm -v $(WORKDIR):/out --privileged -ti \ 65 | ghcr.io/project-flexos/flexos-ae-plot $(GNUPLOT) /out/dss.plot 66 | mv $(WORKDIR)/dss.svg $(PLOT-DSS) 67 | $(DOCKER) run --rm -v $(WORKDIR):/out --privileged -ti \ 68 | ghcr.io/project-flexos/flexos-ae-plot $(GNUPLOT) /out/latency.plot 69 | mv $(WORKDIR)/latency.svg $(PLOT-LATENCY) 70 | 71 | .PHONY: clean 72 | clean: 73 | rm -rf results $(PLOT-LATENCY) $(PLOT-DSS) linux-benchmark 74 | 75 | .PHONY: properclean 76 | properclean: clean 77 | $(DOCKER) image rm -f flexos-microbenchmarks 78 | $(DOCKER) image prune -f 79 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/README.md: -------------------------------------------------------------------------------- 1 | # FlexOS Latency Microbenchmarks 2 | 3 | 4 | 5 | | Estimated prep. time | Estimated runtime | 6 | | -------------------- | ----------------- | 7 | | 0h 35m | 0h 04m | 8 | 9 | ## Overview 10 | 11 | Gate and allocation latency microbenchmarks. FlexOS is compared with Linux 12 | (with and without KPTI). 13 | 14 | ### Measurement workflow 15 | 16 | This experiment is somewhat special, as it requires one measurement with KPTI 17 | disabled on the host system. This requires changes to the kernel command line 18 | and a reboot. The workflow is therefore slightly different, but we tried to 19 | make it as streamlined as possible: 20 | 21 | 1. Prepare the experiment as usual with `make prepare` 22 | 2. Run the first numbers as usual with `make run` 23 | 3. Disable KPTI using `./toggle-kpti.sh off` 24 | 4. After the reboot, run `make run` again 25 | 5. Re-enable KPTI with `./toggle-kpti.sh on` 26 | 27 | As soon as you are done with step (4), we recommend that you immediately proceed to 28 | step 5 to reset the machine to its initial state. 29 | 30 | Note (especially to ASPLOS'22 AE reviewers): disabling KPTI will affect all 31 | other measurements, not only Linux for this figure. Make sure to re-enable KPTI 32 | as soon as you are done with this measurement. Cooperation among reviewers for 33 | this benchmark is recommended. 34 | 35 | ### Plot 36 | 37 | The latency plot contains some hardcoded data. If you want to generate a plot 38 | for your new run, you will need to edit the plot script. The values that you 39 | will want to adapt are the labels (and potentially their position). 40 | 41 | ## Troubleshooting 42 | 43 | - **Problem**: Every once in a while, EPT results increase to ~700 cycles 44 | (instead of ~500 expected). 45 | 46 | **Solution**: It is not entirely clear why this happens. We suspect a 47 | combination of unlucky scheduling of vCPU threads (not pinned 48 | in this specific case due to a missing implementation in `qemu-guest`), and 49 | cache effects. In our measurements this was a rather rare symptom and 50 | we therefore considered it as minor. We recommend to simply restart the benchmark 51 | in this case. 52 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/docker-data/configs/kraft.yaml.ept2: -------------------------------------------------------------------------------- 1 | --- 2 | specification: '0.6' 3 | name: flexos-microbenchmarks 4 | unikraft: 5 | version: staging 6 | kconfig: 7 | - CONFIG_LIBFLEXOS=y 8 | targets: 9 | - architecture: x86_64 10 | platform: kvm 11 | compartments: 12 | - name: comp1 13 | mechanism: 14 | driver: vmept 15 | noisolstack: false 16 | default: true 17 | - name: comp2 18 | mechanism: 19 | driver: vmept 20 | noisolstack: true 21 | libraries: 22 | tlsf: 23 | version: staging 24 | kconfig: 25 | - CONFIG_LIBTLSF=y 26 | newlib: 27 | version: staging 28 | kconfig: 29 | - CONFIG_LIBNEWLIBC=y 30 | - CONFIG_LIBNEWLIBM=y 31 | compartment: comp1 32 | flexos-microbenchmarks: 33 | version: staging 34 | compartment: comp2 35 | volumes: {} 36 | networks: {} 37 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/docker-data/configs/kraft.yaml.mpk2: -------------------------------------------------------------------------------- 1 | --- 2 | specification: '0.6' 3 | name: flexos-microbenchmarks 4 | unikraft: 5 | version: staging 6 | kconfig: 7 | - CONFIG_LIBFLEXOS=y 8 | targets: 9 | - architecture: x86_64 10 | platform: kvm 11 | compartments: 12 | - name: comp1 13 | mechanism: 14 | driver: intel-pku 15 | noisolstack: false 16 | default: true 17 | - name: comp2 18 | mechanism: 19 | driver: intel-pku 20 | noisolstack: true 21 | libraries: 22 | tlsf: 23 | version: staging 24 | kconfig: 25 | - CONFIG_LIBTLSF=y 26 | newlib: 27 | version: staging 28 | kconfig: 29 | - CONFIG_LIBNEWLIBC=y 30 | - CONFIG_LIBNEWLIBM=y 31 | compartment: comp1 32 | flexos-microbenchmarks: 33 | version: staging 34 | compartment: comp2 35 | volumes: {} 36 | networks: {} 37 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/docker-data/configs/microbenchmarks-flexos-ept2.config: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated file; DO NOT EDIT. 3 | # Unikraft/0.5.0~66f546d-custom Configuration 4 | # 5 | CONFIG_UK_FULLVERSION="0.5.0~66f546d-custom" 6 | CONFIG_UK_CODENAME="Tethys" 7 | CONFIG_UK_ARCH="x86_64" 8 | CONFIG_UK_BASE="/root/.unikraft/unikraft" 9 | CONFIG_UK_APP="/root/.unikraft/apps/flexos-microbenchmarks" 10 | CONFIG_UK_DEFNAME="flexos-microbenchmarks" 11 | 12 | # 13 | # Architecture Selection 14 | # 15 | CONFIG_ARCH_X86_64=y 16 | # CONFIG_ARCH_ARM_64 is not set 17 | # CONFIG_ARCH_ARM_32 is not set 18 | # CONFIG_MARCH_X86_64_NATIVE is not set 19 | CONFIG_MARCH_X86_64_GENERIC=y 20 | # CONFIG_MARCH_X86_64_NOCONA is not set 21 | # CONFIG_MARCH_X86_64_CORE2 is not set 22 | # CONFIG_MARCH_X86_64_COREI7 is not set 23 | # CONFIG_MARCH_X86_64_COREI7AVX is not set 24 | # CONFIG_MARCH_X86_64_COREI7AVXI is not set 25 | # CONFIG_MARCH_X86_64_ATOM is not set 26 | # CONFIG_MARCH_X86_64_K8 is not set 27 | # CONFIG_MARCH_X86_64_K8SSE3 is not set 28 | # CONFIG_MARCH_X86_64_AMDFAM10 is not set 29 | # CONFIG_MARCH_X86_64_BTVER1 is not set 30 | # CONFIG_MARCH_X86_64_BDVER1 is not set 31 | # CONFIG_MARCH_X86_64_BDVER2 is not set 32 | # CONFIG_MARCH_X86_64_BDVER3 is not set 33 | # CONFIG_MARCH_X86_64_BTVER2 is not set 34 | CONFIG_STACK_SIZE_PAGE_ORDER=4 35 | # end of Architecture Selection 36 | 37 | # 38 | # Platform Configuration 39 | # 40 | CONFIG_PLAT_KVM=y 41 | 42 | # 43 | # Console Options 44 | # 45 | CONFIG_KVM_KERNEL_SERIAL_CONSOLE=y 46 | CONFIG_KVM_KERNEL_VGA_CONSOLE=y 47 | CONFIG_KVM_DEBUG_SERIAL_CONSOLE=y 48 | CONFIG_KVM_DEBUG_VGA_CONSOLE=y 49 | 50 | # 51 | # Serial console configuration 52 | # 53 | CONFIG_KVM_SERIAL_BAUD_115200=y 54 | # CONFIG_KVM_SERIAL_BAUD_57600 is not set 55 | # CONFIG_KVM_SERIAL_BAUD_38400 is not set 56 | # CONFIG_KVM_SERIAL_BAUD_19200 is not set 57 | # end of Serial console configuration 58 | # end of Console Options 59 | 60 | CONFIG_KVM_PCI=y 61 | CONFIG_VIRTIO_BUS=y 62 | 63 | # 64 | # Virtio 65 | # 66 | # CONFIG_VIRTIO_PCI is not set 67 | # end of Virtio 68 | 69 | # CONFIG_PLAT_LINUXU is not set 70 | # CONFIG_PLAT_XEN is not set 71 | 72 | # 73 | # Platform Interface Options 74 | # 75 | CONFIG_UKPLAT_MEMRNAME=y 76 | CONFIG_PT_API=y 77 | CONFIG_DYNAMIC_PT=y 78 | # end of Platform Interface Options 79 | 80 | CONFIG_HZ=100 81 | # end of Platform Configuration 82 | 83 | # 84 | # Library Configuration 85 | # 86 | # CONFIG_LIBDEVFS is not set 87 | # CONFIG_LIBFDT is not set 88 | CONFIG_LIBFLEXOS=y 89 | # CONFIG_LIBFLEXOS_INTELPKU is not set 90 | CONFIG_LIBFLEXOS_VMEPT=y 91 | # CONFIG_LIBFLEXOS_VMEPT_LIBRARY is not set 92 | # CONFIG_LIBFLEXOS_NONE is not set 93 | CONFIG_LIBFLEXOS_COMP_HEAP_SIZE=10000 94 | # CONFIG_LIBFLEXOS_DEBUG is not set 95 | # CONFIG_LIBKASAN is not set 96 | # CONFIG_LIBPOSIX_LIBDL is not set 97 | # CONFIG_LIBPOSIX_MMAP is not set 98 | CONFIG_LIBPOSIX_PROCESS=y 99 | # CONFIG_LIBPOSIX_SYSINFO is not set 100 | CONFIG_LIBPOSIX_USER=y 101 | CONFIG_LIBRAMFS=y 102 | # CONFIG_LIBSYSCALL_SHIM is not set 103 | # CONFIG_LIBUBSAN is not set 104 | # CONFIG_LIBUK9P is not set 105 | CONFIG_LIBUKALLOC=y 106 | CONFIG_LIBUKALLOC_IFMALLOC=y 107 | # CONFIG_LIBUKALLOC_IFSTATS is not set 108 | CONFIG_LIBUKALLOCBBUDDY=y 109 | # CONFIG_LIBUKALLOCPOOL is not set 110 | # CONFIG_LIBUKALLOCREGION is not set 111 | CONFIG_LIBUKARGPARSE=y 112 | # CONFIG_LIBUKBLKDEV is not set 113 | CONFIG_LIBUKBOOT=y 114 | # CONFIG_LIBUKBOOT_BANNER_NONE is not set 115 | # CONFIG_LIBUKBOOT_BANNER_MINIMAL is not set 116 | # CONFIG_LIBUKBOOT_BANNER_CLASSIC is not set 117 | CONFIG_LIBUKBOOT_BANNER_POWEREDBY=y 118 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI is not set 119 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI2 is not set 120 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EA is not set 121 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI is not set 122 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI2 is not set 123 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8 is not set 124 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI is not set 125 | # CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI2 is not set 126 | CONFIG_LIBUKBOOT_MAXNBARGS=60 127 | CONFIG_LIBUKBOOT_INITBBUDDY=y 128 | # CONFIG_LIBUKBOOT_INITREGION is not set 129 | # CONFIG_LIBUKBOOT_INITTLSF is not set 130 | # CONFIG_LIBUKBOOT_NOALLOC is not set 131 | CONFIG_LIBUKBUS=y 132 | CONFIG_LIBUKDEBUG=y 133 | CONFIG_LIBUKDEBUG_PRINTK=y 134 | # CONFIG_LIBUKDEBUG_PRINTK_INFO is not set 135 | # CONFIG_LIBUKDEBUG_PRINTK_WARN is not set 136 | CONFIG_LIBUKDEBUG_PRINTK_ERR=y 137 | # CONFIG_LIBUKDEBUG_PRINTK_CRIT is not set 138 | # CONFIG_LIBUKDEBUG_PRINTD is not set 139 | # CONFIG_LIBUKDEBUG_NOREDIR is not set 140 | CONFIG_LIBUKDEBUG_REDIR_PRINTD=y 141 | # CONFIG_LIBUKDEBUG_REDIR_PRINTK is not set 142 | CONFIG_LIBUKDEBUG_PRINT_TIME=y 143 | # CONFIG_LIBUKDEBUG_PRINT_STACK is not set 144 | CONFIG_LIBUKDEBUG_PRINT_SRCNAME=y 145 | # CONFIG_LIBUKDEBUG_ANSI_COLOR is not set 146 | # CONFIG_LIBUKDEBUG_ENABLE_ASSERT is not set 147 | # CONFIG_LIBUKDEBUG_TRACEPOINTS is not set 148 | CONFIG_LIBUKLIBPARAM=y 149 | CONFIG_LIBUKLOCK=y 150 | CONFIG_LIBUKLOCK_SEMAPHORE=y 151 | CONFIG_LIBUKLOCK_MUTEX=y 152 | # CONFIG_LIBUKMMAP is not set 153 | # CONFIG_LIBUKMPI is not set 154 | # CONFIG_LIBUKNETDEV is not set 155 | # CONFIG_LIBUKRING is not set 156 | CONFIG_LIBUKSCHED=y 157 | CONFIG_LIBUKSCHEDCOOP=y 158 | CONFIG_LIBUKSGLIST=y 159 | CONFIG_LIBUKSIGNAL=y 160 | # CONFIG_LIBUKSP is not set 161 | # CONFIG_LIBUKSWRAND is not set 162 | CONFIG_LIBUKTIME=y 163 | CONFIG_LIBUKTIMECONV=y 164 | CONFIG_LIBVFSCORE=y 165 | 166 | # 167 | # vfscore: Configuration 168 | # 169 | CONFIG_LIBCPIO=y 170 | CONFIG_LIBINITRAMFS=y 171 | CONFIG_LIBVFSCORE_PIPE_SIZE_ORDER=16 172 | CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y 173 | CONFIG_LIBVFSCORE_ROOTFS_RAMFS=y 174 | # CONFIG_LIBVFSCORE_ROOTFS_9PFS is not set 175 | # CONFIG_LIBVFSCORE_ROOTFS_CUSTOM is not set 176 | CONFIG_LIBVFSCORE_ROOTFS="ramfs" 177 | # end of vfscore: Configuration 178 | 179 | CONFIG_HAVE_BOOTENTRY=y 180 | CONFIG_HAVE_LIBC=y 181 | CONFIG_HAVE_TIME=y 182 | CONFIG_HAVE_SCHED=y 183 | CONFIG_LIBNEWLIBC=y 184 | CONFIG_LIBNEWLIBM=y 185 | # CONFIG_LIBNEWLIBC_WANT_IO_C99_FORMATS is not set 186 | # CONFIG_LIBNEWLIBC_LINUX_ERRNO_EXTENSIONS is not set 187 | CONFIG_LIBNEWLIBC_CRYPT=y 188 | CONFIG_LIBTLSF_INCLUDED=y 189 | CONFIG_LIBTLSF=y 190 | CONFIG_TLSF_LOG2_SLI=5 191 | CONFIG_LIBFLEXOSMICROBENCHMARKS=y 192 | # end of Library Configuration 193 | 194 | # 195 | # Build Options 196 | # 197 | # CONFIG_OPTIMIZE_NONE is not set 198 | CONFIG_OPTIMIZE_PERF=y 199 | # CONFIG_OPTIMIZE_SIZE is not set 200 | 201 | # 202 | # Hint: Specify a CPU type to get most benefits from performance optimization 203 | # 204 | # CONFIG_OPTIMIZE_DEADELIM is not set 205 | # CONFIG_OPTIMIZE_LTO is not set 206 | # CONFIG_DEBUG_SYMBOLS_LVL0 is not set 207 | # CONFIG_DEBUG_SYMBOLS_LVL1 is not set 208 | # CONFIG_DEBUG_SYMBOLS_LVL2 is not set 209 | CONFIG_DEBUG_SYMBOLS_LVL3=y 210 | # CONFIG_OPTIMIZE_SYMFILE is not set 211 | CONFIG_OPTIMIZE_COMPRESS=y 212 | # CONFIG_RECORD_BUILDTIME is not set 213 | CONFIG_CROSS_COMPILE="" 214 | CONFIG_LLVM_TARGET_ARCH="" 215 | # end of Build Options 216 | 217 | # 218 | # Application Options 219 | # 220 | CONFIG_APPFLEXOSMICROBENCHMARKS_DEPENDENCIES=y 221 | # end of Application Options 222 | 223 | CONFIG_UK_NAME="flexos-microbenchmarks" 224 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/docker-data/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Authors: Hugo Lefeuvre 4 | 5 | SECONDS=0 6 | 7 | # Do not run without KPTI 8 | 9 | CPU_ISOLED1=$1 10 | CPU_ISOLED2=$2 11 | GRUB_FILE="/proc/cmdline" 12 | 13 | die() { echo "$*" 1>&2 ; exit 1; } 14 | 15 | if [ -z "$CPU_ISOLED1" ] 16 | then 17 | die "isolated CPU list not provided (read the main README!)" 18 | fi 19 | 20 | if [ -z "$CPU_ISOLED2" ] 21 | then 22 | die "isolated CPU list not provided (read the main README!)" 23 | fi 24 | 25 | if grep -q "pti=off" $GRUB_FILE; then 26 | echo "[X] Not running FlexOS as KPTI is disabled." 27 | # exit 0 to not stop make run, this is not a failure 28 | exit 0 29 | fi 30 | 31 | if grep -q "nopti" $GRUB_FILE; then 32 | echo "[X] Not running FlexOS as KPTI is disabled." 33 | # exit 0 to not stop make run, this is not a failure 34 | exit 0 35 | fi 36 | 37 | # Run microbenchmark and process data for FlexOS. 38 | 39 | mkdir -p /out/results 40 | final_latcy=/out/results/latency-flexos.dat 41 | final_alloc=/out/results/dss.dat 42 | rm $final_latcy && touch $final_latcy 43 | rm $final_alloc && touch $final_alloc 44 | 45 | # ------- 46 | # RESULTS 47 | # ------- 48 | 49 | function_cost="" 50 | mpklight_cost="" 51 | mpkdss_cost="" 52 | ept_cost="" 53 | 54 | dss1="" 55 | dss2="" 56 | dss3="" 57 | 58 | heap1="" 59 | heap2="" 60 | heap3="" 61 | 62 | # ------- 63 | # HELPERS 64 | # ------- 65 | 66 | get_val() { 67 | echo `cat .out | tr -dc '[:alnum:]\n\r .,-' \ 68 | | sed "s/.*$1,/$1,/g" | grep "^$1," | sed "s/$1,//g" | tr -dc '[:alnum:]'` 69 | } 70 | 71 | set_val() { 72 | if [ -n "$1" ]; then 73 | if [ -n "${!2}" ]; then 74 | echo "ERROR: the same measurement is reevaluated twice. Is this a bug?" 75 | exit 1 76 | fi 77 | eval $2=$1 78 | fi 79 | } 80 | 81 | parse_output() { 82 | tentative=$(get_val "pku-dss") 83 | set_val "$tentative" "mpkdss_cost" 84 | 85 | tentative=$(get_val "pku-shared") 86 | set_val "$tentative" "mpklight_cost" 87 | 88 | tentative=$(get_val "ept") 89 | set_val "$tentative" "ept_cost" 90 | 91 | tentative=$(get_val "fcall") 92 | # don't use set_val here, that measurement will pop again all the time... 93 | if [ -n "$tentative" ]; then 94 | if [ ! -n "$function_cost" ]; then 95 | function_cost=$tentative 96 | fi 97 | fi 98 | 99 | tentative=$(get_val "dss1") 100 | set_val "$tentative" "dss1" 101 | tentative=$(get_val "dss2") 102 | set_val "$tentative" "dss2" 103 | tentative=$(get_val "dss3") 104 | set_val "$tentative" "dss3" 105 | 106 | tentative=$(get_val "heap1") 107 | set_val "$tentative" "heap1" 108 | tentative=$(get_val "heap2") 109 | set_val "$tentative" "heap2" 110 | tentative=$(get_val "heap3") 111 | set_val "$tentative" "heap3" 112 | } 113 | 114 | benchmark_kvm() { 115 | { 116 | sleep 30 117 | killall -9 qemu-system-x86 118 | } & 119 | script .out -c "./kvm-start.sh run build/flexos-microbenchmarks_kvm-x86_64 $CPU_ISOLED1 $CPU_ISOLED2" 120 | wait 121 | parse_output 122 | ./kvm-start.sh kill 123 | } 124 | 125 | # --------- 126 | # BENCHMARK 127 | # --------- 128 | 129 | # FlexOS MPK 2 COMP noisolstack 130 | 131 | pushd flexos/apps/flexos-microbenchmarks-mpk2-noisolstack 132 | benchmark_kvm 133 | popd 134 | 135 | # FlexOS MPK 2 COMP isolstack 136 | 137 | pushd flexos/apps/flexos-microbenchmarks-mpk2-isolstack 138 | benchmark_kvm 139 | popd 140 | 141 | # FlexOS MPK 2 COMP isolstack no DSS 142 | 143 | pushd flexos/apps/flexos-microbenchmarks-mpk2-isolstack-heap 144 | benchmark_kvm 145 | popd 146 | 147 | # FlexOS EPT 2 COMP 148 | 149 | pushd flexos/apps/flexos-microbenchmarks-ept2 150 | benchmark_kvm 151 | popd 152 | 153 | # some of the KVM experiments mess the terminal up 154 | reset 155 | 156 | # ------------- 157 | # FORMAT OUTPUT 158 | # ------------- 159 | 160 | echo "1 \"function\" $function_cost" >> $final_latcy 161 | echo "3 \"MPK-light\" $mpklight_cost" >> $final_latcy 162 | echo "4 \"MPK-dss\" $mpkdss_cost" >> $final_latcy 163 | echo "5 \"EPT\" $ept_cost" >> $final_latcy 164 | 165 | echo "Buffers Heap DSS Shared" >> $final_alloc 166 | echo "1 $heap1 $dss1 $function_cost" >> $final_alloc 167 | echo "2 $heap2 $dss2 $function_cost" >> $final_alloc 168 | echo "3 $heap3 $dss3 $function_cost" >> $final_alloc 169 | 170 | duration=$SECONDS 171 | echo "Runtime: $(($duration / 60)) minutes and $(($duration % 60)) seconds." 172 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/docker-data/start-scripts/kvmflexos-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CPU_ISOLED1=$3 4 | CPU_ISOLED2=$4 5 | 6 | function run { 7 | if [ -z "$CPU_ISOLED1" ] 8 | then 9 | die "Usage:\t$0 run \n\t$0 kill" 10 | fi 11 | 12 | if [ -z "$CPU_ISOLED2" ] 13 | then 14 | die "Usage:\t$0 run \n\t$0 kill" 15 | fi 16 | 17 | taskset -c ${CPU_ISOLED1} /root/qemu-guest -k $1 \ 18 | -m 1024 -a "" -i /root/img.cpio -p ${CPU_ISOLED2} 19 | } 20 | 21 | function killimg { 22 | killall -9 qemu-system-x86 qemu-guest $0 23 | } 24 | 25 | die() { echo "$*" 1>&2 ; exit 1; } 26 | 27 | if [ $# -gt 4 ]; then 28 | die "Usage:\t$0 run \n\t$0 kill" 29 | elif [ $# -eq 0 ]; then 30 | die "Usage:\t$0 run \n\t$0 kill" 31 | else 32 | case "$1" in 33 | run) 34 | run $2 35 | ;; 36 | kill) 37 | killimg 38 | ;; 39 | *) 40 | die "'$1': unsupported argument." 41 | ;; 42 | esac 43 | fi 44 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/docker-data/start-scripts/kvmflexosept2-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CPU_ISOLED1=$3 4 | CPU_ISOLED2=$4 5 | 6 | die() { echo "$*" 1>&2 ; exit 1; } 7 | 8 | # ----- 9 | 10 | # EDIT ME if you run me elsewhere 11 | 12 | QEMU_BIN="/root/qemu-system-ept" 13 | 14 | # ----- 15 | 16 | # you should not need to edit these 17 | 18 | MEM=2G 19 | 20 | run() { 21 | if [ -z "$CPU_ISOLED1" ] 22 | then 23 | die "Usage:\t$0 run \n\t$0 kill" 24 | fi 25 | if [ -z "$CPU_ISOLED2" ] 26 | then 27 | die "Usage:\t$0 run \n\t$0 kill" 28 | fi 29 | 30 | TEMP=$(mktemp -d) 31 | 32 | { 33 | sleep 3 34 | # run compartment 1 35 | taskset -c $CPU_ISOLED1 $QEMU_BIN -enable-kvm -daemonize \ 36 | -device myshmem,file=/data_shared,paddr=0x105000,size=0x2000 \ 37 | -device myshmem,file=/rpc_page,paddr=0x800000000,size=0x100000 \ 38 | -device myshmem,file=/heap,paddr=0x4000000000,size=0x8000000 \ 39 | -initrd /root/img.cpio -display none -cpu host \ 40 | -kernel ${1}.comp1 -m $MEM -L /root/pc-bios 41 | } & 42 | 43 | # run compartment 0 44 | taskset -c $CPU_ISOLED2 $QEMU_BIN -enable-kvm -nographic \ 45 | -device myshmem,file=/data_shared,size=0x2000,paddr=0x105000 \ 46 | -device myshmem,file=/rpc_page,size=0x100000,paddr=0x800000000 \ 47 | -device myshmem,file=/heap,size=0x8000000,paddr=0x4000000000 \ 48 | -initrd /root/img.cpio -cpu host \ 49 | -kernel ${1}.comp0 -m $MEM -L /root/pc-bios 50 | } 51 | 52 | killimg() { 53 | pkill -9 qemu-system-x86 54 | pkill -9 qemu-system-ept 55 | } 56 | 57 | if [ $# -gt 4 ]; then 58 | die "Usage:\t$0 run \n\t$0 kill" 59 | elif [ $# -eq 0 ]; then 60 | die "Usage:\t$0 run \n\t$0 kill" 61 | else 62 | case "$1" in 63 | run) 64 | run $2 65 | ;; 66 | kill) 67 | killimg 68 | ;; 69 | *) 70 | die "'$1': unsupported argument." 71 | ;; 72 | esac 73 | fi 74 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/dss.plot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | 3 | reset 4 | 5 | set terminal svg enhanced size 300,250 font 'Arial,18' 6 | set output '/out/dss.svg' 7 | 8 | set style data histogram 9 | set style histogram cluster gap 1 10 | 11 | # Make axis labels easier to read. 12 | set xtics font ",16" nomirror offset 0,0.25 13 | set ytics nomirror 14 | set logscale y 2 15 | set yrange [1:400] 16 | 17 | set grid 18 | 19 | # offsets reduces the space at the extreme left & right borders 20 | # to minimize white space 21 | set offsets -0.2, -0.2, 0, 0 22 | 23 | # ensure that y label doesn't take too much space 24 | set ylabel "Alloc. Latency (cycles)" offset 2.5,0 25 | set xlabel "# of allocated buffers" offset 0,0.8 26 | set lmargin 7 27 | set rmargin 1 28 | set tmargin 0.5 29 | 30 | set style fill pattern border -1 31 | 32 | unset key 33 | 34 | set label 'Heap' at -0.25,80 rotate by 90 font ",14" 35 | set label 'Shared stack and DSS' at 0.15,2.4 rotate by 90 font ",14" 36 | 37 | plot '/out/results/dss.dat' \ 38 | using 2:xtic(1) ti col lc "black" fs pattern 1, \ 39 | '' using 3 ti col lc "black" fs pattern 2, \ 40 | '' using 4 ti col lc "black" fs pattern 6 41 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/flexos-microbenchmarks.dockerfile: -------------------------------------------------------------------------------- 1 | # You can easily build it with the following command: 2 | # $ docker build --tag flexos-microbenchmarks -f flexos-microbenchmarks.dockerfile . 3 | # 4 | # If the build fails because you are rate-limited by GitHub, generate an app 5 | # token () and run instead: 6 | # $ docker build --build-arg UK_KRAFT_GITHUB_TOKEN="" --tag flexos-microbenchmarks 7 | # 8 | # and run with: 9 | # $ docker run --privileged --security-opt seccomp:unconfined -ti flexos-microbenchmarks bash 10 | # 11 | # (--security-opt seccomp:unconfined to limit docker overhead) 12 | 13 | FROM ghcr.io/project-flexos/flexos-ae-base:latest 14 | 15 | ARG GITHUB_TOKEN= 16 | ENV UK_KRAFT_GITHUB_TOKEN=${GITHUB_TOKEN} 17 | 18 | ############## 19 | # FlexOS (KVM) 20 | 21 | WORKDIR /root/.unikraft/apps 22 | 23 | # build flexos with 2 mpk compartments (microbenchmarks/rest) and private stacks with DSS 24 | RUN kraftcleanup 25 | RUN cd /root/.unikraft/unikraft && git checkout 66f546dc6a2d8e13b47846ee29450f75b3ad388a 26 | COPY docker-data/configs/microbenchmarks-flexos-mpk2.config flexos-microbenchmarks/.config 27 | COPY docker-data/configs/kraft.yaml.mpk2 flexos-microbenchmarks/kraft.yaml 28 | COPY docker-data/start-scripts/kvmflexos-start.sh flexos-microbenchmarks/kvm-start.sh 29 | RUN cd flexos-microbenchmarks && make prepare && kraft -v build --no-progress --fast --compartmentalize 30 | RUN mv flexos-microbenchmarks flexos-microbenchmarks-mpk2-isolstack 31 | 32 | # build flexos with 2 mpk compartments (microbenchmarks/rest) and private stacks without DSS 33 | RUN kraftcleanup 34 | RUN cd /root/.unikraft/unikraft && git checkout 66f546dc6a2d8e13b47846ee29450f75b3ad388a 35 | # generated by kraftcleanup, we don't need it as noisolstack 36 | # is only 3 config options away from the previous build 37 | RUN rm -rf /root/.unikraft/apps/flexos-microbenchmarks 38 | RUN cp -r flexos-microbenchmarks-mpk2-isolstack flexos-microbenchmarks-mpk2-isolstack-heap 39 | WORKDIR /root/.unikraft/apps/flexos-microbenchmarks-mpk2-isolstack-heap 40 | RUN git checkout main.c 41 | RUN sed -i "s/CONFIG_LIBFLEXOS_ENABLE_DSS=y/# CONFIG_LIBFLEXOS_ENABLE_DSS is not set/g" \ 42 | .config 43 | RUN rm -rf build && make prepare && kraft -v build --no-progress --fast --compartmentalize 44 | WORKDIR /root/.unikraft/apps 45 | 46 | # build flexos with 2 mpk compartments (microbenchmarks/rest) and shared stacks 47 | RUN kraftcleanup 48 | RUN cd /root/.unikraft/unikraft && git checkout 66f546dc6a2d8e13b47846ee29450f75b3ad388a 49 | # generated by kraftcleanup, we don't need it as noisolstack 50 | # is only 3 config options away from the previous build 51 | RUN rm -rf /root/.unikraft/apps/flexos-microbenchmarks 52 | RUN cp -r flexos-microbenchmarks-mpk2-isolstack flexos-microbenchmarks-mpk2-noisolstack 53 | WORKDIR /root/.unikraft/apps/flexos-microbenchmarks-mpk2-noisolstack 54 | RUN git checkout main.c 55 | RUN sed -i "s/CONFIG_LIBFLEXOS_GATE_INTELPKU_PRIVATE_STACKS=y/# CONFIG_LIBFLEXOS_GATE_INTELPKU_PRIVATE_STACKS is not set/g" \ 56 | .config 57 | RUN sed -i "s/CONFIG_LIBFLEXOS_ENABLE_DSS=y/# CONFIG_LIBFLEXOS_ENABLE_DSS is not set/g" \ 58 | .config 59 | RUN sed -i "s/# CONFIG_LIBFLEXOS_GATE_INTELPKU_SHARED_STACKS is not set/CONFIG_LIBFLEXOS_GATE_INTELPKU_SHARED_STACKS=y/g" \ 60 | .config 61 | RUN rm -rf build && make prepare && kraft -v build --no-progress --fast --compartmentalize 62 | WORKDIR /root/.unikraft/apps 63 | 64 | # build flexos with 2 ept compartments (microbenchmarks/rest) 65 | RUN kraftcleanup 66 | RUN cd /root/.unikraft/unikraft && \ 67 | git checkout 66f546dc6a2d8e13b47846ee29450f75b3ad388a && \ 68 | git apply /root/ept2-tmpfix.patch 69 | COPY docker-data/configs/microbenchmarks-flexos-ept2.config flexos-microbenchmarks/.config 70 | COPY docker-data/configs/kraft.yaml.ept2 flexos-microbenchmarks/kraft.yaml 71 | COPY docker-data/start-scripts/kvmflexosept2-start.sh flexos-microbenchmarks/kvm-start.sh 72 | # no --no-progress here 73 | RUN cd flexos-microbenchmarks && make prepare && kraft -v build --fast --compartmentalize 74 | RUN mv flexos-microbenchmarks flexos-microbenchmarks-ept2 75 | 76 | RUN mv /root/.unikraft /root/flexos 77 | 78 | ############## 79 | # Finish 80 | 81 | WORKDIR /root 82 | 83 | COPY docker-data/run.sh . 84 | RUN chmod u+x run.sh 85 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/latency.plot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gnuplot 2 | 3 | reset 4 | 5 | set terminal svg enhanced size 300,250 font 'Arial,18' 6 | set output '/out/latency.svg' 7 | 8 | set grid 9 | set style fill pattern border -1 10 | set style data histogram 11 | set xtic right nomirror rotate by 30 font ",16" scale 0 12 | set ytic nomirror 13 | set ylabel "Gate Latency (cycles)" offset 2.5,0 14 | 15 | #set logscale y 2 16 | set lmargin 7 17 | set bmargin 2.5 18 | set rmargin 1 19 | set tmargin 0.5 20 | 21 | set xrange [0:9] 22 | set yrange [0:800] 23 | set boxwidth 0.5 24 | 25 | set label "2" at 0.80,55 font ",16" 26 | set label "62" at 2.60,117 font ",16" 27 | set label "108" at 3.40,161 font ",16" 28 | set label "462" at 4.41,515 font ",16" 29 | set label "470" at 6.40,523 font ",16" 30 | set label "146" at 7.40,199 font ",16" 31 | 32 | set label "all" at 0.60,700 font ",16" 33 | set label "FlexOS" at 2.80,700 font ",16" 34 | set label "Linux" at 6.65,700 font ",16" 35 | 36 | set arrow from 2, graph 0 to 2, graph 1 nohead 37 | set arrow from 6, graph 0 to 6, graph 1 nohead 38 | 39 | plot "/out/results/latency.dat" \ 40 | every 6::0 using 1:3:xtic(2) with boxes fs pattern 1 lc "black" notitle, \ 41 | "" every 6::1 using 1:3:xtic(2) with boxes fs pattern 2 lc "black" notitle, \ 42 | "" every 6::2 using 1:3:xtic(2) with boxes fs pattern 6 lc "black" notitle, \ 43 | "" every 6::3 using 1:3:xtic(2) with boxes fs pattern 1 lc "black" notitle, \ 44 | "" every 6::4 using 1:3:xtic(2) with boxes fs pattern 7 lc "black" notitle, \ 45 | "" every 6::5 using 1:3:xtic(2) with boxes fs pattern 8 lc "black" notitle 46 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/results/dss.dat: -------------------------------------------------------------------------------- 1 | Buffers Heap DSS Shared 2 | 1 66 2 2 3 | 2 140 2 2 4 | 3 218 2 2 5 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/results/latency.dat: -------------------------------------------------------------------------------- 1 | 1 "function" 2 2 | 3 "MPK-light" 62 3 | 4 "MPK-dss" 108 4 | 5 "EPT" 462 5 | 7 "syscall" 470 6 | 8 "-nokpti" 146 7 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/toggle-kpti.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Authors: Hugo Lefeuvre 4 | 5 | GRUB_FILE="/etc/default/grub" 6 | 7 | set -e 8 | 9 | die() { echo "$*" 1>&2 ; exit 1; } 10 | 11 | function disclaimer { 12 | echo "[I] Disclaimer:" 13 | echo "[I] This script is experimental. It is known to work on the official" 14 | echo "[I] AE setup for the FlexOS paper, but might not be entirely generic." 15 | echo "[I] Use at your own risk!" 16 | echo "" 17 | } 18 | 19 | function checks { 20 | disclaimer 21 | users=$(who | wc -l) 22 | if [ $users -gt 1 ]; then 23 | die "[E] Cannot toggle KPTI: there are $users logged in; please coordinate on machine use." 24 | fi 25 | 26 | if ! test -f "$GRUB_FILE"; then 27 | die "[E] This machine does not seem to use GRUB, but this script only supports GRUB." 28 | fi 29 | } 30 | 31 | function prompt { 32 | while true; do 33 | read -p "${1}Proceed? [y/n] " yn 34 | case $yn in 35 | [Yy]* ) break;; 36 | [Nn]* ) exit 1;; 37 | * ) echo "Please answer yes or no.";; 38 | esac 39 | done 40 | } 41 | 42 | function off { 43 | checks 44 | 45 | if grep -q "pti=off" $GRUB_FILE; then 46 | die "[E] KPTI is already disabled." 47 | fi 48 | 49 | if grep -q "nopti" $GRUB_FILE; then 50 | die "[E] KPTI is already disabled." 51 | fi 52 | 53 | prompt "This script is going disable KPTI on this machine, which requires a reboot. " 54 | 55 | echo -n "[I] Command line before changes: " 56 | echo $(cat $GRUB_FILE | grep "GRUB_CMDLINE_LINUX=" | sed "s/.*GRUB_CMDLINE_LINUX=//g") 57 | 58 | cp $GRUB_FILE /tmp/.tmp_grub 59 | 60 | echo -n "[I] Editing kernel command line..." 61 | sed -i "s/GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"pti=off /g" /tmp/.tmp_grub 62 | 63 | if grep -q "pti=off" /tmp/.tmp_grub; then 64 | echo " done." 65 | else 66 | echo "" 67 | die "[E] Failed to edit kernel command line." 68 | fi 69 | 70 | echo -n "[I] Command line after changes: " 71 | echo $(cat /tmp/.tmp_grub | grep "GRUB_CMDLINE_LINUX=" | sed "s/.*GRUB_CMDLINE_LINUX=//g") 72 | 73 | prompt "" 74 | 75 | cp /tmp/.tmp_grub $GRUB_FILE 76 | 77 | echo "[I] Reconfiguring GRUB..." 78 | update-grub 79 | 80 | echo "[W] Rebooting in 3s..." 81 | sleep 3 82 | reboot 83 | } 84 | 85 | function on { 86 | checks 87 | 88 | if grep -q "pti=on" $GRUB_FILE; then 89 | die "[E] KPTI is already enabled." 90 | fi 91 | 92 | if ! grep -q "nopti" $GRUB_FILE; then 93 | if ! grep -q "pti=off" $GRUB_FILE; then 94 | die "[E] KPTI is already enabled." 95 | fi 96 | fi 97 | 98 | prompt "This script is going enable KPTI on this machine, which requires a reboot. " 99 | 100 | echo -n "[I] Command line before changes: " 101 | echo $(cat $GRUB_FILE | grep "GRUB_CMDLINE_LINUX=" | sed "s/.*GRUB_CMDLINE_LINUX=//g") 102 | 103 | cp $GRUB_FILE /tmp/.tmp_grub 104 | 105 | echo "[I] Editing kernel command line..." 106 | sed -i "s/pti=off//g" /tmp/.tmp_grub 107 | sed -i "s/nopti//g" /tmp/.tmp_grub 108 | 109 | echo -n "[I] Command line after changes: " 110 | echo $(cat /tmp/.tmp_grub | grep "GRUB_CMDLINE_LINUX=" | sed "s/.*GRUB_CMDLINE_LINUX=//g") 111 | 112 | prompt "" 113 | 114 | cp /tmp/.tmp_grub $GRUB_FILE 115 | 116 | echo "[I] Reconfiguring GRUB..." 117 | update-grub 118 | 119 | echo "[W] Rebooting in 3s..." 120 | sleep 3 121 | reboot 122 | } 123 | 124 | case "$1" in 125 | on) 126 | on 127 | ;; 128 | off) 129 | off 130 | ;; 131 | *) 132 | die "'$1': unsupported argument. Usage: $0 {on, off}" 133 | ;; 134 | esac 135 | -------------------------------------------------------------------------------- /experiments/fig-11_flexos-alloc-latency/tools/benchmark_linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Authors: Hugo Lefeuvre 4 | 5 | GRUB_FILE="/etc/default/grub" 6 | 7 | set -e 8 | 9 | RESULTS=$1 10 | LINUXEXP=$2 11 | CPU=$3 12 | 13 | function merge { 14 | if test -f "${RESULTS}/latency-linux-nokpti.dat"; then 15 | if test -f "${RESULTS}/latency-linux.dat"; then 16 | if test -f "${RESULTS}/latency-flexos.dat"; then 17 | # all benchmarks completed, merge 18 | cat ${RESULTS}/latency-flexos.dat > ${RESULTS}/latency.dat 19 | cat ${RESULTS}/latency-linux.dat >> ${RESULTS}/latency.dat 20 | cat ${RESULTS}/latency-linux-nokpti.dat >> ${RESULTS}/latency.dat 21 | fi 22 | fi 23 | fi 24 | } 25 | 26 | if ! grep -q "nopti" $GRUB_FILE; then 27 | if ! grep -q "pti=off" $GRUB_FILE; then 28 | # KPTI is enabled 29 | taskset -c ${3} ${2}/benchmark > .out 30 | scall=`cat .out | tr -dc '[:alnum:]\n\r .,-' | sed "s/.*scall,/scall,/g" \ 31 | | grep "^scall," | sed "s/scall,//g" | tr -dc '[:alnum:]'` 32 | echo "7 \"syscall\" $scall" > ${1}/latency-linux.dat 33 | rm .out 34 | merge 35 | exit 0 36 | fi 37 | fi 38 | 39 | # KPTI is disabled 40 | taskset -c ${3} ${2}/benchmark > .out 41 | scall=`cat .out | tr -dc '[:alnum:]\n\r .,-' | sed "s/.*scall,/scall,/g" \ 42 | | grep "^scall," | sed "s/scall,//g" | tr -dc '[:alnum:]'` 43 | echo "8 \"-nokpti\" $scall" > ${1}/latency-linux-nokpti.dat 44 | rm .out 45 | merge 46 | -------------------------------------------------------------------------------- /experiments/tab-01_porting-effort/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Files and directories 3 | # 4 | WORKDIR ?= $(CURDIR) 5 | RESULTS ?= $(WORKDIR) 6 | PLOT_FORMAT ?= svg 7 | PLOT ?= $(WORKDIR)/$(notdir $(WORKDIR)).$(PLOT_FORMAT) 8 | 9 | # 10 | # Parameters 11 | # 12 | KRAFT_TOKEN ?= 13 | 14 | # 15 | # Tools 16 | # 17 | DOCKER ?= docker 18 | TIME ?= /usr/bin/time 19 | 20 | # 21 | # Targets 22 | # 23 | .PHONY: all 24 | all: prepare run plot 25 | 26 | .PHONY: prepare 27 | prepare: 28 | $(TIME) $(DOCKER) build -f $(WORKDIR)/flexos-porting.dockerfile \ 29 | --build-arg GITHUB_TOKEN="$(KRAFT_TOKEN)" \ 30 | --tag flexos-porting $(WORKDIR) 31 | 32 | .PHONY: run 33 | run: 34 | $(DOCKER) run --rm -v $(WORKDIR):/out --privileged \ 35 | --security-opt seccomp:unconfined -ti flexos-porting bash 36 | 37 | .PHONY: plot 38 | plot: 39 | @- 40 | 41 | .PHONY: clean 42 | clean: 43 | @- 44 | 45 | .PHONY: properclean 46 | properclean: 47 | $(DOCKER) image rm -f flexos-porting 48 | $(DOCKER) image prune -f 49 | -------------------------------------------------------------------------------- /experiments/tab-01_porting-effort/README.md: -------------------------------------------------------------------------------- 1 | # Porting Effort 2 | 3 | | Estimated prep. time | Estimated runtime | 4 | | -------------------- | ----------------- | 5 | | 0h 2m | 0h 25m (manual) | 6 | 7 | | Libs/Apps | Patch size | Shared variables | 8 | | --------------------- | ---------- | ---------------- | 9 | | lwip | +542/-275 | 23 | 10 | | uksched + ukschedcoop | +48/-8 | 5 | 11 | | ramfs + vfscore | +148/-37 | 12 | 12 | | uktime | +10/-9 | 0 | 13 | | redis | +279/-90 | 16 | 14 | | nginx | +470/-85 | 36 | 15 | | sqlite | +199/-145 | 24 | 16 | | iperf | +15/-14 | 4 | 17 | 18 | ## Overview 19 | 20 | Porting effort: size of the patch (including automatic gate replacements), 21 | number of shared variables. 22 | 23 | ### Measurement workflow 24 | 25 | These measurements are manual, but rather simple. For each repository or 26 | subsystem, perform a `git diff` with the last Unikraft commit, and count the 27 | meaningful +/- lines. For the shared variables, grep for `whitelist` and count 28 | occurences. 29 | 30 | Note that some libraries (mm, lwip, vfscore) include patches that are 31 | not part of FlexOS but not yet merged into the Unikraft master at the time when 32 | FlexOS was forked from Unikraft. We do not want to count these in the diff. 33 | 34 | Here is a list of external, non-FlexOS patches applied: 35 | - lwip: move `socket.c` to the glue code **[[link]](https://github.com/project-flexos/asplos22-ae/tree/main/experiments/tab-01_porting-effort/lwip-patches)** 36 | - vfscore: CPIO support **[[link]](https://github.com/unikraft/eurosys21-artifacts/tree/master/support/patches-unikraft-eurosys21/cpio-series)** 37 | - mm: page table support **[[link]](https://github.com/project-flexos/asplos22-ae/blob/main/experiments/fig-09_iperf-throughput/docker-data/unikraft-pagetable.patch)** 38 | 39 | Note that the iperf app was developed for this paper; you can use the 40 | [`unikraft-baseline`](https://github.com/project-flexos/lib-iperf/tree/unikraft-baseline) 41 | branch as baseline for both the 42 | [application](https://github.com/project-flexos/app-iperf) and the 43 | [library](https://github.com/project-flexos/lib-iperf). 44 | 45 | A similar situation affects sqlite; you can use [this unmodified 46 | application](https://github.com/project-flexos/asplos22-ae/blob/main/experiments/fig-10_sqlite-exec-time/docker-data/main.c) 47 | as baseline. 48 | 49 | In order to simply the operation, we provide a simple docker container that 50 | clones all relevant repositories into `/root/flexos`. You can build it with 51 | `make prepare` and bash it with `make run`. The current directory is mounted in 52 | `/out` in order to ease the sharing of results with the host. 53 | -------------------------------------------------------------------------------- /experiments/tab-01_porting-effort/flexos-porting.dockerfile: -------------------------------------------------------------------------------- 1 | # You can easily build it with the following command: 2 | # $ docker build --tag flexos-iperf -f flexos-iperf.dockerfile . 3 | # 4 | # If the build fails because you are rate-limited by GitHub, generate an app 5 | # token () and run instead: 6 | # $ docker build --build-arg UK_KRAFT_GITHUB_TOKEN="" --tag flexos-iperf 7 | # 8 | # and run with: 9 | # $ docker run --privileged --security-opt seccomp:unconfined -ti flexos-iperf bash 10 | # 11 | # (--security-opt seccomp:unconfined to limit docker overhead) 12 | 13 | FROM ghcr.io/project-flexos/flexos-ae-base:latest 14 | 15 | ARG GITHUB_TOKEN= 16 | ENV UK_KRAFT_GITHUB_TOKEN=${GITHUB_TOKEN} 17 | 18 | WORKDIR /root/.unikraft/apps 19 | RUN kraftcleanup 20 | 21 | RUN mv /root/.unikraft /root/flexos 22 | 23 | ############## 24 | # Finish 25 | 26 | WORKDIR /root 27 | -------------------------------------------------------------------------------- /support/0001-Myshmem.patch: -------------------------------------------------------------------------------- 1 | From 3d52c49ba35dc9c673b8cf43b8623a6874a1ff43 Mon Sep 17 00:00:00 2001 2 | From: Stefan Teodorescu 3 | Date: Wed, 3 Mar 2021 09:48:43 +0200 4 | Subject: [PATCH] Myshmem 5 | 6 | --- 7 | hw/misc/meson.build | 1 + 8 | hw/misc/myshmem.c | 88 +++++++++++++++++++++++++++++++++++++++++++++ 9 | softmmu/runstate.c | 1 + 10 | softmmu/vl.c | 1 + 11 | 4 files changed, 91 insertions(+) 12 | create mode 100644 hw/misc/myshmem.c 13 | 14 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build 15 | index 6292839..34dcaa1 100644 16 | --- a/hw/misc/meson.build 17 | +++ b/hw/misc/meson.build 18 | @@ -39,6 +39,7 @@ softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_pm.c')) 19 | subdir('macio') 20 | 21 | softmmu_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c')) 22 | +softmmu_ss.add(files('myshmem.c')) 23 | 24 | softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c')) 25 | specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c')) 26 | diff --git a/hw/misc/myshmem.c b/hw/misc/myshmem.c 27 | new file mode 100644 28 | index 0000000..b990205 29 | --- /dev/null 30 | +++ b/hw/misc/myshmem.c 31 | @@ -0,0 +1,88 @@ 32 | +#include "qemu/osdep.h" 33 | +#include "qemu/units.h" 34 | +#include "qapi/error.h" 35 | +#include "qemu/cutils.h" 36 | +#include "hw/qdev-properties.h" 37 | +#include "hw/qdev-properties-system.h" 38 | +#include "sysemu/kvm.h" 39 | +#include "migration/blocker.h" 40 | +#include "migration/vmstate.h" 41 | +#include "qemu/error-report.h" 42 | +#include "qemu/event_notifier.h" 43 | +#include "qemu/module.h" 44 | +#include "qom/object_interfaces.h" 45 | +#include "chardev/char-fe.h" 46 | +#include "sysemu/hostmem.h" 47 | +#include "sysemu/qtest.h" 48 | +#include "qapi/visitor.h" 49 | +#include "exec/address-spaces.h" 50 | + 51 | +#include 52 | +#include /* For mode constants */ 53 | +#include /* For O_* constants */ 54 | + 55 | +#include "qom/object.h" 56 | + 57 | +#define TYPE_MY_SHMEM "myshmem" 58 | + 59 | +struct MyShmem { 60 | + DeviceState parent_obj; 61 | + 62 | + char *file; 63 | + uint64_t size; 64 | + uint64_t paddr; 65 | + MemoryRegion region; 66 | +}; 67 | + 68 | +struct MyShmemClass { 69 | + 70 | +}; 71 | + 72 | +typedef struct MyShmem MyShmem; 73 | +typedef struct MyShmemClass MyShmemClass; 74 | + 75 | +OBJECT_DEFINE_TYPE(MyShmem, 76 | + my_shmem, 77 | + MY_SHMEM, 78 | + DEVICE); 79 | + 80 | +static Property myshmem_properties[] = { 81 | + DEFINE_PROP_STRING("file", MyShmem, file), 82 | + DEFINE_PROP_UINT64("size", MyShmem, size, 0), 83 | + DEFINE_PROP_UINT64("paddr", MyShmem, paddr, 0), 84 | + DEFINE_PROP_END_OF_LIST(), 85 | +}; 86 | + 87 | +static void my_shmem_realize(DeviceState *dev, Error **errp) 88 | +{ 89 | + unsigned long shm_size; 90 | + int shm_fd; 91 | + void *shared_memory; 92 | + 93 | + MyShmem *myshmem = (MyShmem *) dev; 94 | + shm_size = myshmem->size; 95 | + shm_fd = shm_open(myshmem->file, O_CREAT | O_RDWR, 0666); 96 | + if (ftruncate(shm_fd, shm_size)) 97 | + printf("ftruncate failed\n"); 98 | + shared_memory = mmap(NULL, shm_size, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); 99 | + 100 | + memory_region_init_ram_ptr(&myshmem->region, NULL, "vram", shm_size, shared_memory); 101 | + memory_region_add_subregion(get_system_memory(), myshmem->paddr, &myshmem->region); 102 | +} 103 | + 104 | +static void my_shmem_class_init(ObjectClass *oc, void *data) 105 | +{ 106 | + DeviceClass *dc = DEVICE_CLASS(oc); 107 | + 108 | + device_class_set_props(dc, myshmem_properties); 109 | + dc->realize = my_shmem_realize; 110 | +} 111 | + 112 | +static void my_shmem_init(Object *obj) 113 | +{ 114 | +} 115 | + 116 | +static void my_shmem_finalize(Object *obj) 117 | +{ 118 | + printf("my shmem finalize called\n"); 119 | +} 120 | diff --git a/softmmu/runstate.c b/softmmu/runstate.c 121 | index 2874417..3ab41a0 100644 122 | --- a/softmmu/runstate.c 123 | +++ b/softmmu/runstate.c 124 | @@ -713,6 +713,7 @@ static bool main_loop_should_exit(void) 125 | return false; 126 | } 127 | 128 | +extern void *shared_memory; 129 | void qemu_main_loop(void) 130 | { 131 | #ifdef CONFIG_PROFILER 132 | diff --git a/softmmu/vl.c b/softmmu/vl.c 133 | index b219ce1..862aa9c 100644 134 | --- a/softmmu/vl.c 135 | +++ b/softmmu/vl.c 136 | @@ -3448,6 +3448,7 @@ void qemu_init(int argc, char **argv, char **envp) 137 | case QEMU_OPTION_nouserconfig: 138 | /* Nothing to be parsed here. Especially, do not error out below. */ 139 | break; 140 | + 141 | default: 142 | if (os_parse_cmd_args(popt->index, optarg)) { 143 | error_report("Option not supported in this build"); 144 | -- 145 | 2.30.2 146 | 147 | -------------------------------------------------------------------------------- /support/dockerfiles/Dockerfile.flexos-ae-base: -------------------------------------------------------------------------------- 1 | FROM debian:10 2 | 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | 5 | ARG UK_KRAFT_GITHUB_TOKEN= 6 | ENV UK_KRAFT_GITHUB_TOKEN=${UK_KRAFT_GITHUB_TOKEN} 7 | 8 | RUN echo "deb-src http://deb.debian.org/debian buster main contrib non-free" \ 9 | >> /etc/apt/sources.list 10 | RUN echo "deb-src http://security.debian.org/ buster/updates main contrib non-free" \ 11 | >> /etc/apt/sources.list 12 | RUN echo "deb-src http://deb.debian.org/debian/ buster-updates main contrib non-free" \ 13 | >> /etc/apt/sources.list 14 | 15 | RUN apt update 16 | RUN apt build-dep -y coccinelle 17 | RUN apt build-dep -y qemu-system-x86 18 | RUN apt install -y build-essential libncurses-dev python3 expect-dev moreutils \ 19 | flex unzip bison wget libxml2-utils tclsh python python-tempita python-six \ 20 | python-future python-ply xorriso qemu-system-x86 qemu qemu-kvm vim qemu-system \ 21 | qemu-utils curl gawk git procps socat uuid-runtime python3-pip libsqlite3-dev \ 22 | bc libiscsi-dev librbd1 libnfs-dev libgfapi0 libffi-dev libiperf-dev net-tools \ 23 | bridge-utils iperf dnsmasq ninja-build redis-tools 24 | 25 | ############## 26 | # Tools 27 | 28 | WORKDIR /root 29 | 30 | RUN wget https://raw.githubusercontent.com/unikraft/kraft/6217d48668cbdf0847c7864bc6368a6adb94f6a6/scripts/qemu-guest 31 | RUN chmod a+x /root/qemu-guest 32 | 33 | COPY kraftcleanup /usr/local/bin/kraftcleanup 34 | COPY kraftrc.default /root/.kraftrc 35 | 36 | RUN git clone https://github.com/project-flexos/kraft.git 37 | RUN cd /root/kraft && git checkout bce1d4c59872ccc88b04041d65b1fc0725cc5d88 && pip3 install -e . 38 | 39 | RUN git clone https://github.com/coccinelle/coccinelle 40 | RUN cd coccinelle && git checkout ae337fce1512ff15aabc3ad5b6d2e537f97ab62a && \ 41 | ./autogen && ./configure && make && make install 42 | 43 | # fix a bug in Coccinelle 44 | RUN mkdir /usr/local/bin/lib 45 | RUN ln -s /usr/local/lib/coccinelle /usr/local/bin/lib/coccinelle 46 | 47 | ############## 48 | # FlexOS EPT QEMU 49 | 50 | RUN git clone https://github.com/qemu/qemu.git 51 | 52 | WORKDIR /root/qemu 53 | 54 | RUN apt install -y ninja-build 55 | RUN git checkout 9ad4c7c9b63f89c308fd988d509bed1389953c8b 56 | COPY 0001-Myshmem.patch /root/0001-Myshmem.patch 57 | RUN git apply /root/0001-Myshmem.patch 58 | RUN ./configure --target-list=x86_64-softmmu 59 | RUN sed -i -e 's/-lstdc++ -Wl,--end-group/-lrt -lstdc++ -Wl,--end-group/g' build/build.ninja 60 | RUN make -j8 61 | RUN cp build/qemu-system-x86_64 /root/qemu-system-ept 62 | RUN cp -r build/pc-bios /root/pc-bios 63 | RUN rm /root/0001-Myshmem.patch 64 | 65 | # The version of EPT used in this artifact is not up-to-date with our 66 | # latest developments. Unfortunately, we weren't able to integrate the 67 | # latest version of the backend in the artifact. In order to obtain the 68 | # same performance behavior, this hack patch mimics the behavior of the 69 | # new backend. It is used by a number of figures. 70 | COPY ept2-tmpfix.patch /root/ 71 | 72 | ############## 73 | # Unikraft 0.5 (KVM and linuxu) 74 | # Performance is similar to Unikraft 0.4, so omit it. 75 | 76 | RUN mkdir /root/unikraft-mainline 77 | 78 | WORKDIR /root/unikraft-mainline 79 | 80 | RUN git clone https://github.com/unikraft/unikraft.git 81 | RUN cd /root/unikraft-mainline/unikraft && \ 82 | git checkout fd5779120a5938d5c814583cb0f59046b1756cd3 83 | 84 | RUN mkdir libs apps 85 | 86 | COPY img.cpio /root/ 87 | 88 | WORKDIR /root 89 | -------------------------------------------------------------------------------- /support/dockerfiles/Dockerfile.flexos-ae-plot: -------------------------------------------------------------------------------- 1 | FROM debian:11 2 | 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | 5 | # This is a very simple image, but it allows us to ensure that the version 6 | # of gnuplot that people use to execute our plot scripts matches the one we 7 | # use, which, in practice, is not an obvious thing. Using a version that's 8 | # too old might result in broken plots, and possibly the same the other way 9 | # around 10 | 11 | RUN set -xe; \ 12 | apt update; \ 13 | apt install -y --no-install-recommends \ 14 | make \ 15 | gnuplot \ 16 | python3 \ 17 | python3-tk \ 18 | python3-pip \ 19 | texlive-latex-base \ 20 | texlive-latex-extra \ 21 | texlive-fonts-recommended; \ 22 | pip3 install \ 23 | numpy \ 24 | matplotlib \ 25 | -------------------------------------------------------------------------------- /support/dockerfiles/Dockerfile.flexos-base: -------------------------------------------------------------------------------- 1 | FROM unikraft/kraft:staging 2 | 3 | # 4 | # Install coccinelle 5 | # 6 | RUN set -xe; \ 7 | apt-get update; \ 8 | apt-get install -y \ 9 | wget \ 10 | bzip2 \ 11 | automake \ 12 | pkg-config \ 13 | ocaml-native-compilers \ 14 | ocaml-findlib \ 15 | menhir \ 16 | libmenhir-ocaml-dev \ 17 | libpcre-ocaml-dev \ 18 | libparmap-ocaml-dev; \ 19 | git clone --branch master https://github.com/coccinelle/coccinelle.git \ 20 | /usr/src/coccinelle; \ 21 | cd /usr/src/coccinelle; \ 22 | git checkout 99ec612852a88fae85dfad863daafccf55b874ce; \ 23 | ./autogen; \ 24 | ./configure; \ 25 | make; \ 26 | make install; \ 27 | mkdir /usr/local/bin/lib; \ 28 | ln -s /usr/local/lib/coccinelle /usr/local/bin/lib/coccinelle; 29 | 30 | # 31 | # Install YTT 32 | # 33 | ARG YTT_VERSION=0.32.0 34 | RUN set -xe; \ 35 | wget -O /usr/local/bin/ytt https://github.com/vmware-tanzu/carvel-ytt/releases/download/v${YTT_VERSION}/ytt-linux-amd64; \ 36 | chmod +x /usr/local/bin/ytt; 37 | 38 | # 39 | # Replace kraft with kraft-flexos 40 | # 41 | RUN set -xe; \ 42 | rm -Rf /usr/src/kraft; \ 43 | git clone --branch staging https://github.com/project-flexos/kraft.git /usr/src/kraft; \ 44 | pip3 install /usr/src/kraft 45 | -------------------------------------------------------------------------------- /support/dockerfiles/Dockerfile.nginx: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/project-flexos/flexos-base:latest 2 | 3 | # 4 | # Cache kraft build 5 | # 6 | ARG UK_KRAFT_GITHUB_TOKEN= 7 | ENV UK_KRAFT_GITHUB_TOKEN=${UK_KRAFT_GITHUB_TOKEN} 8 | COPY kraftrc.nginx /usr/src/unikraft/.kraftrc 9 | RUN set -xe; \ 10 | kraft list update; \ 11 | kraft -v list pull unikraft@staging; \ 12 | kraft -v list pull lib/newlib@staging; \ 13 | kraft -v list pull lib/pthread-embedded@staging; \ 14 | kraft -v list pull lib/lwip@staging; \ 15 | kraft -v list pull lib/nginx@staging; \ 16 | kraft -v list pull app/nginx@staging; \ 17 | cd /usr/src/unikraft/apps/nginx; \ 18 | kraft configure; \ 19 | kraft fetch; \ 20 | unset UK_KRAFT_GITHUB_TOKEN 21 | 22 | WORKDIR /usr/src/unikraft/apps/nginx 23 | -------------------------------------------------------------------------------- /support/dockerfiles/Dockerfile.redis: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/project-flexos/flexos-base:latest 2 | 3 | # 4 | # Cache kraft build 5 | # 6 | ARG UK_KRAFT_GITHUB_TOKEN= 7 | ENV UK_KRAFT_GITHUB_TOKEN=${UK_KRAFT_GITHUB_TOKEN} 8 | COPY kraftrc.redis /usr/src/unikraft/.kraftrc 9 | RUN set -xe; \ 10 | kraft list update; \ 11 | kraft -v list pull unikraft@staging; \ 12 | kraft -v list pull lib/newlib@staging; \ 13 | kraft -v list pull lib/pthread-embedded@staging; \ 14 | kraft -v list pull lib/lwip@staging; \ 15 | kraft -v list pull lib/redis@staging; \ 16 | kraft -v list pull app/redis@staging; \ 17 | cd /usr/src/unikraft/apps/redis; \ 18 | kraft configure; \ 19 | kraft fetch; \ 20 | unset UK_KRAFT_GITHUB_TOKEN 21 | 22 | WORKDIR /usr/src/unikraft/apps/redis 23 | -------------------------------------------------------------------------------- /support/ept2-tmpfix.patch: -------------------------------------------------------------------------------- 1 | diff --git a/lib/flexos-core/vmept.c b/lib/flexos-core/vmept.c 2 | index 7df5b89..eb84344 100644 3 | --- a/lib/flexos-core/vmept.c 4 | +++ b/lib/flexos-core/vmept.c 5 | @@ -200,8 +200,6 @@ void flexos_vmept_wait_for_rpc(volatile struct flexos_vmept_rpc_ctrl *ctrl) 6 | // return from rpc call 7 | FLEXOS_VMEPT_DEBUG_PRINT(("Comp %d finished call.\n", flexos_vmept_comp_id)); 8 | return; 9 | - } else { 10 | - uk_sched_yield(); 11 | } 12 | } 13 | } 14 | @@ -216,6 +214,7 @@ void flexos_vmept_rpc_loop() 15 | uk_sched_yield(); 16 | } 17 | 18 | + if (flexos_vmept_comp_id == 0) return; 19 | FLEXOS_VMEPT_DEBUG_PRINT(("Starting RPC server, observing ctrl %p\n", ctrl)); 20 | 21 | uint64_t ext_state; 22 | @@ -254,6 +253,7 @@ void flexos_vmept_master_rpc_loop() 23 | volatile struct flexos_vmept_master_rpc_ctrl *ctrl = flexos_vmept_master_rpc_ctrl(flexos_vmept_comp_id); 24 | flexos_vmept_init_master_rpc_ctrl(ctrl); 25 | 26 | + if (flexos_vmept_comp_id == 0) return; 27 | FLEXOS_VMEPT_DEBUG_PRINT(("Starting master rpc loop. Observing master_rpc_ctrl at %p\n", ctrl)); 28 | while (1) { 29 | if (ctrl->state == FLEXOS_VMEPT_MASTER_RPC_STATE_CALLED && ctrl->to == flexos_vmept_comp_id) { 30 | @@ -273,7 +273,7 @@ void flexos_vmept_master_rpc_loop() 31 | ctrl->state = FLEXOS_VMEPT_MASTER_RPC_STATE_RETURNED; 32 | FLEXOS_VMEPT_DEBUG_PRINT(("Created thread with tid %d (ptr: %p) to handle RPC calls from thread with tid %d in compartment %d.\n", thread->tid, thread, tid, calling_comp)); 33 | FLEXOS_VMEPT_DEBUG_PRINT(("Mapping is set up to track (comp=%d, local_tid=%d) -> %p.\n", calling_comp, tid, flexos_vmept_thread_map_lookup(&thread_map, calling_comp, tid))); 34 | - break; 35 | + return; 36 | case FLEXOS_VMEPT_MASTER_RPC_ACTION_DESTROY: 37 | FLEXOS_VMEPT_DEBUG_PRINT(("Handling destroy.\n")); 38 | thread = flexos_vmept_thread_map_lookup(&thread_map, calling_comp, (uint8_t) tid); 39 | diff --git a/lib/ukboot/weak_main.c b/lib/ukboot/weak_main.c 40 | index c6d2a05..e47d243 100644 41 | --- a/lib/ukboot/weak_main.c 42 | +++ b/lib/ukboot/weak_main.c 43 | @@ -7,6 +7,7 @@ 44 | int __weak main(int argc __unused, char *argv[] __unused) 45 | { 46 | printf("weak main() called. This won't exit. TODO: don't waste this thread.\n"); 47 | + uk_sched_thread_remove(uk_sched_get_default(), uk_thread_current()); 48 | while (1) { 49 | uk_sched_yield(); 50 | } 51 | diff --git a/lib/uksched/sched.c b/lib/uksched/sched.c 52 | index 3e415f3..a6fdaab 100644 53 | --- a/lib/uksched/sched.c 54 | +++ b/lib/uksched/sched.c 55 | @@ -356,18 +356,20 @@ struct uk_thread *uk_sched_thread_create(struct uk_sched *sched, 56 | goto err; 57 | 58 | #if CONFIG_LIBFLEXOS_VMEPT 59 | - /* here we need to create an rpc thread in each other compartment */ 60 | - // TODO: error handling 61 | - printf("Spawning rpc threads in other compartments.\n"); 62 | - volatile struct flexos_vmept_rpc_ctrl * ctrl = flexos_vmept_rpc_ctrl(flexos_vmept_comp_id, thread->tid); 63 | - flexos_vmept_init_rpc_ctrl(ctrl); 64 | - thread->ctrl = ctrl; 65 | - for (size_t i = 0; i < FLEXOS_VMEPT_COMP_COUNT; ++i) { 66 | - if (i == flexos_vmept_comp_id) 67 | - continue; 68 | - flexos_vmept_master_rpc_call_create(flexos_vmept_comp_id, i, thread->tid); 69 | + if(flexos_vmept_comp_id == 1) { 70 | + /* here we need to create an rpc thread in each other compartment */ 71 | + // TODO: error handling 72 | + printf("Spawning rpc threads in other compartments.\n"); 73 | + volatile struct flexos_vmept_rpc_ctrl * ctrl = flexos_vmept_rpc_ctrl(flexos_vmept_comp_id, thread->tid); 74 | + flexos_vmept_init_rpc_ctrl(ctrl); 75 | + thread->ctrl = ctrl; 76 | + for (size_t i = 0; i < FLEXOS_VMEPT_COMP_COUNT; ++i) { 77 | + if (i == flexos_vmept_comp_id) 78 | + continue; 79 | + flexos_vmept_master_rpc_call_create(flexos_vmept_comp_id, i, thread->tid); 80 | + } 81 | + printf("Spawned rpc threads in other compartments.\n"); 82 | } 83 | - printf("Spawned rpc threads in other compartments.\n"); 84 | #endif /* CONFIG_LIBFLEXOS_VMEPT */ 85 | 86 | rc = uk_sched_thread_add(sched, thread, attr); 87 | -------------------------------------------------------------------------------- /support/kraftcleanup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | make properclean 4 | # git checkout . && git clean -xdf in all repositories would be fine too 5 | rm -rf ~/.kraftcache ~/.unikraft/libs ~/.unikraft/unikraft 6 | kraft list update 7 | kraft list pull newlib@staging tlsf@staging lwip@staging \ 8 | unikraft@staging pthread-embedded@staging iperf@staging sqlite@staging \ 9 | flexos-microbenchmarks@staging 10 | -------------------------------------------------------------------------------- /support/kraftrc.default: -------------------------------------------------------------------------------- 1 | [fetch] 2 | prioritise_origin = true 3 | mirrors = [ 4 | "https://releases.unikraft.org/mirrors", 5 | ] 6 | 7 | [configure] 8 | platform = "kvm" 9 | architecture = "x86_64" 10 | 11 | [list] 12 | origins = [ 13 | "https://github.com/project-flexos/lib-newlib.git", 14 | "https://github.com/project-flexos/lib-tlsf.git", 15 | "https://github.com/project-flexos/lib-lwip.git", 16 | "https://github.com/project-flexos/lib-iperf.git", 17 | "https://github.com/project-flexos/app-iperf.git", 18 | "https://github.com/project-flexos/lib-sqlite.git", 19 | "https://github.com/project-flexos/app-sqlite.git", 20 | "https://github.com/project-flexos/app-flexos-microbenchmarks.git", 21 | "https://github.com/project-flexos/lib-flexos-microbenchmarks.git", 22 | "https://github.com/project-flexos/unikraft.git", 23 | "https://github.com/project-flexos/lib-pthread-embedded.git" 24 | ] 25 | -------------------------------------------------------------------------------- /support/kraftrc.nginx: -------------------------------------------------------------------------------- 1 | [fetch] 2 | prioritize_origin = true 3 | 4 | [configure] 5 | platform = "kvm" 6 | architecture = "x86_64" 7 | 8 | [list] 9 | origins = [ 10 | "https://github.com/project-flexos/unikraft.git", 11 | "https://github.com/project-flexos/app-nginx.git", 12 | "https://github.com/project-flexos/lib-newlib.git", 13 | "https://github.com/project-flexos/lib-lwip.git", 14 | "https://github.com/project-flexos/lib-nginx.git", 15 | "https://github.com/project-flexos/lib-pthread-embedded.git", 16 | "https://github.com/project-flexos/lib-tlsf.git", 17 | ] 18 | -------------------------------------------------------------------------------- /support/kraftrc.redis: -------------------------------------------------------------------------------- 1 | [fetch] 2 | prioritize_origin = true 3 | 4 | [configure] 5 | platform = "kvm" 6 | architecture = "x86_64" 7 | 8 | [list] 9 | origins = [ 10 | "https://github.com/project-flexos/unikraft.git", 11 | "https://github.com/project-flexos/app-redis.git", 12 | "https://github.com/project-flexos/lib-newlib.git", 13 | "https://github.com/project-flexos/lib-lwip.git", 14 | "https://github.com/project-flexos/lib-redis.git", 15 | "https://github.com/project-flexos/lib-pthread-embedded.git", 16 | "https://github.com/project-flexos/lib-tlsf.git", 17 | ] 18 | --------------------------------------------------------------------------------