Skip to content
Snippets Groups Projects
Commit 2a2a6ed1 authored by Craig Tiller's avatar Craig Tiller
Browse files

Support rebuilding table

parent b1136495
No related branches found
No related tags found
No related merge requests found
...@@ -130,6 +130,7 @@ typedef struct { ...@@ -130,6 +130,7 @@ typedef struct {
/** How much memory to use for hpack decoding */ /** How much memory to use for hpack decoding */
#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER \ #define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER \
"grpc.http2.hpack_table_size.decoder" "grpc.http2.hpack_table_size.decoder"
/** How much memory to use for hpack encoding */
#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER \ #define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER \
"grpc.http2.hpack_table_size.encoder" "grpc.http2.hpack_table_size.encoder"
/** Default authority to pass if none specified on call construction */ /** Default authority to pass if none specified on call construction */
......
...@@ -474,7 +474,8 @@ void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c, ...@@ -474,7 +474,8 @@ void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c,
c->mdctx = ctx; c->mdctx = ctx;
c->timeout_key_str = grpc_mdstr_from_string(ctx, "grpc-timeout"); c->timeout_key_str = grpc_mdstr_from_string(ctx, "grpc-timeout");
c->max_table_size = GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE; c->max_table_size = GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE;
c->cap_table_elems = c->max_table_elems = elems_for_bytes(c->max_table_size); c->cap_table_elems = elems_for_bytes(c->max_table_size);
c->max_table_elems = c->cap_table_elems;
c->max_usable_size = GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE; c->max_usable_size = GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE;
c->table_elem_size = c->table_elem_size =
gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems); gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems);
...@@ -500,7 +501,20 @@ void grpc_chttp2_hpack_compressor_set_max_usable_size( ...@@ -500,7 +501,20 @@ void grpc_chttp2_hpack_compressor_set_max_usable_size(
} }
static void rebuild_elems(grpc_chttp2_hpack_compressor *c, gpr_uint32 new_cap) { static void rebuild_elems(grpc_chttp2_hpack_compressor *c, gpr_uint32 new_cap) {
gpr_uint16 *table_elem_size = gpr_malloc(sizeof(*table_elem_size) * new_cap);
gpr_uint32 i;
memset(table_elem_size, 0, sizeof(*table_elem_size) * new_cap);
GPR_ASSERT(c->table_elems <= new_cap);
for (i = 0; i < c->table_elems; i++) {
gpr_uint32 ofs = c->tail_remote_index + i + 1;
table_elem_size[ofs % new_cap] = c->table_elem_size[ofs % c->cap_table_elems];
}
c->cap_table_elems = new_cap;
gpr_free(c->table_elem_size);
c->table_elem_size = table_elem_size;
} }
void grpc_chttp2_hpack_compressor_set_max_table_size( void grpc_chttp2_hpack_compressor_set_max_table_size(
...@@ -517,7 +531,7 @@ void grpc_chttp2_hpack_compressor_set_max_table_size( ...@@ -517,7 +531,7 @@ void grpc_chttp2_hpack_compressor_set_max_table_size(
if (c->max_table_elems > c->cap_table_elems) { if (c->max_table_elems > c->cap_table_elems) {
rebuild_elems(c, GPR_MAX(c->max_table_elems, 2 * c->cap_table_elems)); rebuild_elems(c, GPR_MAX(c->max_table_elems, 2 * c->cap_table_elems));
} else if (c->max_table_elems < c->cap_table_elems / 3) { } else if (c->max_table_elems < c->cap_table_elems / 3) {
gpr_uint32 new_cap = GPR_MIN(c->max_table_elems, 16); gpr_uint32 new_cap = GPR_MAX(c->max_table_elems, 16);
if (new_cap != c->cap_table_elems) { if (new_cap != c->cap_table_elems) {
rebuild_elems(c, new_cap); rebuild_elems(c, new_cap);
} }
......
...@@ -485,10 +485,10 @@ _CONFIGS = { ...@@ -485,10 +485,10 @@ _CONFIGS = {
'msan': SimpleConfig('msan', timeout_multiplier=1.5), 'msan': SimpleConfig('msan', timeout_multiplier=1.5),
'ubsan': SimpleConfig('ubsan'), 'ubsan': SimpleConfig('ubsan'),
'asan': SimpleConfig('asan', timeout_multiplier=1.5, environ={ 'asan': SimpleConfig('asan', timeout_multiplier=1.5, environ={
'ASAN_OPTIONS': 'detect_leaks=1:color=always:suppressions=tools/tsan_suppressions.txt', 'ASAN_OPTIONS': 'detect_leaks=1:color=always',
'LSAN_OPTIONS': 'report_objects=1'}), 'LSAN_OPTIONS': 'report_objects=1'}),
'asan-noleaks': SimpleConfig('asan', environ={ 'asan-noleaks': SimpleConfig('asan', environ={
'ASAN_OPTIONS': 'detect_leaks=0:color=always:suppressions=tools/tsan_suppressions.txt'}), 'ASAN_OPTIONS': 'detect_leaks=0:color=always'}),
'gcov': SimpleConfig('gcov'), 'gcov': SimpleConfig('gcov'),
'memcheck': ValgrindConfig('valgrind', 'memcheck', ['--leak-check=full']), 'memcheck': ValgrindConfig('valgrind', 'memcheck', ['--leak-check=full']),
'helgrind': ValgrindConfig('dbg', 'helgrind') 'helgrind': ValgrindConfig('dbg', 'helgrind')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment