Add Except example

This commit is contained in:
tanghan
2022-09-22 07:35:48 +00:00
parent 811b477b5e
commit 8a0955c9d9
5 changed files with 116 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
1. Download the test data
wget http://cs.fit.edu/~mmahoney/compression/enwik8.zip
2. Prepare the environment
sh prepare.sh enwik8.zip
3. Start to tuning
atune-adm tuning --project compress_Except_example --detail compress_Except_example_client.yaml
4. Restore the environment
atune-adm tuning --restore --project compress_Except_example
5. Divide ip
Use "-" to divide inter group ip and "," to divide intra group ip in /etc/atuned/atuned.cnf
6. Use Except
Use "Except" in server.yaml file to declare which parameters cannot adjust the "object", and ips are separated by ","

View File

@@ -0,0 +1,28 @@
"""
This program is used as compression benchmark
"""
import time
import zlib
import gzip
import bz2
FILE_PATH = "compress_Except_example/enwik8"
COMPRESS_LEVEL = 8
COMPRESS_METHOD = "bz2"
with open(FILE_PATH, 'rb') as f_in:
data = f_in.read()
start = time.time()
RES = b"compressed result"
if COMPRESS_METHOD == "bz2":
RES = bz2.compress(data, COMPRESS_LEVEL)
elif COMPRESS_METHOD == "zlib":
RES = zlib.compress(data, COMPRESS_LEVEL)
elif COMPRESS_METHOD == "gzip":
RES = gzip.compress(data, COMPRESS_LEVEL)
end = time.time()
print("time = %f" % (end - start))
print("compress_ratio = %f" % (len(data) / len(RES)))

View File

@@ -0,0 +1,19 @@
project: "compress_Except_example"
engine : "gbrt"
iterations : 20
random_starts : 10
benchmark : "python3 compress_Except_example/compress_Except_example.py"
evaluations :
-
name: "time"
info:
get: "echo '$out' | grep 'time' | awk '{print $3}'"
type: "positive"
weight: 20
-
name: "compress_ratio"
info:
get: "echo '$out' | grep 'compress_ratio' | awk '{print $3}'"
type: "negative"
weight: 80

View File

@@ -0,0 +1,34 @@
project: "compress_Except_example"
maxiterations: 500
startworkload: ""
stopworkload: ""
object :
-
name : "compressLevel"
info :
desc : "The compresslevel parameter is an integer from 1 to 9 controlling the level of compression"
get : "cat compress_Except_example/compress_Except_example.py | grep 'COMPRESS_LEVEL =' | awk -F '=' '{print $2}'"
set : "sed -i 's/^COMPRESS_LEVEL =\\s*[0-9]*/COMPRESS_LEVEL = $value/g' compress_Except_example/compress_Except_example.py"
needrestart : "false"
type : "continuous"
scope :
- 1
- 9
dtype : "int"
Except : "ip1"
# ip1 不能调节 compressLevel
-
name : "compressMethod"
info :
desc : "The compressMethod parameter is a string controlling the compression method"
get : "cat compress_Except_example/compress_Except_example.py | grep 'COMPRESS_METHOD =' | awk -F '=' '{print $2}' | sed 's/\"//g'"
set : "sed -i 's/^COMPRESS_METHOD =\\s*[0-9,a-z,\"]*/COMPRESS_METHOD = \"$value\"/g' compress_Except_example/compress_Except_example.py"
needrestart : "false"
type : "discrete"
options :
- "bz2"
- "zlib"
- "gzip"
dtype : "string"
Except : "ip2"
# ip2 不能调节compressMethod

View File

@@ -0,0 +1,23 @@
#!/usr/bin/bash
if [ "$#" -ne 1 ]; then
echo "USAGE: $0 the path of enwik8.zip"
exit 1
fi
path=$(
cd "$(dirname "$0")"
pwd
)
echo "unzip enwik8.zip"
unzip "$path"/enwik8.zip
echo "set FILE_PATH to the path of enwik8 in compress_Except_example.py"
sed -i "s#compress_Except_example/enwik8#$path/enwik8#g" "$path"/compress_Except_example.py
echo "update the client and server yaml files"
sed -i "s#python3 .*compress_Except_example.py#python3 $path/compress_Except_example.py#g" "$path"/compress_Except_example_client.yaml
sed -i "s# compress_Except_example/compress_Except_example.py# $path/compress_Except_example.py#g" "$path"/compress_Except_example_server.yaml
echo "copy the server yaml file to /etc/atuned/tuning/"
cp "$path"/compress_Except_example_server.yaml /etc/atuned/tuning/