Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ removed_config_or_runtime:
- area: listener
change: |
removed ``envoy.reloadable_features.strict_check_on_ipv4_compat`` and legacy code paths.
- area: http
change: |
removed ``envoy.reloadable_features.deprecate_global_ints`` and legacy code paths.
- area: http
change: |
removed ``envoy.reloadable_features.allow_adding_content_type_in_local_replies`` and legacy code paths.
Expand Down
3 changes: 2 additions & 1 deletion source/common/http/header_map_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace {

constexpr absl::string_view DelimiterForInlineHeaders{","};
constexpr absl::string_view DelimiterForInlineCookies{"; "};
const static int kMinHeadersForLazyMap = 3; // Optimal hard-coded value based on benchmarks.

bool validatedLowerCaseString(absl::string_view str) {
auto lower_case_str = LowerCaseString(str);
Expand Down Expand Up @@ -58,7 +59,7 @@ template <> bool HeaderMapImpl::HeaderList::isPseudoHeader(const LowerCaseString

bool HeaderMapImpl::HeaderList::maybeMakeMap() {
if (lazy_map_.empty()) {
if (headers_.size() < lazy_map_min_size_) {
if (headers_.size() < kMinHeadersForLazyMap) {
return false;
}
// Add all entries from the list into the map.
Expand Down
17 changes: 5 additions & 12 deletions source/common/http/header_map_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,9 @@ class HeaderMapImpl : NonCopyable {
/**
* List of HeaderEntryImpl that keeps the pseudo headers (key starting with ':') in the front
* of the list (as required by nghttp2) and otherwise maintains insertion order.
* When the list size is greater or equal to the envoy.http.headermap.lazy_map_min_size runtime
* feature value (defaults to 3, if not set), all headers are added to a map, to allow
* fast access given a header key. Once the map is initialized, it will be used even if the number
* of headers decreases below the threshold.
* When the list size is greater or equal to 3, all headers are added to a map, to allow fast
* access given a header key. Once the map is initialized, it will be used even
* if the number of headers decreases below the threshold.
*
* Note: the internal iterators held in fields make this unsafe to copy and move, since the
* reference to end() is not preserved across a move (see Notes in
Expand All @@ -198,10 +197,7 @@ class HeaderMapImpl : NonCopyable {
using HeaderNodeVector = absl::InlinedVector<HeaderNode, 1>;
using HeaderLazyMap = absl::flat_hash_map<absl::string_view, HeaderNodeVector>;

HeaderList()
: pseudo_headers_end_(headers_.end()),
lazy_map_min_size_(static_cast<uint32_t>(
Runtime::getInteger("envoy.http.headermap.lazy_map_min_size", 3))) {}
HeaderList() : pseudo_headers_end_(headers_.end()) {}

template <class Key> bool isPseudoHeader(const Key& key) {
return !key.getStringView().empty() && key.getStringView()[0] == ':';
Expand Down Expand Up @@ -278,8 +274,7 @@ class HeaderMapImpl : NonCopyable {
}

/*
* Creates and populates a map if the number of headers is at least the
* envoy.http.headermap.lazy_map_min_size runtime feature value.
* Creates and populates a map if the number of headers is at least 3.
*
* @return if a map was created.
*/
Expand Down Expand Up @@ -311,8 +306,6 @@ class HeaderMapImpl : NonCopyable {
private:
std::list<HeaderEntryImpl> headers_;
HeaderNode pseudo_headers_end_;
// The number of headers threshold for lazy map usage.
const uint32_t lazy_map_min_size_;
HeaderLazyMap lazy_map_;
};

Expand Down
13 changes: 2 additions & 11 deletions source/common/runtime/runtime_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ RUNTIME_GUARD(envoy_reloadable_features_conn_pool_delete_when_idle);
RUNTIME_GUARD(envoy_reloadable_features_conn_pool_new_stream_with_early_data_and_http3);
RUNTIME_GUARD(envoy_reloadable_features_correct_remote_address);
RUNTIME_GUARD(envoy_reloadable_features_delta_xds_subscription_state_tracking_fix);
RUNTIME_GUARD(envoy_reloadable_features_deprecate_global_ints);
RUNTIME_GUARD(envoy_reloadable_features_do_not_await_headers_on_upstream_timeout_to_emit_stats);
RUNTIME_GUARD(envoy_reloadable_features_do_not_count_mapped_pages_as_free);
RUNTIME_GUARD(envoy_reloadable_features_enable_compression_bomb_protection);
Expand Down Expand Up @@ -213,16 +212,8 @@ void maybeSetDeprecatedInts(absl::string_view name, uint32_t value) {
return;
}

// DO NOT ADD MORE FLAGS HERE. This function deprecated and being removed.
if (name == "envoy.http.headermap.lazy_map_min_size") {
if (Runtime::runtimeFeatureEnabled("envoy.reloadable_features.deprecate_global_ints")) {
IS_ENVOY_BUG(absl::StrCat(
"The Envoy community is attempting to remove global integers. Given you use ", name,
" please immediately file an upstream issue to retain the functionality as it will "
"otherwise be removed following the usual deprecation cycle."));
}
absl::SetFlag(&FLAGS_envoy_headermap_lazy_map_min_size, value);
} else if (name == "re2.max_program_size.error_level") {
// DO NOT ADD MORE FLAGS HERE. This function deprecated.
else if (name == "re2.max_program_size.error_level") {
absl::SetFlag(&FLAGS_re2_max_program_size_error_level, value);
} else if (name == "re2.max_program_size.warn_level") {
absl::SetFlag(&FLAGS_re2_max_program_size_warn_level, value);
Expand Down
3 changes: 1 addition & 2 deletions source/docs/header_map.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
The Envoy header map implementation (`HeaderMapImpl`) has the following properties:
* Headers are stored in a linked list (`HeaderList`) in the order they are added, with pseudo
headers kept at the front of the list.
* Once the number of headers is at least the runtime configured feature `envoy.http.headermap.lazy_map_min_size`,
the header map will also use a map (`HeaderLazyMap`), in addition to the linked list, for faster access to the headers.
* Once there at at least 3 years, the header map will also use a map (`HeaderLazyMap`), in addition to the linked list, for faster access to the headers.
* O(1) direct access is possible for common headers needed during data plane processing. This is
provided by a table of pointers that reach directly into a linked list that is populated when
headers are added or removed from the map. When O(1) headers are accessed by direct method
Expand Down
10 changes: 3 additions & 7 deletions test/common/common/regex_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ TEST(Utility, ParseRegex) {
// The deprecated field codepath precedes any runtime settings.
{
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.deprecate_global_ints", "false"},
{"re2.max_program_size.error_level", "3"}});
scoped_runtime.mergeValues({{"re2.max_program_size.error_level", "3"}});
envoy::type::matcher::v3::RegexMatcher matcher;
matcher.set_regex("/asdf/.*");
matcher.mutable_google_re2()->mutable_max_program_size()->set_value(1);
Expand All @@ -99,8 +98,7 @@ TEST(Utility, ParseRegex) {
// Verify that an exception is thrown for the error level max program size.
{
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.deprecate_global_ints", "false"},
{"re2.max_program_size.error_level", "1"}});
scoped_runtime.mergeValues({{"re2.max_program_size.error_level", "1"}});
envoy::type::matcher::v3::RegexMatcher matcher;
matcher.set_regex("/asdf/.*");
matcher.mutable_google_re2();
Expand All @@ -118,7 +116,6 @@ TEST(Utility, ParseRegex) {
// Verify that the error level max program size defaults to 100 if not set by runtime.
{
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.deprecate_global_ints", "false"}});
envoy::type::matcher::v3::RegexMatcher matcher;
matcher.set_regex(
"/asdf/.*/asdf/.*/asdf/.*/asdf/.*/asdf/.*/asdf/.*/asdf/.*/asdf/.*/asdf/.*/asdf/.*");
Expand All @@ -137,8 +134,7 @@ TEST(Utility, ParseRegex) {
// Verify that a warning is logged for the warn level max program size.
{
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues({{"envoy.reloadable_features.deprecate_global_ints", "false"},
{"re2.max_program_size.warn_level", "1"}});
scoped_runtime.mergeValues({{"re2.max_program_size.warn_level", "1"}});
envoy::type::matcher::v3::RegexMatcher matcher;
matcher.set_regex("/asdf/.*");
matcher.mutable_google_re2();
Expand Down
6 changes: 0 additions & 6 deletions test/common/http/header_map_impl_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ namespace Envoy {
// Fuzz the header map implementation.
DEFINE_PROTO_FUZZER(const test::common::http::HeaderMapImplFuzzTestCase& input) {
TestScopedRuntime scoped_runtime;
// Set the lazy header-map threshold if found.
if (input.has_config()) {
scoped_runtime.mergeValues({{"envoy.reloadable_features.deprecate_global_ints", "false"},
{"envoy.http.headermap.lazy_map_min_size",
absl::StrCat(input.config().lazy_map_min_size())}});
}

auto header_map = Http::RequestHeaderMapImpl::create();
std::vector<std::unique_ptr<Http::LowerCaseString>> lower_case_strings;
Expand Down
Loading