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
4f60fbf1
Commit
4f60fbf1
authored
8 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Add initial metadata benchmarks
parent
3a04debe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cpp/microbenchmarks/bm_call_create.cc
+83
-1
83 additions, 1 deletion
test/cpp/microbenchmarks/bm_call_create.cc
with
83 additions
and
1 deletion
test/cpp/microbenchmarks/bm_call_create.cc
+
83
−
1
View file @
4f60fbf1
...
@@ -208,7 +208,9 @@ void SetPollsetSet(grpc_exec_ctx *exec_ctx, grpc_transport *self,
...
@@ -208,7 +208,9 @@ void SetPollsetSet(grpc_exec_ctx *exec_ctx, grpc_transport *self,
/* implementation of grpc_transport_perform_stream_op */
/* implementation of grpc_transport_perform_stream_op */
void
PerformStreamOp
(
grpc_exec_ctx
*
exec_ctx
,
grpc_transport
*
self
,
void
PerformStreamOp
(
grpc_exec_ctx
*
exec_ctx
,
grpc_transport
*
self
,
grpc_stream
*
stream
,
grpc_transport_stream_op
*
op
)
{}
grpc_stream
*
stream
,
grpc_transport_stream_op
*
op
)
{
grpc_closure_sched
(
exec_ctx
,
op
->
on_complete
,
GRPC_ERROR_NONE
);
}
/* implementation of grpc_transport_perform_op */
/* implementation of grpc_transport_perform_op */
void
PerformOp
(
grpc_exec_ctx
*
exec_ctx
,
grpc_transport
*
self
,
void
PerformOp
(
grpc_exec_ctx
*
exec_ctx
,
grpc_transport
*
self
,
...
@@ -295,29 +297,109 @@ static void BM_FilterInitDestroy(benchmark::State &state) {
...
@@ -295,29 +297,109 @@ static void BM_FilterInitDestroy(benchmark::State &state) {
state
.
SetLabel
(
label
.
str
());
state
.
SetLabel
(
label
.
str
());
}
}
template
<
class
Fixture
>
static
void
BM_FilterInitSendInitialMetadataThenDestroy
(
benchmark
::
State
&
state
)
{
Fixture
fixture
;
std
::
ostringstream
label
;
std
::
vector
<
grpc_arg
>
args
;
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
;
if
(
fixture
.
filter
!=
nullptr
)
{
filters
.
push_back
(
fixture
.
filter
);
}
if
(
fixture
.
flags
&
CHECKS_NOT_LAST
)
{
filters
.
push_back
(
&
dummy_filter
::
dummy_filter
);
label
<<
" has_dummy_filter"
;
}
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
size_t
channel_size
=
grpc_channel_stack_size
(
&
filters
[
0
],
filters
.
size
());
grpc_channel_stack
*
channel_stack
=
static_cast
<
grpc_channel_stack
*>
(
gpr_malloc
(
channel_size
));
GPR_ASSERT
(
GRPC_LOG_IF_ERROR
(
"call_stack_init"
,
grpc_channel_stack_init
(
&
exec_ctx
,
1
,
FilterDestroy
,
channel_stack
,
&
filters
[
0
],
filters
.
size
(),
&
channel_args
,
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
;
grpc_transport_stream_op
op
;
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
())
{
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
,
DoNothing
,
NULL
,
NULL
,
NULL
,
method
,
start_time
,
deadline
,
call_stack
));
auto
elem
=
grpc_call_stack_element
(
call_stack
,
0
);
elem
->
filter
->
start_transport_stream_op
(
&
exec_ctx
,
elem
,
&
op
);
grpc_call_stack_destroy
(
&
exec_ctx
,
call_stack
,
&
final_info
,
NULL
);
grpc_metadata_batch_destroy
(
&
exec_ctx
,
&
batch
);
grpc_exec_ctx_flush
(
&
exec_ctx
);
}
grpc_channel_stack_destroy
(
&
exec_ctx
,
channel_stack
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
state
.
SetLabel
(
label
.
str
());
}
typedef
Fixture
<
nullptr
,
0
>
NoFilter
;
typedef
Fixture
<
nullptr
,
0
>
NoFilter
;
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
NoFilter
);
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
NoFilter
);
typedef
Fixture
<&
dummy_filter
::
dummy_filter
,
0
>
DummyFilter
;
typedef
Fixture
<&
dummy_filter
::
dummy_filter
,
0
>
DummyFilter
;
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
DummyFilter
);
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
DummyFilter
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
DummyFilter
);
typedef
Fixture
<&
grpc_client_channel_filter
,
0
>
ClientChannelFilter
;
typedef
Fixture
<&
grpc_client_channel_filter
,
0
>
ClientChannelFilter
;
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
ClientChannelFilter
);
BENCHMARK_TEMPLATE
(
BM_FilterInitDestroy
,
ClientChannelFilter
);
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_FilterInitDestroy
,
CompressFilter
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
CompressFilter
);
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_FilterInitDestroy
,
ClientDeadlineFilter
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
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_FilterInitDestroy
,
ServerDeadlineFilter
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
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_FilterInitDestroy
,
HttpClientFilter
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
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_FilterInitDestroy
,
HttpServerFilter
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
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_FilterInitDestroy
,
MessageSizeFilter
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
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_FilterInitDestroy
,
LoadReportingFilter
);
BENCHMARK_TEMPLATE
(
BM_FilterInitSendInitialMetadataThenDestroy
,
LoadReportingFilter
);
BENCHMARK_MAIN
();
BENCHMARK_MAIN
();
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