Skip to content

Local perf #174

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

Merged
merged 3 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions scripts/deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ Run the script:

Results will be saved locally and be shown on the screen as well.

## Test Performance Locally
Before running, place the private IP addresses of your machines in the file ``config/kv_performance_server_local.conf``.
You can simply add "127.0.0.1" to the files to specify the number of nodes and clients.

Run the script:

./performance_local/pbft_performance.sh config/kv_performance_server_local.conf


## Using non-ubuntu account ##
The default path for the workspace to deploy the system is /home/ubuntu
Expand Down
9 changes: 9 additions & 0 deletions scripts/deploy/config/kv_performance_server_local.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
iplist=(
127.0.0.1
127.0.0.1
127.0.0.1
127.0.0.1
127.0.0.1
)

client_num=1
71 changes: 71 additions & 0 deletions scripts/deploy/performance_local/calculate_result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

import sys

def read_tps(file):
tps = []
lat = []
with open(file) as f:
for l in f.readlines():
s = l.split()
for r in s:
if(r.split(':')[0] == 'txn'):
tps.append(int(r.split(':')[1]))
if l.find("client latency") > 0:
lat.append(float(s[-1].split(':')[-1]))
return tps, lat

def cal_tps(tps):
tps_sum = []
tps_max = 0

for v in tps:
if v == 0:
continue
tps_max = max(tps_max, v)
tps_sum.append(v)

print("max throughput:",tps_max)
print("average throughput:",sum(tps_sum)/len(tps_sum))

def cal_lat(lat):
lat_sum = []
lat_max = 0
for v in lat:
if v == 0:
continue
lat_max = max(lat_max, v)
lat_sum.append(v)

print("max latency:",lat_max)
print("average latency:",sum(lat_sum)/len(lat_sum))

if __name__ == '__main__':
files = sys.argv[1:]
print("calculate results, number of nodes:",len(files))


tps = []
lat = []
for f in files:
t, l=read_tps(f)
tps += t
lat += l

cal_tps(tps)
cal_lat(lat)
24 changes: 24 additions & 0 deletions scripts/deploy/performance_local/pbft_performance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

export server=//benchmark/protocols/pbft:kv_server_performance
#export TEMPLATE_PATH=$PWD/config/pbft.config
export performance=true

./performance_local/run_performance.sh $*
23 changes: 23 additions & 0 deletions scripts/deploy/performance_local/poe_performance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

export server=//benchmark/protocols/poe:kv_server_performance
export TEMPLATE_PATH=$PWD/config/poe.config

./performance_local/run_performance.sh $*
60 changes: 60 additions & 0 deletions scripts/deploy/performance_local/run_performance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#


./script/deploy_local.sh $1
. ./script/load_config.sh $1
. ./script/env.sh

home_path="./"
server_name=`echo "$server" | awk -F':' '{print $NF}'`
server_bin=${server_name}

bazel run //benchmark/protocols/pbft:kv_service_tools -- $PWD/config_out/client.config

sleep 60

echo "benchmark done"
count=1
for ip in ${iplist[@]};
do
echo "server bin:"${server_bin}
killall -9 ${server_bin}
((count++))
done

while [ $count -gt 0 ]; do
wait $pids
count=`expr $count - 1`
done

idx=1
echo "getting results"
for ip in ${iplist[@]};
do
echo "cp ${home_path}/${server_bin}.log ./${ip}_${idx}_log"
cp ${home_path}/resilientdb_app/${idx}/${server_bin}.log result_${ip}_${idx}_log
((idx++))
done

python3 performance/calculate_result.py `ls result_*_log` > results.log

rm -rf result_*_log
echo "save result to results.log"
cat results.log
169 changes: 169 additions & 0 deletions scripts/deploy/script/deploy_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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 -e

# load environment parameters
. ./script/env.sh

# load ip list
. ./script/load_config.sh $1

script_path=${BAZEL_WORKSPACE_PATH}/scripts

if [[ -z $server ]];
then
server=//service/kv:kv_service
fi

# obtain the src path
main_folder=resilientdb_app
server_path=`echo "$server" | sed 's/:/\//g'`
server_path=${server_path:1}
server_name=`echo "$server" | awk -F':' '{print $NF}'`
server_bin=${server_name}
grafna_port=8090

bin_path=${BAZEL_WORKSPACE_PATH}/bazel-bin/${server_path}
output_path=${script_path}/deploy/config_out
output_key_path=${output_path}/cert
output_cert_path=${output_key_path}
export home_path=${script_path}/deploy

admin_key_path=${script_path}/deploy/data/cert

rm -rf ${output_path}
mkdir -p ${output_path}

deploy_iplist=${iplist[@]}


echo "server src path:"${server_path}
echo "server bazel bin path:"${bin_path}
echo "server name:"${server_bin}
echo "admin config path:"${admin_key_path}
echo "output path:"${output_path}
echo "deploy to :"${deploy_iplist[@]}

# generate keys and certificates.

cd ${script_path}
echo "where am i:"$PWD

deploy/script/generate_admin_key.sh ${BAZEL_WORKSPACE_PATH} ${admin_key_path}
deploy/script/generate_key.sh ${BAZEL_WORKSPACE_PATH} ${output_key_path} ${#iplist[@]}
deploy/script/generate_config.sh ${BAZEL_WORKSPACE_PATH} ${output_key_path} ${output_cert_path} ${output_path} ${admin_key_path} ${deploy_iplist[@]}

# build kv server
bazel build ${server}

if [ $? != 0 ]
then
echo "Complile ${server} failed"
exit 0
fi

# commands functions
function run_cmd(){
echo "run cmd:"$1
count=1
idx=1
for ip in ${deploy_iplist[@]};
do
cd ${home_path}/${main_folder}/$idx;
`$1`
((count++))
((idx++))
done

while [ $count -gt 0 ]; do
wait $pids
count=`expr $count - 1`
done
}

function run_one_cmd(){
echo "run one:"$1
$1
}

run_cmd "killall -9 ${server_bin}"
if [ $performance ];
then
run_cmd "rm -rf ${home_path}/${main_folder}"
fi

idx=1
for ip in ${deploy_iplist[@]};
do
run_one_cmd "mkdir -p ${home_path}/${main_folder}/$idx" &
((count++))
((idx++))
done


# upload config files and binary
echo "upload configs"
idx=1
count=0
for ip in ${deploy_iplist[@]};
do
echo "cp -r ${bin_path} ${output_path}/server.config ${output_path}/cert ${home_path}/${main_folder}/$idx"
cp -r ${bin_path} ${output_path}/server.config ${output_path}/cert ${home_path}/${main_folder}/$idx &
((count++))
((idx++))
done

while [ $count -gt 0 ]; do
wait $pids
count=`expr $count - 1`
done

echo "start to run" $PWD
# Start server
idx=1
count=0
for ip in ${deploy_iplist[@]};
do
private_key="cert/node_"${idx}".key.pri"
cert="cert/cert_"${idx}".cert"
cd ${home_path}/${main_folder}/$idx; nohup ./${server_bin} server.config ${private_key} ${cert} ${grafna_port} > ${server_bin}.log 2>&1 &
((count++))
((idx++))
((grafna_port++))
done

# Check ready logs
idx=1
for ip in ${deploy_iplist[@]};
do
resp=""
while [ "$resp" = "" ]
do
cd ${home_path}/${main_folder}/$idx;
resp=`grep "receive public size:${#iplist[@]}" ${server_bin}.log`
if [ "$resp" = "" ]; then
sleep 1
fi
done
((idx++))
done

echo "Servers are running....."

Loading