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
7e1d5178
Commit
7e1d5178
authored
8 years ago
by
Craig Tiller
Browse files
Options
Downloads
Plain Diff
Merge branch 'bm_call_create' into deadline_mu
parents
50b6ec2e
385b0093
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/microbenchmarks/bm_call_create.cc
+63
-89
63 additions, 89 deletions
test/cpp/microbenchmarks/bm_call_create.cc
tools/profiling/microbenchmarks/bm2bq.py
+5
-1
5 additions, 1 deletion
tools/profiling/microbenchmarks/bm2bq.py
with
68 additions
and
90 deletions
test/cpp/microbenchmarks/bm_call_create.cc
+
63
−
89
View file @
7e1d5178
...
@@ -74,6 +74,7 @@ static void BM_InsecureChannelWithDefaults(benchmark::State &state) {
...
@@ -74,6 +74,7 @@ static void BM_InsecureChannelWithDefaults(benchmark::State &state) {
method
,
NULL
,
deadline
,
NULL
));
method
,
NULL
,
deadline
,
NULL
));
}
}
grpc_channel_destroy
(
channel
);
grpc_channel_destroy
(
channel
);
grpc_completion_queue_destroy
(
cq
);
}
}
BENCHMARK
(
BM_InsecureChannelWithDefaults
);
BENCHMARK
(
BM_InsecureChannelWithDefaults
);
...
@@ -244,64 +245,50 @@ static grpc_transport dummy_transport = {&dummy_transport_vtable};
...
@@ -244,64 +245,50 @@ static grpc_transport dummy_transport = {&dummy_transport_vtable};
}
// namespace dummy_transport
}
// namespace dummy_transport
template
<
class
Fixture
>
class
NoOp
{
static
void
BM_FilterInitDestroy
(
benchmark
::
State
&
state
)
{
public:
Fixture
fixture
;
class
Op
{
std
::
ostringstream
label
;
public:
Op
(
grpc_exec_ctx
*
exec_ctx
,
NoOp
*
p
,
grpc_call_stack
*
s
)
{}
std
::
vector
<
grpc_arg
>
args
;
void
Finish
(
grpc_exec_ctx
*
exec_ctx
)
{}
FakeClientChannelFactory
fake_client_channel_factory
;
};
args
.
push_back
(
grpc_client_channel_factory_create_channel_arg
(
};
&
fake_client_channel_factory
));
args
.
push_back
(
StringArg
(
GRPC_ARG_SERVER_URI
,
"localhost"
));
grpc_channel_args
channel_args
=
{
args
.
size
(),
&
args
[
0
]};
std
::
vector
<
const
grpc_channel_filter
*>
filters
;
class
SendEmptyMetadata
{
if
(
fixture
.
filter
!=
nullptr
)
{
public:
filters
.
push_back
(
fixture
.
filter
);
SendEmptyMetadata
()
{
}
memset
(
&
op_
,
0
,
sizeof
(
op_
));
if
(
fixture
.
flags
&
CHECKS_NOT_LAST
)
{
op_
.
on_complete
=
grpc_closure_init
(
&
closure_
,
DoNothing
,
nullptr
,
filters
.
push_back
(
&
dummy_filter
::
dummy_filter
);
grpc_schedule_on_exec_ctx
);
label
<<
" has_dummy_filter"
;
}
}
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
class
Op
{
size_t
channel_size
=
grpc_channel_stack_size
(
&
filters
[
0
],
filters
.
size
());
public:
grpc_channel_stack
*
channel_stack
=
Op
(
grpc_exec_ctx
*
exec_ctx
,
SendEmptyMetadata
*
p
,
grpc_call_stack
*
s
)
{
static_cast
<
grpc_channel_stack
*>
(
gpr_malloc
(
channel_size
));
grpc_metadata_batch_init
(
&
batch_
);
GPR_ASSERT
(
GRPC_LOG_IF_ERROR
(
p
->
op_
.
send_initial_metadata
=
&
batch_
;
"call_stack_init"
,
}
grpc_channel_stack_init
(
&
exec_ctx
,
1
,
FilterDestroy
,
channel_stack
,
void
Finish
(
grpc_exec_ctx
*
exec_ctx
)
{
&
filters
[
0
],
filters
.
size
(),
&
channel_args
,
grpc_metadata_batch_destroy
(
exec_ctx
,
&
batch_
);
fixture
.
flags
&
REQUIRES_TRANSPORT
}
?
&
dummy_transport
::
dummy_transport
:
nullptr
,
"CHANNEL"
,
channel_stack
)));
grpc_exec_ctx_flush
(
&
exec_ctx
);
grpc_call_stack
*
call_stack
=
static_cast
<
grpc_call_stack
*>
(
gpr_malloc
(
channel_stack
->
call_stack_size
));
gpr_timespec
deadline
=
gpr_inf_future
(
GPR_CLOCK_MONOTONIC
);
gpr_timespec
start_time
=
gpr_now
(
GPR_CLOCK_MONOTONIC
);
grpc_slice
method
=
grpc_slice_from_static_string
(
"/foo/bar"
);
grpc_call_final_info
final_info
;
while
(
state
.
KeepRunning
())
{
GRPC_ERROR_UNREF
(
grpc_call_stack_init
(
&
exec_ctx
,
channel_stack
,
1
,
DoNothing
,
NULL
,
NULL
,
NULL
,
method
,
start_time
,
deadline
,
call_stack
));
grpc_call_stack_destroy
(
&
exec_ctx
,
call_stack
,
&
final_info
,
NULL
);
grpc_exec_ctx_flush
(
&
exec_ctx
);
}
grpc_channel_stack_destroy
(
&
exec_ctx
,
channel_stack
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
gpr_free
(
channel_stack
);
state
.
SetLabel
(
label
.
str
());
private
:
}
grpc_metadata_batch
batch_
;
};
private
:
const
gpr_timespec
deadline_
=
gpr_inf_future
(
GPR_CLOCK_MONOTONIC
);
const
gpr_timespec
start_time_
=
gpr_now
(
GPR_CLOCK_MONOTONIC
);
const
grpc_slice
method_
=
grpc_slice_from_static_string
(
"/foo/bar"
);
grpc_transport_stream_op
op_
;
grpc_closure
closure_
;
};
template
<
class
Fixture
>
// Test a filter in isolation. Fixture specifies the filter under test (use the
static
void
BM_FilterInitSendInitialMetadataThenDestroy
(
// Fixture<> template to specify this), and TestOp defines some unit of work to
benchmark
::
State
&
state
)
{
// perform on said filter.
template
<
class
Fixture
,
class
TestOp
>
static
void
BM_IsolatedFilter
(
benchmark
::
State
&
state
)
{
Fixture
fixture
;
Fixture
fixture
;
std
::
ostringstream
label
;
std
::
ostringstream
label
;
...
@@ -319,7 +306,7 @@ static void BM_FilterInitSendInitialMetadataThenDestroy(
...
@@ -319,7 +306,7 @@ static void BM_FilterInitSendInitialMetadataThenDestroy(
}
}
if
(
fixture
.
flags
&
CHECKS_NOT_LAST
)
{
if
(
fixture
.
flags
&
CHECKS_NOT_LAST
)
{
filters
.
push_back
(
&
dummy_filter
::
dummy_filter
);
filters
.
push_back
(
&
dummy_filter
::
dummy_filter
);
label
<<
" has_dummy_filter"
;
label
<<
"
#
has_dummy_filter"
;
}
}
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
...
@@ -341,68 +328,55 @@ static void BM_FilterInitSendInitialMetadataThenDestroy(
...
@@ -341,68 +328,55 @@ static void BM_FilterInitSendInitialMetadataThenDestroy(
gpr_timespec
start_time
=
gpr_now
(
GPR_CLOCK_MONOTONIC
);
gpr_timespec
start_time
=
gpr_now
(
GPR_CLOCK_MONOTONIC
);
grpc_slice
method
=
grpc_slice_from_static_string
(
"/foo/bar"
);
grpc_slice
method
=
grpc_slice_from_static_string
(
"/foo/bar"
);
grpc_call_final_info
final_info
;
grpc_call_final_info
final_info
;
grpc_transport_stream_op
op
;
TestOp
test_op_data
;
memset
(
&
op
,
0
,
sizeof
(
op
));
grpc_closure
closure
;
op
.
on_complete
=
grpc_closure_init
(
&
closure
,
DoNothing
,
nullptr
,
grpc_schedule_on_exec_ctx
);
while
(
state
.
KeepRunning
())
{
while
(
state
.
KeepRunning
())
{
grpc_metadata_batch
batch
;
grpc_metadata_batch_init
(
&
batch
);
op
.
send_initial_metadata
=
&
batch
;
GRPC_ERROR_UNREF
(
grpc_call_stack_init
(
&
exec_ctx
,
channel_stack
,
1
,
GRPC_ERROR_UNREF
(
grpc_call_stack_init
(
&
exec_ctx
,
channel_stack
,
1
,
DoNothing
,
NULL
,
NULL
,
NULL
,
method
,
DoNothing
,
NULL
,
NULL
,
NULL
,
method
,
start_time
,
deadline
,
call_stack
));
start_time
,
deadline
,
call_stack
));
auto
elem
=
grpc_call_stack_element
(
call_stack
,
0
);
typename
TestOp
::
Op
op
(
&
exec_ctx
,
&
test_op_data
,
call_stack
);
elem
->
filter
->
start_transport_stream_op
(
&
exec_ctx
,
elem
,
&
op
);
grpc_call_stack_destroy
(
&
exec_ctx
,
call_stack
,
&
final_info
,
NULL
);
grpc_call_stack_destroy
(
&
exec_ctx
,
call_stack
,
&
final_info
,
NULL
);
grpc_metadata_batch_destroy
(
&
exec_ctx
,
&
batch
);
op
.
Finish
(
&
exec_ctx
);
grpc_exec_ctx_flush
(
&
exec_ctx
);
grpc_exec_ctx_flush
(
&
exec_ctx
);
}
}
grpc_channel_stack_destroy
(
&
exec_ctx
,
channel_stack
);
grpc_channel_stack_destroy
(
&
exec_ctx
,
channel_stack
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
gpr_free
(
channel_stack
);
gpr_free
(
channel_stack
);
gpr_free
(
call_stack
);
state
.
SetLabel
(
label
.
str
());
state
.
SetLabel
(
label
.
str
());
}
}
typedef
Fixture
<
nullptr
,
0
>
NoFilter
;
typedef
Fixture
<
nullptr
,
0
>
NoFilter
;
BENCHMARK_TEMPLATE
(
BM_
FilterInitDestroy
,
NoFilter
);
BENCHMARK_TEMPLATE
(
BM_
IsolatedFilter
,
NoFilter
,
NoOp
);
typedef
Fixture
<&
dummy_filter
::
dummy_filter
,
0
>
DummyFilter
;
typedef
Fixture
<&
dummy_filter
::
dummy_filter
,
0
>
DummyFilter
;
BENCHMARK_TEMPLATE
(
BM_
FilterInitDestroy
,
DummyFilter
);
BENCHMARK_TEMPLATE
(
BM_
IsolatedFilter
,
DummyFilter
,
NoOp
);
BENCHMARK_TEMPLATE
(
BM_
FilterInitSendInitialMetadataThenDestroy
,
DummyFilter
);
BENCHMARK_TEMPLATE
(
BM_
IsolatedFilter
,
DummyFilter
,
SendEmptyMetadata
);
typedef
Fixture
<&
grpc_client_channel_filter
,
0
>
ClientChannelFilter
;
typedef
Fixture
<&
grpc_client_channel_filter
,
0
>
ClientChannelFilter
;
BENCHMARK_TEMPLATE
(
BM_
FilterInitDestroy
,
ClientChannelFilter
);
BENCHMARK_TEMPLATE
(
BM_
IsolatedFilter
,
ClientChannelFilter
,
NoOp
);
typedef
Fixture
<&
grpc_compress_filter
,
CHECKS_NOT_LAST
>
CompressFilter
;
typedef
Fixture
<&
grpc_compress_filter
,
CHECKS_NOT_LAST
>
CompressFilter
;
BENCHMARK_TEMPLATE
(
BM_
FilterInitDestroy
,
CompressFilter
);
BENCHMARK_TEMPLATE
(
BM_
IsolatedFilter
,
CompressFilter
,
NoOp
);
BENCHMARK_TEMPLATE
(
BM_
FilterInitSendInitialMetadataThenDestroy
,
CompressFilter
);
BENCHMARK_TEMPLATE
(
BM_
IsolatedFilter
,
CompressFilter
,
SendEmptyMetadata
);
typedef
Fixture
<&
grpc_client_deadline_filter
,
CHECKS_NOT_LAST
>
typedef
Fixture
<&
grpc_client_deadline_filter
,
CHECKS_NOT_LAST
>
ClientDeadlineFilter
;
ClientDeadlineFilter
;
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
ClientDeadlineFilter
);
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
ClientDeadlineFilter
,
NoOp
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
ClientDeadlineFilter
,
SendEmptyMetadata
);
ClientDeadlineFilter
);
typedef
Fixture
<&
grpc_server_deadline_filter
,
CHECKS_NOT_LAST
>
typedef
Fixture
<&
grpc_server_deadline_filter
,
CHECKS_NOT_LAST
>
ServerDeadlineFilter
;
ServerDeadlineFilter
;
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
ServerDeadlineFilter
);
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
ServerDeadlineFilter
,
NoOp
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
ServerDeadlineFilter
,
SendEmptyMetadata
);
ServerDeadlineFilter
);
typedef
Fixture
<&
grpc_http_client_filter
,
CHECKS_NOT_LAST
|
REQUIRES_TRANSPORT
>
typedef
Fixture
<&
grpc_http_client_filter
,
CHECKS_NOT_LAST
|
REQUIRES_TRANSPORT
>
HttpClientFilter
;
HttpClientFilter
;
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
HttpClientFilter
);
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
HttpClientFilter
,
NoOp
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
HttpClientFilter
,
SendEmptyMetadata
);
HttpClientFilter
);
typedef
Fixture
<&
grpc_http_server_filter
,
CHECKS_NOT_LAST
>
HttpServerFilter
;
typedef
Fixture
<&
grpc_http_server_filter
,
CHECKS_NOT_LAST
>
HttpServerFilter
;
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
HttpServerFilter
);
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
HttpServerFilter
,
NoOp
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
HttpServerFilter
,
SendEmptyMetadata
);
HttpServerFilter
);
typedef
Fixture
<&
grpc_message_size_filter
,
CHECKS_NOT_LAST
>
MessageSizeFilter
;
typedef
Fixture
<&
grpc_message_size_filter
,
CHECKS_NOT_LAST
>
MessageSizeFilter
;
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
MessageSizeFilter
);
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
MessageSizeFilter
,
NoOp
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
MessageSizeFilter
,
SendEmptyMetadata
);
MessageSizeFilter
);
typedef
Fixture
<&
grpc_load_reporting_filter
,
CHECKS_NOT_LAST
>
typedef
Fixture
<&
grpc_load_reporting_filter
,
CHECKS_NOT_LAST
>
LoadReportingFilter
;
LoadReportingFilter
;
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
LoadReportingFilter
);
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
LoadReportingFilter
,
NoOp
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
BENCHMARK_TEMPLATE
(
BM_IsolatedFilter
,
LoadReportingFilter
,
SendEmptyMetadata
);
LoadReportingFilter
);
BENCHMARK_MAIN
();
BENCHMARK_MAIN
();
This diff is collapsed.
Click to expand it.
tools/profiling/microbenchmarks/bm2bq.py
+
5
−
1
View file @
7e1d5178
...
@@ -104,6 +104,10 @@ bm_specs = {
...
@@ -104,6 +104,10 @@ bm_specs = {
'
tpl
'
:
[],
'
tpl
'
:
[],
'
dyn
'
:
[
'
request_size
'
,
'
bandwidth_kilobits
'
],
'
dyn
'
:
[
'
request_size
'
,
'
bandwidth_kilobits
'
],
},
},
'
BM_IsolatedFilter
'
:
{
'
tpl
'
:
[
'
fixture
'
,
'
client_mutator
'
],
'
dyn
'
:
[],
}
}
}
def
numericalize
(
s
):
def
numericalize
(
s
):
...
@@ -160,7 +164,7 @@ def parse_name(name):
...
@@ -160,7 +164,7 @@ def parse_name(name):
for
bm
in
js
[
'
benchmarks
'
]:
for
bm
in
js
[
'
benchmarks
'
]:
context
=
js
[
'
context
'
]
context
=
js
[
'
context
'
]
if
'
label
'
in
bm
:
if
'
label
'
in
bm
:
labels_list
=
[
s
.
split
(
'
:
'
)
for
s
in
bm
[
'
label
'
].
strip
().
split
(
'
'
)]
labels_list
=
[
s
.
split
(
'
:
'
)
for
s
in
bm
[
'
label
'
].
strip
().
split
(
'
'
)
if
len
(
s
)
and
s
[
0
]
!=
'
#
'
]
for
el
in
labels_list
:
for
el
in
labels_list
:
el
[
0
]
=
el
[
0
].
replace
(
'
/iter
'
,
'
_per_iteration
'
)
el
[
0
]
=
el
[
0
].
replace
(
'
/iter
'
,
'
_per_iteration
'
)
labels
=
dict
(
labels_list
)
labels
=
dict
(
labels_list
)
...
...
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