From f10e1f65e568eff497e721a2a30a8ca39c120d25 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Wed, 1 Jul 2020 16:41:28 +0800 Subject: [PATCH] refine cube benchmark --- .../op/general_dist_kv_infer_op.cpp | 9 +++++--- .../criteo_ctr_with_cube/benchmark.py | 5 ++++- .../criteo_ctr_with_cube/benchmark.sh | 22 ++++++++++++++++--- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/core/general-server/op/general_dist_kv_infer_op.cpp b/core/general-server/op/general_dist_kv_infer_op.cpp index 9c6c7035..adaa6cbc 100644 --- a/core/general-server/op/general_dist_kv_infer_op.cpp +++ b/core/general-server/op/general_dist_kv_infer_op.cpp @@ -90,6 +90,9 @@ int GeneralDistKVInferOp::inference() { keys.begin() + key_idx); key_idx += dataptr_size_pairs[i].second; } + Timer timeline; + int64_t cube_start = timeline.TimeStampUS(); + timeline.Start(); rec::mcube::CubeAPI *cube = rec::mcube::CubeAPI::instance(); std::vector table_names = cube->get_table_names(); if (table_names.size() == 0) { @@ -97,7 +100,7 @@ int GeneralDistKVInferOp::inference() { return -1; } int ret = cube->seek(table_names[0], keys, &values); - + int64_t cube_end = timeline.TimeStampUS(); if (values.size() != keys.size() || values[0].buff.size() == 0) { LOG(ERROR) << "cube value return null"; } @@ -153,9 +156,7 @@ int GeneralDistKVInferOp::inference() { VLOG(2) << "infer batch size: " << batch_size; - Timer timeline; int64_t start = timeline.TimeStampUS(); - timeline.Start(); if (InferManager::instance().infer( engine_name().c_str(), &infer_in, out, batch_size)) { @@ -165,6 +166,8 @@ int GeneralDistKVInferOp::inference() { int64_t end = timeline.TimeStampUS(); CopyBlobInfo(input_blob, output_blob); + AddBlobInfo(output_blob, cube_start); + AddBlobInfo(output_blob, cube_end); AddBlobInfo(output_blob, start); AddBlobInfo(output_blob, end); return 0; diff --git a/python/examples/criteo_ctr_with_cube/benchmark.py b/python/examples/criteo_ctr_with_cube/benchmark.py index a850d244..5e952474 100755 --- a/python/examples/criteo_ctr_with_cube/benchmark.py +++ b/python/examples/criteo_ctr_with_cube/benchmark.py @@ -71,14 +71,17 @@ if __name__ == '__main__': multi_thread_runner = MultiThreadRunner() endpoint_list = ["127.0.0.1:9292"] #result = single_func(0, {"endpoint": endpoint_list}) + start = time.time() result = multi_thread_runner.run(single_func, args.thread, {"endpoint": endpoint_list}) - print(result) + end = time.time() + total_cost = end - start avg_cost = 0 qps = 0 for i in range(args.thread): avg_cost += result[0][i * 2 + 0] qps += result[0][i * 2 + 1] avg_cost = avg_cost / args.thread + print("total cost: {}".format(total_cost)) print("average total cost {} s.".format(avg_cost)) print("qps {} ins/s".format(qps)) diff --git a/python/examples/criteo_ctr_with_cube/benchmark.sh b/python/examples/criteo_ctr_with_cube/benchmark.sh index 35b19b63..21daf933 100755 --- a/python/examples/criteo_ctr_with_cube/benchmark.sh +++ b/python/examples/criteo_ctr_with_cube/benchmark.sh @@ -1,9 +1,23 @@ rm profile_log export FLAGS_profile_client=1 export FLAGS_profile_server=1 -for thread_num in 1 2 4 8 16 + +wget https://paddle-serving.bj.bcebos.com/unittest/ctr_cube_unittest.tar.gz --no-check-certificate +tar xf ctr_cube_unittest.tar.gz +mv models/ctr_client_conf ./ +mv models/ctr_serving_model_kv ./ +mv models/data ./cube/ + +wget https://paddle-serving.bj.bcebos.com/others/cube_app.tar.gz --no-check-certificate +tar xf cube_app.tar.gz +mv cube_app/cube* ./cube/ +sh cube_prepare.sh & + +python test_server.py ctr_serving_model_kv > serving_log 2>&1 & + +for thread_num in 1 4 16 do -for batch_size in 1 4 16 64 256 +for batch_size in 1 4 16 64 do $PYTHONROOT/bin/python benchmark.py --thread $thread_num --batch_size $batch_size --model serving_client_conf/serving_client_conf.prototxt --request rpc > profile 2>&1 echo "batch size : $batch_size" @@ -11,6 +25,8 @@ do echo "========================================" echo "batch size : $batch_size" >> profile_log $PYTHONROOT/bin/python ../util/show_profile.py profile $thread_num >> profile_log - tail -n 2 profile >> profile_log + tail -n 3 profile >> profile_log done done + +ps -ef|grep 'serving'|grep -v grep|cut -c 9-15 | xargs kill -9 -- GitLab