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
ab1dba72
Commit
ab1dba72
authored
9 years ago
by
Vijay Pai
Browse files
Options
Downloads
Patches
Plain Diff
clang-format
parent
09d0b0cf
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/cpp/qps/client.h
+25
-21
25 additions, 21 deletions
test/cpp/qps/client.h
test/cpp/qps/client_async.cc
+23
-22
23 additions, 22 deletions
test/cpp/qps/client_async.cc
test/cpp/qps/interarrival.h
+2
-2
2 additions, 2 deletions
test/cpp/qps/interarrival.h
with
50 additions
and
45 deletions
test/cpp/qps/client.h
+
25
−
21
View file @
ab1dba72
...
@@ -71,7 +71,8 @@ class Client {
...
@@ -71,7 +71,8 @@ class Client {
explicit
Client
(
const
ClientConfig
&
config
)
explicit
Client
(
const
ClientConfig
&
config
)
:
timer_
(
new
Timer
),
interarrival_timer_
()
{
:
timer_
(
new
Timer
),
interarrival_timer_
()
{
for
(
int
i
=
0
;
i
<
config
.
client_channels
();
i
++
)
{
for
(
int
i
=
0
;
i
<
config
.
client_channels
();
i
++
)
{
channels_
.
emplace_back
(
config
.
server_targets
(
i
%
config
.
server_targets_size
()),
config
);
channels_
.
emplace_back
(
config
.
server_targets
(
i
%
config
.
server_targets_size
()),
config
);
}
}
request_
.
set_response_type
(
grpc
::
testing
::
PayloadType
::
COMPRESSABLE
);
request_
.
set_response_type
(
grpc
::
testing
::
PayloadType
::
COMPRESSABLE
);
request_
.
set_response_size
(
config
.
payload_size
());
request_
.
set_response_size
(
config
.
payload_size
());
...
@@ -188,8 +189,11 @@ class Client {
...
@@ -188,8 +189,11 @@ class Client {
class
Thread
{
class
Thread
{
public:
public:
Thread
(
Client
*
client
,
size_t
idx
)
Thread
(
Client
*
client
,
size_t
idx
)
:
done_
(
false
),
new_
(
nullptr
),
client_
(
client
),
idx_
(
idx
),
:
done_
(
false
),
impl_
(
&
Thread
::
ThreadFunc
,
this
)
{}
new_
(
nullptr
),
client_
(
client
),
idx_
(
idx
),
impl_
(
&
Thread
::
ThreadFunc
,
this
)
{}
~
Thread
()
{
~
Thread
()
{
{
{
...
@@ -215,23 +219,23 @@ class Client {
...
@@ -215,23 +219,23 @@ class Client {
void
ThreadFunc
()
{
void
ThreadFunc
()
{
for
(;;)
{
for
(;;)
{
// run the loop body
// run the loop body
bool
thread_still_ok
=
client_
->
ThreadFunc
(
&
histogram_
,
idx_
);
bool
thread_still_ok
=
client_
->
ThreadFunc
(
&
histogram_
,
idx_
);
// lock, see if we're done
// lock, see if we're done
std
::
lock_guard
<
std
::
mutex
>
g
(
mu_
);
std
::
lock_guard
<
std
::
mutex
>
g
(
mu_
);
if
(
!
thread_still_ok
)
{
if
(
!
thread_still_ok
)
{
gpr_log
(
GPR_ERROR
,
"Finishing client thread due to RPC error"
);
gpr_log
(
GPR_ERROR
,
"Finishing client thread due to RPC error"
);
done_
=
true
;
done_
=
true
;
}
}
if
(
done_
)
{
if
(
done_
)
{
return
;
return
;
}
}
// check if we're marking, swap out the histogram if so
// check if we're marking, swap out the histogram if so
if
(
new_
)
{
if
(
new_
)
{
new_
->
Swap
(
&
histogram_
);
new_
->
Swap
(
&
histogram_
);
new_
=
nullptr
;
new_
=
nullptr
;
cv_
.
notify_one
();
cv_
.
notify_one
();
}
}
}
}
}
}
...
@@ -242,7 +246,7 @@ class Client {
...
@@ -242,7 +246,7 @@ class Client {
bool
done_
;
bool
done_
;
Histogram
*
new_
;
Histogram
*
new_
;
Histogram
histogram_
;
Histogram
histogram_
;
Client
*
client_
;
Client
*
client_
;
size_t
idx_
;
size_t
idx_
;
std
::
thread
impl_
;
std
::
thread
impl_
;
};
};
...
...
This diff is collapsed.
Click to expand it.
test/cpp/qps/client_async.cc
+
23
−
22
View file @
ab1dba72
...
@@ -316,21 +316,25 @@ class AsyncClient : public Client {
...
@@ -316,21 +316,25 @@ class AsyncClient : public Client {
}
}
private
:
private
:
class
boolean
{
// exists only to avoid data-race on vector<bool>
class
boolean
{
// exists only to avoid data-race on vector<bool>
public:
public:
boolean
()
:
val_
(
false
)
{}
boolean
()
:
val_
(
false
)
{}
boolean
(
bool
b
)
:
val_
(
b
)
{}
boolean
(
bool
b
)
:
val_
(
b
)
{}
operator
bool
()
const
{
return
val_
;}
operator
bool
()
const
{
return
val_
;
}
boolean
&
operator
=
(
bool
b
)
{
val_
=
b
;
return
*
this
;}
boolean
&
operator
=
(
bool
b
)
{
val_
=
b
;
return
*
this
;
}
private
:
private
:
bool
val_
;
bool
val_
;
};
};
std
::
vector
<
std
::
unique_ptr
<
CompletionQueue
>>
cli_cqs_
;
std
::
vector
<
std
::
unique_ptr
<
CompletionQueue
>>
cli_cqs_
;
std
::
vector
<
deadline_list
>
rpc_deadlines_
;
// per thread deadlines
std
::
vector
<
deadline_list
>
rpc_deadlines_
;
// per thread deadlines
std
::
vector
<
int
>
next_channel_
;
// per thread round-robin channel ctr
std
::
vector
<
int
>
next_channel_
;
// per thread round-robin channel ctr
std
::
vector
<
boolean
>
issue_allowed_
;
// may this thread attempt to issue
std
::
vector
<
boolean
>
issue_allowed_
;
// may this thread attempt to issue
std
::
vector
<
grpc_time
>
next_issue_
;
// when should it issue?
std
::
vector
<
grpc_time
>
next_issue_
;
// when should it issue?
std
::
vector
<
std
::
mutex
>
channel_lock_
;
std
::
vector
<
std
::
mutex
>
channel_lock_
;
std
::
vector
<
context_list
>
contexts_
;
// per-channel list of idle contexts
std
::
vector
<
context_list
>
contexts_
;
// per-channel list of idle contexts
...
@@ -350,17 +354,15 @@ class AsyncUnaryClient GRPC_FINAL : public AsyncClient {
...
@@ -350,17 +354,15 @@ class AsyncUnaryClient GRPC_FINAL : public AsyncClient {
private
:
private
:
static
void
CheckDone
(
grpc
::
Status
s
,
SimpleResponse
*
response
)
{}
static
void
CheckDone
(
grpc
::
Status
s
,
SimpleResponse
*
response
)
{}
static
std
::
unique_ptr
<
grpc
::
ClientAsyncResponseReader
<
SimpleResponse
>>
static
std
::
unique_ptr
<
grpc
::
ClientAsyncResponseReader
<
SimpleResponse
>>
StartReq
(
TestService
::
Stub
*
stub
,
grpc
::
ClientContext
*
ctx
,
StartReq
(
TestService
::
Stub
*
stub
,
grpc
::
ClientContext
*
ctx
,
const
SimpleRequest
&
request
,
CompletionQueue
*
cq
)
{
const
SimpleRequest
&
request
,
CompletionQueue
*
cq
)
{
return
stub
->
AsyncUnaryCall
(
ctx
,
request
,
cq
);
return
stub
->
AsyncUnaryCall
(
ctx
,
request
,
cq
);
};
};
static
ClientRpcContext
*
SetupCtx
(
int
channel_id
,
TestService
::
Stub
*
stub
,
static
ClientRpcContext
*
SetupCtx
(
int
channel_id
,
TestService
::
Stub
*
stub
,
const
SimpleRequest
&
req
)
{
const
SimpleRequest
&
req
)
{
return
new
return
new
ClientRpcContextUnaryImpl
<
SimpleRequest
,
SimpleResponse
>
(
ClientRpcContextUnaryImpl
<
SimpleRequest
,
channel_id
,
stub
,
req
,
AsyncUnaryClient
::
StartReq
,
SimpleResponse
>
(
channel_id
,
stub
,
req
,
AsyncUnaryClient
::
CheckDone
);
AsyncUnaryClient
::
StartReq
,
AsyncUnaryClient
::
CheckDone
);
}
}
};
};
...
@@ -447,19 +449,18 @@ class AsyncStreamingClient GRPC_FINAL : public AsyncClient {
...
@@ -447,19 +449,18 @@ class AsyncStreamingClient GRPC_FINAL : public AsyncClient {
private
:
private
:
static
void
CheckDone
(
grpc
::
Status
s
,
SimpleResponse
*
response
)
{}
static
void
CheckDone
(
grpc
::
Status
s
,
SimpleResponse
*
response
)
{}
static
std
::
unique_ptr
<
grpc
::
ClientAsyncReaderWriter
<
static
std
::
unique_ptr
<
SimpleRequest
,
SimpleResponse
>>
grpc
::
ClientAsyncReaderWriter
<
SimpleRequest
,
SimpleResponse
>>
StartReq
(
TestService
::
Stub
*
stub
,
grpc
::
ClientContext
*
ctx
,
StartReq
(
TestService
::
Stub
*
stub
,
grpc
::
ClientContext
*
ctx
,
CompletionQueue
*
cq
,
void
*
tag
)
{
CompletionQueue
*
cq
,
void
*
tag
)
{
auto
stream
=
stub
->
AsyncStreamingCall
(
ctx
,
cq
,
tag
);
auto
stream
=
stub
->
AsyncStreamingCall
(
ctx
,
cq
,
tag
);
return
stream
;
return
stream
;
};
};
static
ClientRpcContext
*
SetupCtx
(
int
channel_id
,
TestService
::
Stub
*
stub
,
static
ClientRpcContext
*
SetupCtx
(
int
channel_id
,
TestService
::
Stub
*
stub
,
const
SimpleRequest
&
req
)
{
const
SimpleRequest
&
req
)
{
return
new
ClientRpcContextStreamingImpl
<
SimpleRequest
,
SimpleResponse
>
(
return
new
ClientRpcContextStreamingImpl
<
SimpleRequest
,
SimpleResponse
>
(
channel_id
,
stub
,
req
,
channel_id
,
stub
,
req
,
AsyncStreamingClient
::
StartReq
,
AsyncStreamingClient
::
StartReq
,
AsyncStreamingClient
::
CheckDone
);
AsyncStreamingClient
::
CheckDone
);
}
}
};
};
...
...
This diff is collapsed.
Click to expand it.
test/cpp/qps/interarrival.h
+
2
−
2
View file @
ab1dba72
...
@@ -150,8 +150,8 @@ class InterarrivalTimer {
...
@@ -150,8 +150,8 @@ class InterarrivalTimer {
// rand is the only choice that is portable across POSIX and Windows
// rand is the only choice that is portable across POSIX and Windows
// and that supports new and old compilers
// and that supports new and old compilers
double
uniform_0_1
=
rand
()
/
RAND_MAX
;
double
uniform_0_1
=
rand
()
/
RAND_MAX
;
random_table_
.
push_back
(
std
::
chrono
::
nanoseconds
(
random_table_
.
push_back
(
static_cast
<
int64_t
>
(
1e9
*
r
(
uniform_0_1
))));
std
::
chrono
::
nanoseconds
(
static_cast
<
int64_t
>
(
1e9
*
r
(
uniform_0_1
))));
}
}
// Now set up the thread positions
// Now set up the thread positions
for
(
int
i
=
0
;
i
<
threads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
threads
;
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