This is an automated email from the ASF dual-hosted git repository.
junchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-resilientdb.git
The following commit(s) were added to refs/heads/master by this push:
new edff4f8e Local perf (#174)
edff4f8e is described below
commit edff4f8ea7580257b2edb6716c47b4b3a8db12c9
Author: cjcchen <[email protected]>
AuthorDate: Thu Apr 17 02:56:33 2025 +0800
Local perf (#174)
* add local per
* add local per
* add read me
---------
Co-authored-by: junchao
<[email protected]>
---
scripts/deploy/README.md | 8 +
.../deploy/config/kv_performance_server_local.conf | 9 ++
.../deploy/performance_local/calculate_result.py | 71 +++++++++
.../deploy/performance_local/pbft_performance.sh | 24 +++
.../deploy/performance_local/poe_performance.sh | 23 +++
.../deploy/performance_local/run_performance.sh | 60 ++++++++
scripts/deploy/script/deploy_local.sh | 169 +++++++++++++++++++++
7 files changed, 364 insertions(+)
diff --git a/scripts/deploy/README.md b/scripts/deploy/README.md
index 7abab0e7..cce87624 100644
--- a/scripts/deploy/README.md
+++ b/scripts/deploy/README.md
@@ -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
diff --git a/scripts/deploy/config/kv_performance_server_local.conf
b/scripts/deploy/config/kv_performance_server_local.conf
new file mode 100644
index 00000000..3a16d95e
--- /dev/null
+++ b/scripts/deploy/config/kv_performance_server_local.conf
@@ -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
diff --git a/scripts/deploy/performance_local/calculate_result.py
b/scripts/deploy/performance_local/calculate_result.py
new file mode 100644
index 00000000..f6892d26
--- /dev/null
+++ b/scripts/deploy/performance_local/calculate_result.py
@@ -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)
diff --git a/scripts/deploy/performance_local/pbft_performance.sh
b/scripts/deploy/performance_local/pbft_performance.sh
new file mode 100755
index 00000000..003b9787
--- /dev/null
+++ b/scripts/deploy/performance_local/pbft_performance.sh
@@ -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 $*
diff --git a/scripts/deploy/performance_local/poe_performance.sh
b/scripts/deploy/performance_local/poe_performance.sh
new file mode 100755
index 00000000..fd23e077
--- /dev/null
+++ b/scripts/deploy/performance_local/poe_performance.sh
@@ -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 $*
diff --git a/scripts/deploy/performance_local/run_performance.sh
b/scripts/deploy/performance_local/run_performance.sh
new file mode 100755
index 00000000..25cab4cf
--- /dev/null
+++ b/scripts/deploy/performance_local/run_performance.sh
@@ -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
diff --git a/scripts/deploy/script/deploy_local.sh
b/scripts/deploy/script/deploy_local.sh
new file mode 100755
index 00000000..7adb1918
--- /dev/null
+++ b/scripts/deploy/script/deploy_local.sh
@@ -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....."
+