@ -32,7 +32,6 @@
# include <grpc/grpc.h>
# include <grpc/grpc.h>
# include <grpc/impl/channel_arg_names.h>
# include <grpc/impl/channel_arg_names.h>
# include <grpc/impl/compression_types.h>
# include <grpc/impl/compression_types.h>
# include <grpc/support/log.h>
# include "src/core/ext/filters/message_size/message_size_filter.h"
# include "src/core/ext/filters/message_size/message_size_filter.h"
# include "src/core/lib/channel/channel_args.h"
# include "src/core/lib/channel/channel_args.h"
@ -104,9 +103,8 @@ ChannelCompression::ChannelCompression(const ChannelArgs& args)
& name ) ) {
& name ) ) {
name = " <unknown> " ;
name = " <unknown> " ;
}
}
gpr_log ( GPR_ERROR ,
LOG ( ERROR ) < < " default compression algorithm " < < name
" default compression algorithm %s not enabled: switching to none " ,
< < " not enabled: switching to none " ;
name ) ;
default_compression_algorithm_ = GRPC_COMPRESS_NONE ;
default_compression_algorithm_ = GRPC_COMPRESS_NONE ;
}
}
}
}
@ -114,8 +112,8 @@ ChannelCompression::ChannelCompression(const ChannelArgs& args)
MessageHandle ChannelCompression : : CompressMessage (
MessageHandle ChannelCompression : : CompressMessage (
MessageHandle message , grpc_compression_algorithm algorithm ) const {
MessageHandle message , grpc_compression_algorithm algorithm ) const {
if ( GRPC_TRACE_FLAG_ENABLED ( compression ) ) {
if ( GRPC_TRACE_FLAG_ENABLED ( compression ) ) {
gpr_log ( GPR_INFO , " CompressMessage: len=% " PRIdPTR " alg=%d flags=%d " ,
LOG ( INFO ) < < " CompressMessage: len= " < < message - > payload ( ) - > Length ( )
message - > payload ( ) - > Length ( ) , algorithm , message - > flags ( ) ) ;
< < " alg= " < < algorithm < < " flags= " < < message - > flags ( ) ;
}
}
auto * call_tracer = MaybeGetContext < CallTracerInterface > ( ) ;
auto * call_tracer = MaybeGetContext < CallTracerInterface > ( ) ;
if ( call_tracer ! = nullptr ) {
if ( call_tracer ! = nullptr ) {
@ -144,10 +142,10 @@ MessageHandle ChannelCompression::CompressMessage(
const float savings_ratio = 1.0f - static_cast < float > ( after_size ) /
const float savings_ratio = 1.0f - static_cast < float > ( after_size ) /
static_cast < float > ( before_size ) ;
static_cast < float > ( before_size ) ;
CHECK ( grpc_compression_algorithm_name ( algorithm , & algo_name ) ) ;
CHECK ( grpc_compression_algorithm_name ( algorithm , & algo_name ) ) ;
gpr_log ( GPR_INFO ,
LOG ( INFO ) < < absl : : StrFormat (
" Compressed[%s] % " PRIuPTR " bytes vs. % " PRIuPTR
" Compressed[%s] % " PRIuPTR " bytes vs. % " PRIuPTR
" bytes (%.2f%% savings) " ,
" bytes (%.2f%% savings) " ,
algo_name , before_size , after_size , 100 * savings_ratio ) ;
algo_name , before_size , after_size , 100 * savings_ratio ) ;
}
}
tmp . Swap ( payload ) ;
tmp . Swap ( payload ) ;
flags | = GRPC_WRITE_INTERNAL_COMPRESS ;
flags | = GRPC_WRITE_INTERNAL_COMPRESS ;
@ -158,10 +156,9 @@ MessageHandle ChannelCompression::CompressMessage(
if ( GRPC_TRACE_FLAG_ENABLED ( compression ) ) {
if ( GRPC_TRACE_FLAG_ENABLED ( compression ) ) {
const char * algo_name ;
const char * algo_name ;
CHECK ( grpc_compression_algorithm_name ( algorithm , & algo_name ) ) ;
CHECK ( grpc_compression_algorithm_name ( algorithm , & algo_name ) ) ;
gpr_log ( GPR_INFO ,
LOG ( INFO ) < < " Algorithm ' " < < algo_name
" Algorithm '%s' enabled but decided not to compress. Input size: "
< < " ' enabled but decided not to compress. Input size: "
" % " PRIuPTR ,
< < payload - > Length ( ) ;
algo_name , payload - > Length ( ) ) ;
}
}
}
}
return message ;
return message ;
@ -170,9 +167,9 @@ MessageHandle ChannelCompression::CompressMessage(
absl : : StatusOr < MessageHandle > ChannelCompression : : DecompressMessage (
absl : : StatusOr < MessageHandle > ChannelCompression : : DecompressMessage (
bool is_client , MessageHandle message , DecompressArgs args ) const {
bool is_client , MessageHandle message , DecompressArgs args ) const {
if ( GRPC_TRACE_FLAG_ENABLED ( compression ) ) {
if ( GRPC_TRACE_FLAG_ENABLED ( compression ) ) {
gpr_log ( GPR_INFO , " DecompressMessage: len=% " PRIdPTR " max=%d alg=%d " ,
LOG ( INFO ) < < " DecompressMessage: len= " < < message - > payload ( ) - > Length ( )
message - > payload ( ) - > Length ( ) ,
< < " max= " < < args . max_recv_message_length . value_or ( - 1 )
args . max_recv_message_length . value_or ( - 1 ) , args . algorithm ) ;
< < " alg= " < < args . algorithm ;
}
}
auto * call_tracer = MaybeGetContext < CallTracerInterface > ( ) ;
auto * call_tracer = MaybeGetContext < CallTracerInterface > ( ) ;
if ( call_tracer ! = nullptr ) {
if ( call_tracer ! = nullptr ) {