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
51f938f1
Commit
51f938f1
authored
9 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Make async server use one CQ per server thread
parent
77ece807
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/server_async.cc
+27
-28
27 additions, 28 deletions
test/cpp/qps/server_async.cc
with
27 additions
and
28 deletions
test/cpp/qps/server_async.cc
+
27
−
28
View file @
51f938f1
...
@@ -73,31 +73,35 @@ class AsyncQpsServerTest : public Server {
...
@@ -73,31 +73,35 @@ class AsyncQpsServerTest : public Server {
gpr_free
(
server_address
);
gpr_free
(
server_address
);
builder
.
RegisterAsyncService
(
&
async_service_
);
builder
.
RegisterAsyncService
(
&
async_service_
);
srv_cq_
=
builder
.
AddCompletionQueue
();
for
(
int
i
=
0
;
i
<
config
.
threads
();
i
++
)
{
srv_cqs_
.
emplace_back
(
std
::
move
(
builder
.
AddCompletionQueue
()));
}
server_
=
builder
.
BuildAndStart
();
server_
=
builder
.
BuildAndStart
();
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
request_unary_
=
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
std
::
bind
(
&
TestService
::
AsyncService
::
RequestUnaryCall
,
&
async_service_
,
for
(
int
j
=
0
;
j
<
config
.
threads
();
j
++
)
{
_1
,
_2
,
_3
,
srv_cq_
.
get
(),
srv_cq_
.
get
(),
_4
);
auto
request_unary
=
std
::
bind
(
request_streaming_
=
&
TestService
::
AsyncService
::
RequestUnaryCall
,
&
async_service_
,
_1
,
std
::
bind
(
&
TestService
::
AsyncService
::
RequestStreamingCall
,
_2
,
_3
,
srv_cqs_
[
j
].
get
(),
srv_cqs_
[
j
].
get
(),
_4
);
&
async_service_
,
_1
,
_2
,
srv_cq_
.
get
(),
srv_cq_
.
get
(),
_3
);
auto
request_streaming
=
std
::
bind
(
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
&
TestService
::
AsyncService
::
RequestStreamingCall
,
&
async_service_
,
contexts_
.
push_front
(
_1
,
_2
,
srv_cqs_
[
j
].
get
(),
srv_cqs_
[
j
].
get
(),
_3
);
new
ServerRpcContextUnaryImpl
<
SimpleRequest
,
SimpleResponse
>
(
contexts_
.
push_front
(
request_unary_
,
ProcessRPC
));
new
ServerRpcContextUnaryImpl
<
SimpleRequest
,
SimpleResponse
>
(
contexts_
.
push_front
(
request_unary
,
ProcessRPC
));
new
ServerRpcContextStreamingImpl
<
SimpleRequest
,
SimpleResponse
>
(
contexts_
.
push_front
(
request_streaming_
,
ProcessRPC
));
new
ServerRpcContextStreamingImpl
<
SimpleRequest
,
SimpleResponse
>
(
request_streaming
,
ProcessRPC
));
}
}
}
for
(
int
i
=
0
;
i
<
config
.
threads
();
i
++
)
{
for
(
int
i
=
0
;
i
<
config
.
threads
();
i
++
)
{
threads_
.
push_back
(
std
::
thread
([
=
]()
{
threads_
.
push_back
(
std
::
thread
([
=
]()
{
// Wait until work is available or we are shutting down
// Wait until work is available or we are shutting down
bool
ok
;
bool
ok
;
void
*
got_tag
;
void
*
got_tag
;
while
(
srv_cq
_
->
Next
(
&
got_tag
,
&
ok
))
{
while
(
srv_cq
s_
[
i
]
->
Next
(
&
got_tag
,
&
ok
))
{
ServerRpcContext
*
ctx
=
detag
(
got_tag
);
ServerRpcContext
*
ctx
=
detag
(
got_tag
);
// The tag is a pointer to an RPC context to invoke
// The tag is a pointer to an RPC context to invoke
bool
still_going
=
ctx
->
RunNextState
(
ok
);
bool
still_going
=
ctx
->
RunNextState
(
ok
);
...
@@ -125,11 +129,13 @@ class AsyncQpsServerTest : public Server {
...
@@ -125,11 +129,13 @@ class AsyncQpsServerTest : public Server {
for
(
auto
thr
=
threads_
.
begin
();
thr
!=
threads_
.
end
();
thr
++
)
{
for
(
auto
thr
=
threads_
.
begin
();
thr
!=
threads_
.
end
();
thr
++
)
{
thr
->
join
();
thr
->
join
();
}
}
srv_cq_
->
Shutdown
();
for
(
auto
cq
=
srv_cqs_
.
begin
();
cq
!=
srv_cqs_
.
end
();
++
cq
)
{
bool
ok
;
(
*
cq
)
->
Shutdown
();
void
*
got_tag
;
bool
ok
;
while
(
srv_cq_
->
Next
(
&
got_tag
,
&
ok
))
void
*
got_tag
;
;
while
((
*
cq
)
->
Next
(
&
got_tag
,
&
ok
))
;
}
while
(
!
contexts_
.
empty
())
{
while
(
!
contexts_
.
empty
())
{
delete
contexts_
.
front
();
delete
contexts_
.
front
();
contexts_
.
pop_front
();
contexts_
.
pop_front
();
...
@@ -306,15 +312,8 @@ class AsyncQpsServerTest : public Server {
...
@@ -306,15 +312,8 @@ class AsyncQpsServerTest : public Server {
}
}
std
::
vector
<
std
::
thread
>
threads_
;
std
::
vector
<
std
::
thread
>
threads_
;
std
::
unique_ptr
<
grpc
::
Server
>
server_
;
std
::
unique_ptr
<
grpc
::
Server
>
server_
;
std
::
unique_ptr
<
grpc
::
ServerCompletionQueue
>
srv_cq_
;
std
::
vector
<
std
::
unique_ptr
<
grpc
::
ServerCompletionQueue
>
>
srv_cq
s
_
;
TestService
::
AsyncService
async_service_
;
TestService
::
AsyncService
async_service_
;
std
::
function
<
void
(
ServerContext
*
,
SimpleRequest
*
,
grpc
::
ServerAsyncResponseWriter
<
SimpleResponse
>
*
,
void
*
)
>
request_unary_
;
std
::
function
<
void
(
ServerContext
*
,
grpc
::
ServerAsyncReaderWriter
<
SimpleResponse
,
SimpleRequest
>
*
,
void
*
)
>
request_streaming_
;
std
::
forward_list
<
ServerRpcContext
*>
contexts_
;
std
::
forward_list
<
ServerRpcContext
*>
contexts_
;
std
::
mutex
shutdown_mutex_
;
std
::
mutex
shutdown_mutex_
;
...
...
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