Skip to content

Commit

Permalink
quic: Use GRO for reading packets from the UDP socket in upstream QUIC
Browse files Browse the repository at this point in the history
This behavior is guarded by the runtime flag
`envoy.reloadable_features.prefer_udp_gro`.

We previously turned off GRO in `EnvoyQuicClientConnection` because we
weren't sure about the performance (see
envoyproxy#19088). However, kernel experts
have recommended using GRO over recvmmsg as a much more CPU efficient
solution for reading multiple UDP packets into a single buffer.

Signed-off-by: Ali Beyad <abeyad@google.com>
  • Loading branch information
abeyad committed Feb 28, 2024
1 parent 50ed618 commit 8c72e92
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ minor_behavior_changes:
change: |
Enable obsolete line folding in BalsaParser (for behavior parity with http-parser, the
previously used HTTP/1 parser).
- area: http3
change: |
Use GRO (Generic Receive Offload) for reading packets from a UDP socket. See
https://www.kernel.org/doc/html/next/networking/segmentation-offloads.html for a description of
GRO. This behavior change can be reverted by setting
``envoy.reloadable_features.prefer_udp_gro`` to ``false``.
bug_fixes:
# *Changes expected to improve the state of the world and are unlikely to have negative effects*
Expand Down
5 changes: 4 additions & 1 deletion source/common/quic/envoy_quic_client_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "source/common/network/socket_option_factory.h"
#include "source/common/network/udp_packet_writer_handler_impl.h"
#include "source/common/quic/envoy_quic_utils.h"
#include "source/common/runtime/runtime_features.h"

namespace Envoy {
namespace Quic {
Expand Down Expand Up @@ -229,7 +230,9 @@ void EnvoyQuicClientConnection::onFileEvent(uint32_t events,
if (connected() && (events & Event::FileReadyType::Read)) {
Api::IoErrorPtr err = Network::Utility::readPacketsFromSocket(
connection_socket.ioHandle(), *connection_socket.connectionInfoProvider().localAddress(),
*this, dispatcher_.timeSource(), /*prefer_gro=*/false, packets_dropped_);
*this, dispatcher_.timeSource(),
Runtime::runtimeFeatureEnabled("envoy.reloadable_features.prefer_udp_gro"),
packets_dropped_);
if (err == nullptr) {
// In the case where the path validation fails, the probing socket will be closed and its IO
// events are no longer interesting.
Expand Down
1 change: 1 addition & 0 deletions source/common/runtime/runtime_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ RUNTIME_GUARD(envoy_reloadable_features_oauth_make_token_cookie_httponly);
RUNTIME_GUARD(envoy_reloadable_features_oauth_use_standard_max_age_value);
RUNTIME_GUARD(envoy_reloadable_features_oauth_use_url_encoding);
RUNTIME_GUARD(envoy_reloadable_features_original_dst_rely_on_idle_timeout);
RUNTIME_GUARD(envoy_reloadable_features_prefer_udp_gro);
RUNTIME_GUARD(envoy_reloadable_features_proxy_status_upstream_request_timeout);
RUNTIME_GUARD(envoy_reloadable_features_quic_fix_filter_manager_uaf);
// Ignore the automated "remove this flag" issue: we should keep this for 1 year. Confirm with
Expand Down

0 comments on commit 8c72e92

Please sign in to comment.