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
f921f2be
Commit
f921f2be
authored
8 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Plain Diff
Merge pull request #6305 from dgquintas/compression_tracer
Added compression tracer
parents
91cda8ff
cce51fe5
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
src/core/lib/channel/compress_filter.c
+22
-0
22 additions, 0 deletions
src/core/lib/channel/compress_filter.c
src/core/lib/channel/compress_filter.h
+2
-0
2 additions, 0 deletions
src/core/lib/channel/compress_filter.h
src/core/lib/surface/init.c
+1
-0
1 addition, 0 deletions
src/core/lib/surface/init.c
with
25 additions
and
0 deletions
src/core/lib/channel/compress_filter.c
+
22
−
0
View file @
f921f2be
...
...
@@ -47,6 +47,8 @@
#include
"src/core/lib/support/string.h"
#include
"src/core/lib/transport/static_metadata.h"
int
grpc_compress_filter_trace
=
0
;
typedef
struct
call_data
{
gpr_slice_buffer
slices
;
/**< Buffers up input slices to be compressed */
grpc_linked_mdelem
compression_algorithm_storage
;
...
...
@@ -169,9 +171,29 @@ static void finish_send_message(grpc_exec_ctx *exec_ctx,
did_compress
=
grpc_msg_compress
(
calld
->
compression_algorithm
,
&
calld
->
slices
,
&
tmp
);
if
(
did_compress
)
{
if
(
grpc_compress_filter_trace
)
{
char
*
algo_name
;
const
size_t
before_size
=
calld
->
slices
.
length
;
const
size_t
after_size
=
tmp
.
length
;
const
float
savings_ratio
=
1
.
0
f
-
(
float
)
after_size
/
(
float
)
before_size
;
GPR_ASSERT
(
grpc_compression_algorithm_name
(
calld
->
compression_algorithm
,
&
algo_name
));
gpr_log
(
GPR_DEBUG
,
"Compressed[%s] %d bytes vs. %d bytes (%.2f%% savings)"
,
algo_name
,
before_size
,
after_size
,
100
*
savings_ratio
);
}
gpr_slice_buffer_swap
(
&
calld
->
slices
,
&
tmp
);
calld
->
send_flags
|=
GRPC_WRITE_INTERNAL_COMPRESS
;
}
else
{
if
(
grpc_compress_filter_trace
)
{
char
*
algo_name
;
GPR_ASSERT
(
grpc_compression_algorithm_name
(
calld
->
compression_algorithm
,
&
algo_name
));
gpr_log
(
GPR_DEBUG
,
"Algorithm '%s' enabled but decided not to compress."
,
algo_name
);
}
}
gpr_slice_buffer_destroy
(
&
tmp
);
grpc_slice_buffer_stream_init
(
&
calld
->
replacement_stream
,
&
calld
->
slices
,
...
...
This diff is collapsed.
Click to expand it.
src/core/lib/channel/compress_filter.h
+
2
−
0
View file @
f921f2be
...
...
@@ -38,6 +38,8 @@
#define GRPC_COMPRESS_REQUEST_ALGORITHM_KEY "grpc-internal-encoding-request"
extern
int
grpc_compress_filter_trace
;
/** Compression filter for outgoing data.
*
* See <grpc/compression.h> for the available compression settings.
...
...
This diff is collapsed.
Click to expand it.
src/core/lib/surface/init.c
+
1
−
0
View file @
f921f2be
...
...
@@ -164,6 +164,7 @@ void grpc_init(void) {
grpc_register_tracer
(
"channel_stack_builder"
,
&
grpc_trace_channel_stack_builder
);
grpc_register_tracer
(
"http1"
,
&
grpc_http1_trace
);
grpc_register_tracer
(
"compression"
,
&
grpc_compress_filter_trace
);
grpc_security_pre_init
();
grpc_iomgr_init
();
grpc_executor_init
();
...
...
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