Commit 219c2a7a authored by yasong's avatar yasong Committed by Commit bot

Increase HPACK table size up to the optimal size if clients allow it.

This CL lands server change 133042402 by yasong@.

BUG=488484

Review-Url: https://codereview.chromium.org/2348603003
Cr-Commit-Position: refs/heads/master@{#419235}
parent e9224222
......@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "net/spdy/hpack/hpack_constants.h"
#include "net/spdy/hpack/hpack_static_table.h"
#include "net/spdy/spdy_flags.h"
namespace net {
......@@ -125,7 +126,11 @@ void HpackHeaderTable::SetMaxSize(size_t max_size) {
void HpackHeaderTable::SetSettingsHeaderTableSize(size_t settings_size) {
settings_size_bound_ = settings_size;
if (settings_size_bound_ < max_size_) {
if (!FLAGS_chromium_reloadable_flag_increase_hpack_table_size) {
if (settings_size_bound_ < max_size_) {
SetMaxSize(settings_size_bound_);
}
} else {
SetMaxSize(settings_size_bound_);
}
}
......
......@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "net/spdy/hpack/hpack_constants.h"
#include "net/spdy/hpack/hpack_entry.h"
#include "net/spdy/spdy_flags.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
......@@ -258,6 +259,41 @@ TEST_F(HpackHeaderTableTest, EntryIndexing) {
}
TEST_F(HpackHeaderTableTest, SetSizes) {
FLAGS_chromium_reloadable_flag_increase_hpack_table_size = true;
string key = "key", value = "value";
const HpackEntry* entry1 = table_.TryAddEntry(key, value);
const HpackEntry* entry2 = table_.TryAddEntry(key, value);
const HpackEntry* entry3 = table_.TryAddEntry(key, value);
// Set exactly large enough. No Evictions.
size_t max_size = entry1->Size() + entry2->Size() + entry3->Size();
table_.SetMaxSize(max_size);
EXPECT_EQ(3u, peer_.dynamic_entries().size());
// Set just too small. One eviction.
max_size = entry1->Size() + entry2->Size() + entry3->Size() - 1;
table_.SetMaxSize(max_size);
EXPECT_EQ(2u, peer_.dynamic_entries().size());
// Changing SETTINGS_HEADER_TABLE_SIZE.
EXPECT_EQ(kDefaultHeaderTableSizeSetting, table_.settings_size_bound());
// In production, the size passed to SetSettingsHeaderTableSize is never
// larger than table_.settings_size_bound().
table_.SetSettingsHeaderTableSize(kDefaultHeaderTableSizeSetting * 3 + 1);
EXPECT_EQ(kDefaultHeaderTableSizeSetting * 3 + 1, table_.max_size());
// SETTINGS_HEADER_TABLE_SIZE upper-bounds |table_.max_size()|,
// and will force evictions.
max_size = entry3->Size() - 1;
table_.SetSettingsHeaderTableSize(max_size);
EXPECT_EQ(max_size, table_.max_size());
EXPECT_EQ(max_size, table_.settings_size_bound());
EXPECT_EQ(0u, peer_.dynamic_entries().size());
}
TEST_F(HpackHeaderTableTest, SetSizesOld) {
FLAGS_chromium_reloadable_flag_increase_hpack_table_size = false;
string key = "key", value = "value";
const HpackEntry* entry1 = table_.TryAddEntry(key, value);
const HpackEntry* entry2 = table_.TryAddEntry(key, value);
......
......@@ -13,6 +13,10 @@ bool FLAGS_chromium_http2_flag_spdy_framer_use_new_methods4 = true;
// Use SpdyHeaderBlock::AppendValueOrAddHeader when adding to headers.
bool FLAGS_chromium_http2_flag_use_new_spdy_header_block_header_joining = true;
// If true, increase HPACK table size up to optimal size kOptTableSize if
// clients allow it.
bool FLAGS_chromium_reloadable_flag_increase_hpack_table_size = false;
// Use NestedSpdyFramerDecoder.
bool FLAGS_use_nested_spdy_framer_decoder = false;
......
......@@ -13,6 +13,8 @@ NET_EXPORT_PRIVATE extern bool
FLAGS_chromium_http2_flag_spdy_framer_use_new_methods4;
NET_EXPORT_PRIVATE extern bool
FLAGS_chromium_http2_flag_use_new_spdy_header_block_header_joining;
NET_EXPORT_PRIVATE extern bool
FLAGS_chromium_reloadable_flag_increase_hpack_table_size;
NET_EXPORT_PRIVATE extern bool FLAGS_use_nested_spdy_framer_decoder;
} // namespace net
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment