Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
58977f14
Commit
58977f14
authored
Oct 4, 2016
by
Yuxuan Li
Browse files
Options
Downloads
Patches
Plain Diff
initial merge of latency vs load to qps_json_driver.cc
parent
fe21ec90
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cpp/qps/qps_json_driver.cc
+94
-22
94 additions, 22 deletions
test/cpp/qps/qps_json_driver.cc
with
94 additions
and
22 deletions
test/cpp/qps/qps_json_driver.cc
+
94
−
22
View file @
58977f14
...
...
@@ -50,13 +50,100 @@ DEFINE_string(scenarios_json, "",
"JSON string containing an array of Scenario objects"
);
DEFINE_bool
(
quit
,
false
,
"Quit the workers"
);
DEFINE_bool
(
search
,
flase
,
"Search for offered load setting that achieves targeted cpu load"
);
DEFINE_double
(
initial_offered_load
,
1000.0
,
"Set up for intial offered load"
);
DEFINE_double
(
targeted_cpu_load
,
99.0
,
"targeted cpu load"
);
DEFINE_double
(
precision
,
500
,
"final search result precision"
);
namespace
grpc
{
namespace
testing
{
static
std
::
unique_ptr
<
ScenarioResult
>
RunAndReport
(
const
Scenario
&
scenario
,
bool
*
success
)
{
std
::
cerr
<<
"RUNNING SCENARIO: "
<<
scenario
.
name
()
<<
"
\n
"
;
auto
result
=
RunScenario
(
scenario
.
client_config
(),
scenario
.
num_clients
(),
scenario
.
server_config
(),
scenario
.
num_servers
(),
scenario
.
warmup_seconds
(),
scenario
.
benchmark_seconds
(),
scenario
.
spawn_local_worker_count
());
// Amend the result with scenario config. Eventually we should adjust
// RunScenario contract so we don't need to touch the result here.
result
->
mutable_scenario
()
->
CopyFrom
(
scenario
);
GetReporter
()
->
ReportQPS
(
*
result
);
GetReporter
()
->
ReportQPSPerCore
(
*
result
);
GetReporter
()
->
ReportLatency
(
*
result
);
GetReporter
()
->
ReportTimes
(
*
result
);
GetReporter
()
->
ReportCpuUsage
(
*
result
);
for
(
int
i
=
0
;
*
success
&&
i
<
result
->
client_success_size
();
i
++
)
{
*
success
=
result
->
client_success
(
i
);
}
for
(
int
i
=
0
;
*
success
&&
i
<
result
->
server_success_size
();
i
++
)
{
*
success
=
result
->
server_success
(
i
);
}
return
result
;
}
static
double
GetCpuLoad
(
Scenario
*
scenario
,
double
offered_load
,
bool
*
success
)
{
scenario
->
mutable_client_config
()
->
mutable_load_params
()
->
mutable_poisson
()
->
set_offered_load
(
offered_load
);
auto
result
=
RunAndReport
(
*
scenario
,
success
);
return
result
->
summary
().
server_cpu_usage
();
}
static
double
BinarySearch
(
Scenario
*
scenario
,
double
targeted_cpu_load
,
double
low_offered_load
,
double
high_offered_load
,
bool
*
success
)
{
while
(
low
<=
high
-
FLAGS_precision
)
{
double
mid
=
low
+
(
high
-
low
)
/
2
;
double
current_cpu_load
=
GetCpuLoad
(
scenario
,
mid
,
success
);
gpr_log
(
GPR_INFO
,
"binary search: current_offered_load %.0f"
,
mid
);
if
(
!*
success
)
{
gpr_log
(
GPR_ERROR
,
"Client/Server Failure"
);
break
;
}
if
(
targeted_cpu_load
<
current_cpu_load
)
{
high
=
mid
-
1
;
}
else
if
(
targeted_cpu_load
>
current_cpu_load
)
{
low
=
mid
+
1
;
}
else
{
high
=
mid
-
1
;
}
}
return
low
;
}
static
double
SearchOfferedLoad
(
double
initial_offered_load
,
double
targeted_cpu_load
,
Scenario
*
scenario
,
bool
*
success
)
{
std
::
cerr
<<
"RUNNING SCENARIO: "
<<
scenario
->
name
()
<<
"
\n
"
;
double
current_offered_load
=
initial_offered_load
;
double
current_cpu_load
=
GetCpuLoad
(
scenario
,
current_offered_load
,
success
);
if
(
current_cpu_load
>
targeted_cpu_load
)
{
gpr_log
(
GPR_ERROR
,
"Initial offered load too high"
);
return
-
1
;
}
while
(
*
success
&&
(
current_cpu_load
<
targeted_cpu_load
))
{
current_offered_load
*=
2
;
current_cpu_load
=
GetCpuLoad
(
scenario
,
current_offered_load
,
success
);
gpr_log
(
GPR_INFO
,
"do while: current_offered_load %f"
,
current_offered_load
);
}
double
targeted_offered_load
=
BinarySearch
(
scenario
,
targeted_cpu_load
,
current_offered_load
/
2
,
current_offered_load
,
success
);
return
targeted_offered_load
;
}
static
bool
QpsDriver
()
{
grpc
::
string
json
;
...
...
@@ -97,29 +184,14 @@ static bool QpsDriver() {
GPR_ASSERT
(
scenarios
.
scenarios_size
()
>
0
);
for
(
int
i
=
0
;
i
<
scenarios
.
scenarios_size
();
i
++
)
{
if
(
!
FLAGS_search
)
{
const
Scenario
&
scenario
=
scenarios
.
scenarios
(
i
);
std
::
cerr
<<
"RUNNING SCENARIO: "
<<
scenario
.
name
()
<<
"
\n
"
;
auto
result
=
RunScenario
(
scenario
.
client_config
(),
scenario
.
num_clients
(),
scenario
.
server_config
(),
scenario
.
num_servers
(),
scenario
.
warmup_seconds
(),
scenario
.
benchmark_seconds
(),
scenario
.
spawn_local_worker_count
());
// Amend the result with scenario config. Eventually we should adjust
// RunScenario contract so we don't need to touch the result here.
result
->
mutable_scenario
()
->
CopyFrom
(
scenario
);
GetReporter
()
->
ReportQPS
(
*
result
);
GetReporter
()
->
ReportQPSPerCore
(
*
result
);
GetReporter
()
->
ReportLatency
(
*
result
);
GetReporter
()
->
ReportTimes
(
*
result
);
GetReporter
()
->
ReportCpuUsage
(
*
result
);
for
(
int
i
=
0
;
success
&&
i
<
result
->
client_success_size
();
i
++
)
{
success
=
result
->
client_success
(
i
);
RunAndReport
(
scenario
,
&
success
);
}
for
(
int
i
=
0
;
success
&&
i
<
result
->
server_success_size
();
i
++
)
{
success
=
result
->
server_success
(
i
);
else
{
Scenario
*
scenario
=
scenarios
.
mutable_scenarios
(
i
);
double
targeted_offered_load
=
SearchOfferedLoad
(
FLAGS_initial_offered_load
,
FLAGS_targeted_cpu_load
,
scenario
,
&
success
);
gpr_log
(
GPR_INFO
,
"targeted_offered_load %f"
,
targeted_offered_load
);
}
}
return
success
;
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment