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
0ea6b435
Commit
0ea6b435
authored
10 years ago
by
Vijay Pai
Browse files
Options
Downloads
Plain Diff
Merge pull request #324 from ctiller/bench
Add pprof support to qps client, server
parents
d2f2e8ec
056ba544
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/cpp/qps/client.cc
+6
-0
6 additions, 0 deletions
test/cpp/qps/client.cc
test/cpp/qps/server.cc
+22
-4
22 additions, 4 deletions
test/cpp/qps/server.cc
with
28 additions
and
4 deletions
test/cpp/qps/client.cc
+
6
−
0
View file @
0ea6b435
...
@@ -44,6 +44,7 @@
...
@@ -44,6 +44,7 @@
#include
<google/gflags.h>
#include
<google/gflags.h>
#include
<grpc++/client_context.h>
#include
<grpc++/client_context.h>
#include
<grpc++/status.h>
#include
<grpc++/status.h>
#include
"test/core/util/grpc_profiler.h"
#include
"test/cpp/util/create_test_channel.h"
#include
"test/cpp/util/create_test_channel.h"
#include
"test/cpp/qps/qpstest.pb.h"
#include
"test/cpp/qps/qpstest.pb.h"
...
@@ -129,6 +130,8 @@ void RunTest(const int client_threads, const int client_channels,
...
@@ -129,6 +130,8 @@ void RunTest(const int client_threads, const int client_channels,
grpc
::
Status
status_beg
=
stub_stats
->
CollectServerStats
(
grpc
::
Status
status_beg
=
stub_stats
->
CollectServerStats
(
&
context_stats_begin
,
stats_request
,
&
server_stats_begin
);
&
context_stats_begin
,
stats_request
,
&
server_stats_begin
);
grpc_profiler_start
(
"qps_client.prof"
);
for
(
int
i
=
0
;
i
<
client_threads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
client_threads
;
i
++
)
{
gpr_histogram
*
hist
=
gpr_histogram_create
(
0.01
,
60e9
);
gpr_histogram
*
hist
=
gpr_histogram_create
(
0.01
,
60e9
);
GPR_ASSERT
(
hist
!=
NULL
);
GPR_ASSERT
(
hist
!=
NULL
);
...
@@ -172,6 +175,9 @@ void RunTest(const int client_threads, const int client_channels,
...
@@ -172,6 +175,9 @@ void RunTest(const int client_threads, const int client_channels,
for
(
auto
&
t
:
threads
)
{
for
(
auto
&
t
:
threads
)
{
t
.
join
();
t
.
join
();
}
}
grpc_profiler_stop
();
for
(
int
i
=
0
;
i
<
client_threads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
client_threads
;
i
++
)
{
gpr_histogram
*
h
=
thread_stats
[
i
];
gpr_histogram
*
h
=
thread_stats
[
i
];
gpr_log
(
GPR_INFO
,
"latency at thread %d (50/90/95/99/99.9): %f/%f/%f/%f/%f"
,
gpr_log
(
GPR_INFO
,
"latency at thread %d (50/90/95/99/99.9): %f/%f/%f/%f/%f"
,
...
...
This diff is collapsed.
Click to expand it.
test/cpp/qps/server.cc
+
22
−
4
View file @
0ea6b435
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include
<sys/time.h>
#include
<sys/time.h>
#include
<sys/resource.h>
#include
<sys/resource.h>
#include
<sys/signal.h>
#include
<thread>
#include
<thread>
#include
<google/gflags.h>
#include
<google/gflags.h>
...
@@ -43,6 +44,7 @@
...
@@ -43,6 +44,7 @@
#include
<grpc++/server_builder.h>
#include
<grpc++/server_builder.h>
#include
<grpc++/server_context.h>
#include
<grpc++/server_context.h>
#include
<grpc++/status.h>
#include
<grpc++/status.h>
#include
"test/core/util/grpc_profiler.h"
#include
"test/cpp/qps/qpstest.pb.h"
#include
"test/cpp/qps/qpstest.pb.h"
#include
<grpc/grpc.h>
#include
<grpc/grpc.h>
...
@@ -63,11 +65,15 @@ using grpc::testing::StatsRequest;
...
@@ -63,11 +65,15 @@ using grpc::testing::StatsRequest;
using
grpc
::
testing
::
TestService
;
using
grpc
::
testing
::
TestService
;
using
grpc
::
Status
;
using
grpc
::
Status
;
static
bool
got_sigint
=
false
;
static
void
sigint_handler
(
int
x
)
{
got_sigint
=
1
;
}
static
double
time_double
(
struct
timeval
*
tv
)
{
static
double
time_double
(
struct
timeval
*
tv
)
{
return
tv
->
tv_sec
+
1e-6
*
tv
->
tv_usec
;
return
tv
->
tv_sec
+
1e-6
*
tv
->
tv_usec
;
}
}
bool
SetPayload
(
PayloadType
type
,
int
size
,
Payload
*
payload
)
{
static
bool
SetPayload
(
PayloadType
type
,
int
size
,
Payload
*
payload
)
{
PayloadType
response_type
=
type
;
PayloadType
response_type
=
type
;
// TODO(yangg): Support UNCOMPRESSABLE payload.
// TODO(yangg): Support UNCOMPRESSABLE payload.
if
(
type
!=
PayloadType
::
COMPRESSABLE
)
{
if
(
type
!=
PayloadType
::
COMPRESSABLE
)
{
...
@@ -79,7 +85,9 @@ bool SetPayload(PayloadType type, int size, Payload* payload) {
...
@@ -79,7 +85,9 @@ bool SetPayload(PayloadType type, int size, Payload* payload) {
return
true
;
return
true
;
}
}
class
TestServiceImpl
:
public
TestService
::
Service
{
namespace
{
class
TestServiceImpl
final
:
public
TestService
::
Service
{
public:
public:
Status
CollectServerStats
(
ServerContext
*
context
,
const
StatsRequest
*
,
Status
CollectServerStats
(
ServerContext
*
context
,
const
StatsRequest
*
,
ServerStats
*
response
)
{
ServerStats
*
response
)
{
...
@@ -104,7 +112,9 @@ class TestServiceImpl : public TestService::Service {
...
@@ -104,7 +112,9 @@ class TestServiceImpl : public TestService::Service {
}
}
};
};
void
RunServer
()
{
}
// namespace
static
void
RunServer
()
{
char
*
server_address
=
NULL
;
char
*
server_address
=
NULL
;
gpr_join_host_port
(
&
server_address
,
"::"
,
FLAGS_port
);
gpr_join_host_port
(
&
server_address
,
"::"
,
FLAGS_port
);
...
@@ -118,10 +128,15 @@ void RunServer() {
...
@@ -118,10 +128,15 @@ void RunServer() {
builder
.
RegisterService
(
service
.
service
());
builder
.
RegisterService
(
service
.
service
());
std
::
unique_ptr
<
Server
>
server
(
builder
.
BuildAndStart
());
std
::
unique_ptr
<
Server
>
server
(
builder
.
BuildAndStart
());
gpr_log
(
GPR_INFO
,
"Server listening on %s
\n
"
,
server_address
);
gpr_log
(
GPR_INFO
,
"Server listening on %s
\n
"
,
server_address
);
while
(
true
)
{
grpc_profiler_start
(
"qps_server.prof"
);
while
(
!
got_sigint
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
5
));
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
5
));
}
}
grpc_profiler_stop
();
gpr_free
(
server_address
);
gpr_free
(
server_address
);
}
}
...
@@ -129,6 +144,8 @@ int main(int argc, char** argv) {
...
@@ -129,6 +144,8 @@ int main(int argc, char** argv) {
grpc_init
();
grpc_init
();
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
signal
(
SIGINT
,
sigint_handler
);
GPR_ASSERT
(
FLAGS_port
!=
0
);
GPR_ASSERT
(
FLAGS_port
!=
0
);
GPR_ASSERT
(
!
FLAGS_enable_ssl
);
GPR_ASSERT
(
!
FLAGS_enable_ssl
);
RunServer
();
RunServer
();
...
@@ -136,3 +153,4 @@ int main(int argc, char** argv) {
...
@@ -136,3 +153,4 @@ int main(int argc, char** argv) {
grpc_shutdown
();
grpc_shutdown
();
return
0
;
return
0
;
}
}
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