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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
f4671bfa
Commit
f4671bfa
authored
8 years ago
by
Vijay Pai
Browse files
Options
Downloads
Patches
Plain Diff
Remove a namespace and start using a lambda for a small function
parent
c01958bf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cpp/qps/driver.cc
+19
-31
19 additions, 31 deletions
test/cpp/qps/driver.cc
with
19 additions
and
31 deletions
test/cpp/qps/driver.cc
+
19
−
31
View file @
f4671bfa
...
...
@@ -177,39 +177,21 @@ static void postprocess_scenario_result(ScenarioResult* result) {
}
}
// Namespace for classes and functions used only in RunScenario
// Using this rather than local definitions to workaround gcc-4.4 limitations
// regarding using templates without linkage
namespace
runsc
{
// ClientContext allocator
static
ClientContext
*
AllocContext
(
list
<
ClientContext
>*
contexts
)
{
contexts
->
emplace_back
();
auto
context
=
&
contexts
->
back
();
context
->
set_wait_for_ready
(
true
);
return
context
;
}
struct
ServerData
{
unique_ptr
<
WorkerService
::
Stub
>
stub
;
unique_ptr
<
ClientReaderWriter
<
ServerArgs
,
ServerStatus
>>
stream
;
};
struct
ClientData
{
unique_ptr
<
WorkerService
::
Stub
>
stub
;
unique_ptr
<
ClientReaderWriter
<
ClientArgs
,
ClientStatus
>>
stream
;
};
}
// namespace runsc
std
::
unique_ptr
<
ScenarioResult
>
RunScenario
(
const
ClientConfig
&
initial_client_config
,
size_t
num_clients
,
const
ServerConfig
&
initial_server_config
,
size_t
num_servers
,
int
warmup_seconds
,
int
benchmark_seconds
,
int
spawn_local_worker_count
)
{
// Log everything from the driver
gpr_set_log_verbosity
(
GPR_LOG_SEVERITY_DEBUG
);
// ClientContext allocations (all are destroyed at scope exit)
list
<
ClientContext
>
contexts
;
auto
alloc_context
=
[](
list
<
ClientContext
>*
contexts
)
{
contexts
->
emplace_back
();
auto
context
=
&
contexts
->
back
();
context
->
set_wait_for_ready
(
true
);
return
context
;
};
// To be added to the result, containing the final configuration used for
// client and config (including host, etc.)
...
...
@@ -262,7 +244,11 @@ std::unique_ptr<ScenarioResult> RunScenario(
workers
.
resize
(
num_clients
+
num_servers
);
// Start servers
std
::
vector
<
runsc
::
ServerData
>
servers
(
num_servers
);
struct
ServerData
{
unique_ptr
<
WorkerService
::
Stub
>
stub
;
unique_ptr
<
ClientReaderWriter
<
ServerArgs
,
ServerStatus
>>
stream
;
};
std
::
vector
<
ServerData
>
servers
(
num_servers
);
for
(
size_t
i
=
0
;
i
<
num_servers
;
i
++
)
{
gpr_log
(
GPR_INFO
,
"Starting server on %s (worker #%"
PRIuPTR
")"
,
workers
[
i
].
c_str
(),
i
);
...
...
@@ -306,8 +292,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
ServerArgs
args
;
*
args
.
mutable_setup
()
=
server_config
;
servers
[
i
].
stream
=
servers
[
i
].
stub
->
RunServer
(
runsc
::
AllocContext
(
&
contexts
));
servers
[
i
].
stream
=
servers
[
i
].
stub
->
RunServer
(
alloc_context
(
&
contexts
));
if
(
!
servers
[
i
].
stream
->
Write
(
args
))
{
gpr_log
(
GPR_ERROR
,
"Could not write args to server %zu"
,
i
);
}
...
...
@@ -325,7 +310,11 @@ std::unique_ptr<ScenarioResult> RunScenario(
// Targets are all set by now
result_client_config
=
client_config
;
// Start clients
std
::
vector
<
runsc
::
ClientData
>
clients
(
num_clients
);
struct
ClientData
{
unique_ptr
<
WorkerService
::
Stub
>
stub
;
unique_ptr
<
ClientReaderWriter
<
ClientArgs
,
ClientStatus
>>
stream
;
};
std
::
vector
<
ClientData
>
clients
(
num_clients
);
size_t
channels_allocated
=
0
;
for
(
size_t
i
=
0
;
i
<
num_clients
;
i
++
)
{
const
auto
&
worker
=
workers
[
i
+
num_servers
];
...
...
@@ -374,8 +363,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
ClientArgs
args
;
*
args
.
mutable_setup
()
=
per_client_config
;
clients
[
i
].
stream
=
clients
[
i
].
stub
->
RunClient
(
runsc
::
AllocContext
(
&
contexts
));
clients
[
i
].
stream
=
clients
[
i
].
stub
->
RunClient
(
alloc_context
(
&
contexts
));
if
(
!
clients
[
i
].
stream
->
Write
(
args
))
{
gpr_log
(
GPR_ERROR
,
"Could not write args to client %zu"
,
i
);
}
...
...
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
register
or
sign in
to comment