Skip to content

quic: Use GRO for reading packets from the UDP socket in upstream QUIC#32628

Merged
abeyad merged 30 commits intoenvoyproxy:mainfrom
abeyad:gro
Mar 12, 2024
Merged

quic: Use GRO for reading packets from the UDP socket in upstream QUIC#32628
abeyad merged 30 commits intoenvoyproxy:mainfrom
abeyad:gro

Conversation

@abeyad
Copy link
Copy Markdown
Contributor

@abeyad abeyad commented Feb 28, 2024

This behavior is guarded by the runtime flag envoy.restart_features.prefer_udp_gro.

We previously turned off GRO in EnvoyQuicClientConnection because we weren't sure about the performance (see
#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.

This change also enables setting the option of whether recvmmsg should be used or not, so we can
disable it for client connections, while keeping it for listener sockets.

Risk Level: low (can be turned off with the runtime guard)
Testing: unit tests
Release Notes: included
Runtime guard: envoy.reloadable_features.prefer_udp_gro

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>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).

🐱

Caused by: #32628 was opened by abeyad.

see: more, trace.

@abeyad
Copy link
Copy Markdown
Contributor Author

abeyad commented Feb 28, 2024

@alyssawilk still haven't found a good way to write tests for this PR, relied on running existing tests so far

@abeyad
Copy link
Copy Markdown
Contributor Author

abeyad commented Feb 28, 2024

I can also default it to _FALSE and only enable in Envoy Mobile for starters, though I don't think based on usage patterns that this is a high risk change

Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two thoughts for testing.
You can see if any tests which include a real EnvoyQuicClientConnection can have the TestThreadsafeSingletonInjector added. Even if the test fast-fails you can do an
EXPECT_CALL(os_sys_calls_, recvmsg like test/common/quic/quic_io_handle_wrapper_test.cc does, since I believe with the flag false we'd recvmmsg. Alternately there's an expect log message macro somewhere and you could see if any unit tests have an increased level of "starting gro recvmsg with..." logs

Signed-off-by: Ali Beyad <abeyad@google.com>
@abeyad
Copy link
Copy Markdown
Contributor Author

abeyad commented Mar 4, 2024

@alyssawilk @danzh2010 This is ready for review again, thanks!

@abeyad
Copy link
Copy Markdown
Contributor Author

abeyad commented Mar 4, 2024

two thoughts for testing. You can see if any tests which include a real EnvoyQuicClientConnection can have the TestThreadsafeSingletonInjector added. Even if the test fast-fails you can do an EXPECT_CALL(os_sys_calls_, recvmsg like test/common/quic/quic_io_handle_wrapper_test.cc does, since I believe with the flag false we'd recvmmsg. Alternately there's an expect log message macro somewhere and you could see if any unit tests have an increased level of "starting gro recvmsg with..." logs

I added a test in envoy_quic_client_session_test that mocks the recvmsg, and makes sure recvmsg is called and recvmmsg is not called

Signed-off-by: Ali Beyad <abeyad@google.com>
abeyad added 2 commits March 4, 2024 22:25
Signed-off-by: Ali Beyad <abeyad@google.com>
Signed-off-by: Ali Beyad <abeyad@google.com>
Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo addressing Dan's flag concerns
/wait

Signed-off-by: Ali Beyad <abeyad@google.com>
@abeyad
Copy link
Copy Markdown
Contributor Author

abeyad commented Mar 6, 2024

LGTM modulo addressing Dan's flag concerns /wait

Done, ready for another round of review

abeyad added 3 commits March 6, 2024 17:55
Signed-off-by: Ali Beyad <abeyad@google.com>
Signed-off-by: Ali Beyad <abeyad@google.com>
Signed-off-by: Ali Beyad <abeyad@google.com>
Copy link
Copy Markdown
Contributor

@danzh2010 danzh2010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the change!

@abeyad
Copy link
Copy Markdown
Contributor Author

abeyad commented Mar 9, 2024

/retest

abeyad added 6 commits March 9, 2024 03:49
Signed-off-by: Ali Beyad <abeyad@google.com>
Signed-off-by: Ali Beyad <abeyad@google.com>
Signed-off-by: Ali Beyad <abeyad@google.com>
Signed-off-by: Ali Beyad <abeyad@google.com>
Signed-off-by: Ali Beyad <abeyad@google.com>
Signed-off-by: Ali Beyad <abeyad@google.com>
Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/wait-any

``envoy.reloadable_features.prefer_quic_client_udp_gro`` to ``false``.
- area: http3
change: |
Allow recvmmsg (multi-message) to be used for reading packets from a client QUIC UDP socket, if
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait I thought we wanted to disallow client recvmmsg?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed the runtime guard to disallow_ so the default behavior is to disallow recvmmsg. PTAL

Signed-off-by: Ali Beyad <abeyad@google.com>
@abeyad
Copy link
Copy Markdown
Contributor Author

abeyad commented Mar 11, 2024

/retest

2 similar comments
@abeyad
Copy link
Copy Markdown
Contributor Author

abeyad commented Mar 12, 2024

/retest

@abeyad
Copy link
Copy Markdown
Contributor Author

abeyad commented Mar 12, 2024

/retest

Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, that's what I get for not reading far enough along.
Love this final version -all the readability and barely any refactor

@abeyad
Copy link
Copy Markdown
Contributor Author

abeyad commented Mar 12, 2024

/retest

Copy link
Copy Markdown
Contributor

@RyanTheOptimist RyanTheOptimist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@abeyad abeyad merged commit 10a1003 into envoyproxy:main Mar 12, 2024
@abeyad
Copy link
Copy Markdown
Contributor Author

abeyad commented Mar 12, 2024

thanks for the reviews everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants