-
Notifications
You must be signed in to change notification settings - Fork 137
[WIP]filesystem benchmark #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright The containerd Authors. | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM alpine:3.9 AS stage-build | ||
|
||
WORKDIR /work | ||
RUN apk add git build-base linux-headers && \ | ||
git clone git://git.kernel.dk/fio.git /work/fio && \ | ||
cd /work/fio && \ | ||
git checkout c96b385b6e0c78478697713e6da9174fba2432d3 && \ | ||
./configure --prefix=/work/root && \ | ||
make && \ | ||
make install | ||
|
||
FROM alpine:3.9 AS stage-final | ||
|
||
# How many bytes fio is going to read/write, 512MiB by default. | ||
ARG size=256M | ||
|
||
# How many concurrent reading threads. | ||
ARG thread=4 | ||
|
||
WORKDIR /work | ||
COPY --from=stage-build /work/root/ / | ||
|
||
# Lay out test files here, so that they can be compressed into the image layer. | ||
RUN fio -directory=/work -direct=1 -numjobs=$thread -size=$size -name=test -rw=read |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/bash | ||
|
||
# Copyright The containerd Authors. | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -euo pipefail | ||
|
||
cleanup() { | ||
local ORG_EXIT_CODE="${1}" | ||
rm "${DOCKER_COMPOSE_YAML}" || true | ||
exit "${ORG_EXIT_CODE}" | ||
} | ||
trap 'cleanup "$?"' EXIT SIGHUP SIGINT SIGQUIT SIGTERM | ||
|
||
CONTEXT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/" | ||
REPO="${CONTEXT}../../" | ||
|
||
echo "Preparing docker-compose.yml..." | ||
DOCKER_COMPOSE_YAML=$(mktemp) | ||
BENCHMARKING_NODE=fs-bench | ||
BENCHMARKING_CONTAINER=fs-bench | ||
cat <<EOF > "${DOCKER_COMPOSE_YAML}" | ||
version: "3" | ||
services: | ||
${BENCHMARKING_NODE}: | ||
build: | ||
context: "${CONTEXT}/work" | ||
dockerfile: Dockerfile | ||
container_name: ${BENCHMARKING_CONTAINER} | ||
privileged: true | ||
working_dir: /go/src/github.com/containerd/stargz-snapshotter | ||
command: tail -f /dev/null | ||
environment: | ||
- NO_PROXY=127.0.0.1,localhost | ||
- HTTP_PROXY=${HTTP_PROXY:-} | ||
- HTTPS_PROXY=${HTTPS_PROXY:-} | ||
- http_proxy=${http_proxy:-} | ||
- https_proxy=${https_proxy:-} | ||
tmpfs: | ||
- /tmp:exec,mode=777 | ||
volumes: | ||
- "${REPO}:/go/src/github.com/containerd/stargz-snapshotter:ro" | ||
- "/dev/fuse:/dev/fuse" | ||
- "containerd-data:/var/lib/containerd:delegated" | ||
- "containerd-stargz-grpc-data:/var/lib/containerd-stargz-grpc:delegated" | ||
- "containerd-stargz-grpc-status:/run/containerd-stargz-grpc:delegated" | ||
volumes: | ||
containerd-data: | ||
containerd-stargz-grpc-data: | ||
containerd-stargz-grpc-status: | ||
EOF | ||
|
||
echo "Setup benchmark environment..." | ||
docker-compose -f "${DOCKER_COMPOSE_YAML}" build ${DOCKER_BUILD_ARGS:-} "${BENCHMARKING_NODE}" | ||
docker-compose -f "${DOCKER_COMPOSE_YAML}" up -d --force-recreate | ||
|
||
echo "Benchmarking..." | ||
docker exec -i "${BENCHMARKING_CONTAINER}" script/fs-bench/work/run.sh | ||
|
||
echo "Harvesting output..." | ||
docker cp "${BENCHMARKING_CONTAINER}:/output" "${REPO}/out-bench" | ||
|
||
echo "Cleaning up benchmark environment..." | ||
docker-compose -f "${DOCKER_COMPOSE_YAML}" down -v |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright The containerd Authors. | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM golang:1.13 | ||
|
||
# basic tools | ||
COPY ./tools /tmp/tools | ||
|
||
RUN apt-get update -y && \ | ||
apt-get install --no-install-recommends -y libbtrfs-dev libseccomp-dev fuse python \ | ||
apt-transport-https software-properties-common && \ | ||
curl -Lo gnuplot-5.2.8.tar.gz \ | ||
https://sourceforge.net/projects/gnuplot/files/gnuplot/5.2.8/gnuplot-5.2.8.tar.gz/download && \ | ||
sequix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tar xf gnuplot-5.2.8.tar.gz && \ | ||
cd gnuplot-5.2.8 && \ | ||
./configure && make && make install && \ | ||
cd /tmp/tools && \ | ||
GO111MODULE=on go build -o "/usr/local/bin/process" "./process/main.go" && \ | ||
GO111MODULE=on go build -o "/usr/local/bin/scrape" "./scrape/main.go" | ||
|
||
# runtime dependencies | ||
RUN git clone https://github.com/opencontainers/runc \ | ||
$GOPATH/src/github.com/opencontainers/runc && \ | ||
cd $GOPATH/src/github.com/opencontainers/runc && \ | ||
git checkout d736ef14f0288d6993a1845745d6756cfc9ddd5a && \ | ||
GO111MODULE=off make -j2 BUILDTAGS='seccomp apparmor' && \ | ||
GO111MODULE=off make install && \ | ||
git clone https://github.com/containerd/containerd \ | ||
$GOPATH/src/github.com/containerd/containerd && \ | ||
cd $GOPATH/src/github.com/containerd/containerd && \ | ||
git checkout 990076b731ec9446437972b41176a6b0f3b7bcbf && \ | ||
GO111MODULE=off make -j2 && GO111MODULE=off make install | ||
Comment on lines
+33
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recently we introduced a common base image among test codes for easier version management of containerd & runc in this project. Can we use the base image for this? Can use |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[proxy_plugins] | ||
[proxy_plugins.stargz] | ||
type = "snapshot" | ||
address = "/run/containerd-stargz-grpc/containerd-stargz-grpc.sock" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
noprefetch = true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[test] | ||
# TODO randomize the size of each read (pread, to be precise). | ||
bs=4k | ||
rw=randread | ||
size=256M | ||
numjobs=4 | ||
directory=/work | ||
write_bw_log=/output/test | ||
write_iops_log=/output/test | ||
write_lat_log=/output/test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/bash | ||
|
||
# Copyright The containerd Authors. | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -euo pipefail | ||
|
||
CONTAINERD_ROOT=/var/lib/containerd/ | ||
CONTAINERD_CONFIG_DIR=/etc/containerd/ | ||
REMOTE_SNAPSHOTTER_SOCKET=/run/containerd-stargz-grpc/containerd-stargz-grpc.sock | ||
REMOTE_SNAPSHOTTER_ROOT=/var/lib/containerd-stargz-grpc/ | ||
REMOTE_SNAPSHOTTER_CONFIG_DIR=/etc/containerd-stargz-grpc/ | ||
|
||
for arg; do | ||
case x"$arg" in | ||
x-nosnapshotter) | ||
NOSNAPSHOTTER="-nosnapshotter" | ||
;; | ||
x-nocleanup) | ||
NOCLEANUP="-nocleanup" | ||
;; | ||
x*) | ||
SCRAPE_OUTPUT_FILENAME="$arg" | ||
;; | ||
esac | ||
done | ||
|
||
RETRYNUM=30 | ||
RETRYINTERVAL=1 | ||
TIMEOUTSEC=180 | ||
function retry { | ||
local SUCCESS=false | ||
for i in $(seq ${RETRYNUM}) ; do | ||
if eval "timeout ${TIMEOUTSEC} ${@}" ; then | ||
SUCCESS=true | ||
break | ||
fi | ||
echo "Fail(${i}). Retrying..." | ||
sleep ${RETRYINTERVAL} | ||
done | ||
if [ "${SUCCESS}" == "true" ] ; then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
|
||
function kill_all { | ||
if [ "${1}" != "" ] ; then | ||
ps aux | grep "${1}" | grep -v grep | grep -v $(basename ${0}) | sed -E 's/ +/ /g' | cut -f 2 -d ' ' | xargs -I{} kill -9 {} || true | ||
fi | ||
} | ||
|
||
function cleanup { | ||
rm -rf "${CONTAINERD_ROOT}"* | ||
if [ -f "${REMOTE_SNAPSHOTTER_SOCKET}" ] ; then | ||
rm "${REMOTE_SNAPSHOTTER_SOCKET}" | ||
fi | ||
if [ -d "${REMOTE_SNAPSHOTTER_ROOT}snapshotter/snapshots/" ] ; then | ||
find "${REMOTE_SNAPSHOTTER_ROOT}snapshotter/snapshots/" \ | ||
-maxdepth 1 -mindepth 1 -type d -exec umount "{}/fs" \; | ||
fi | ||
rm -rf "${REMOTE_SNAPSHOTTER_ROOT}"* | ||
} | ||
|
||
echo "cleaning up the environment..." | ||
kill_all "containerd" | ||
kill_all "containerd-stargz-grpc" | ||
kill_all "scrape" | ||
if [ "$NOCLEANUP" == "-nocleanup" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unbound variable when no option is passed. It should be |
||
echo "DO NOT CLEANUP containerd & stargz-snapshotter layers" | ||
else | ||
cleanup | ||
fi | ||
if [ "${NOSNAPSHOTTER}" == "-nosnapshotter" ] ; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as the above. Should be |
||
echo "DO NOT RUN remote snapshotter" | ||
else | ||
echo "running remote snaphsotter..." | ||
containerd-stargz-grpc --log-level=debug \ | ||
--address="${REMOTE_SNAPSHOTTER_SOCKET}" \ | ||
--config="${REMOTE_SNAPSHOTTER_CONFIG_DIR}config.stargz.toml" \ | ||
&>/var/log/containerd-stargz-grpc.log & | ||
retry ls "${REMOTE_SNAPSHOTTER_SOCKET}" | ||
mkdir -p "$(dirname "${SCRAPE_OUTPUT_FILENAME}")" | ||
scrape -output "${SCRAPE_OUTPUT_FILENAME}" -netinf eth0 -interval 1s \ | ||
-pid "$(ps aux | grep -v grep | grep containerd-stargz-grpc | awk '{print $2}')" & | ||
fi | ||
echo "running containerd..." | ||
containerd --log-level debug \ | ||
--config="${CONTAINERD_CONFIG_DIR}config.containerd.toml" &>/var/log/containerd.log & | ||
retry ctr version |
Uh oh!
There was an error while loading. Please reload this page.