Skip to content

rgw: h3 frontend based on quiche library - #48178

Draft
cbodley wants to merge 11 commits into
ceph:mainfrom
cbodley:wip-rgw-h3
Draft

cbodley wants to merge 11 commits into
ceph:mainfrom
cbodley:wip-rgw-h3

Conversation

@cbodley

@cbodley cbodley commented Sep 19, 2022 •

Copy link
Copy Markdown
Contributor

https://github.com/cloudflare/quiche is a rust library with C bindings. this PR adds quiche as a cmake ExternalProject, using cargo to build it as a static library

like several other quic libraries, quiche depends on boringssl so this pr adds a librgw_h3_quiche.so and dlopens it to isolate the boringssl/quiche linkage from the rest of rgw/ceph

libcurl's cmake also supports a USE_QUICHE option, which should prove useful as an http/3 client for testing. the latest curl 7.85 doesn't build against any quiche release, but curl 7.84 does. so curl 7.84 and the latest quiche 0.14.0 were the selected versions

i've sketched out some of the rgw frontend based on quiche, boost::asio, and c++20 coroutines. by running each quic connection on a separate strand executor, i hope to avoid the need for explicit locking

TODO:

  • split quiche dependency into a shared library and dlopen it to isolate the boringssl linkage
  • optimize i/o path for bandwidth
  • optimize headers with custom allocator or replacement for beast::http::fields
  • unit tests driven by a quiche client to cover interesting error paths
  • functional tests driven by a curl client to exercise several streams over a single connection
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@yuvalif

yuvalif commented Sep 19, 2022

Copy link
Copy Markdown
Contributor

https://github.com/cloudflare/quiche is a rust library with C bindings. this PR adds quiche as a cmake ExternalProject, using cargo to build it as a static library

what were the reasons to prefer quiche over lsquic ?

like several other quic libraries, quiche depends on boringssl so this pr builds on #48160 to enable it in ceph. as reported there, radosgw crashes on startup because the system libcurl is still linked to the system openssl library. to work around this, we build a custom libcurl against the same boringssl library

libcurl's cmake also supports a USE_QUICHE option, which should prove useful as an http/3 client for testing. the latest curl 7.85 doesn't build against any quiche release, but curl 7.84 does. so curl 7.84 and the latest quiche 0.14.0 were the selected versions

i've sketched out some of the rgw frontend based on quiche, boost::asio, and c++20 coroutines. by running each quic connection on a separate strand executor, i hope to avoid the need for explicit locking

with the rest of the code we are using the spawn library with the optiobal_yield. i thought that the plan would be to refactor the frontends with c++20 coroutines in a later stage?

Show available Jenkins commands

@cbodley

cbodley commented Sep 19, 2022

Copy link
Copy Markdown
Contributor Author

what were the reasons to prefer quiche over lsquic ?

for me, the main differentiator was related to locking. with lsquic, the main API object is lsquic_engine which manages the state of all of its connections. every call into lsquic essentially requires a global lock on that engine object

in quiche, Connection is the top-level API object. there are 'global' quiche_config and quiche_h3_config objects but they're immutable. because each Connection is distinct, we can treat each connection as a separate lock domain. that should allow rgw to scale much better with connection count

the tradeoff is that lsquic managed the set of open connections and their lookups by connection id, whereas quiche leaves that part up to the application. i believe we can do this part with no locking at all

in the current prototype, i did add a mutex to the connection set in Listener::on_packet(), but as long as the single Listener::receive_packets() coroutine is the only thing that accesses that connection set, it doesn't actually need to lock

@cbodley

cbodley commented Sep 19, 2022

Copy link
Copy Markdown
Contributor Author

with the rest of the code we are using the spawn library with the optiobal_yield. i thought that the plan would be to refactor the frontends with c++20 coroutines in a later stage?

this will still use the spawn library to create the stackful coroutine that calls process_request(), but i haven't quite gotten that far. the frontend can still use c++20 coroutines internally for its implementation, they're just not exposed to the rest of rgw

@mattbenjamin

Copy link
Copy Markdown
Contributor

what were the reasons to prefer quiche over lsquic ?

for me, the main differentiator was related to locking. with lsquic

I feel we should exercise some caution about incorporating a rust library, but as a prototype, it seems motivated. I don't mind supporting it if it works well--and rust is so au courant.

Matt

@cbodley
cbodley force-pushed the wip-rgw-h3 branch 3 times, most recently from 7d85af0 to dae5a4e Compare September 21, 2022 14:43
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@cbodley

cbodley commented Sep 26, 2022

Copy link
Copy Markdown
Contributor Author

it's alive and working, but the bulk data transfers are pretty slow. testing PUT and GET of a 128mb object with http3:

~/ceph/build $ time SSL_CERT_FILE=cert.crt ~/curl/build/src/curl --http3 --aws-sigv4 aws:amz:us-east-1:s3 -u '0555b35654ad1656d804:h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==' https://localhost:8000/testbucket/128m.iso -T 128m.iso

real    0m2.123s
user    0m0.160s
sys     0m1.615s

~/ceph/build $ time SSL_CERT_FILE=cert.crt ~/curl/build/src/curl --http3 --aws-sigv4 aws:amz:us-east-1:s3 -u '0555b35654ad1656d804:h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==' https://localhost:8000/testbucket/128m.iso --output 128m.out
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  128M  100  128M    0     0  13.1M      0  0:00:09  0:00:09 --:--:-- 13.3M

real    0m9.875s
user    0m0.101s
sys     0m2.976s

the same requests with tcp for comparison:

~/ceph/build $ time ~/curl/build/src/curl --aws-sigv4 aws:amz:us-east-1:s3 -u '0555b35654ad1656d804:h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==' http://localhost:8000/testbucket/128m.iso -T 128m.iso

real    0m0.775s
user    0m0.000s
sys     0m0.053s

~/ceph/build $ time ~/curl/build/src/curl --aws-sigv4 aws:amz:us-east-1:s3 -u '0555b35654ad1656d804:h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==' http://localhost:8000/testbucket/128m.iso --output 128m.out
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  128M  100  128M    0     0   519M      0 --:--:-- --:--:-- --:--:--  520M

real    0m0.388s
user    0m0.003s
sys     0m0.242s

the addition of recvmmsg() helped a lot with the PUTs, but most of the overhead seems to come from the timer in StreamIO which i use for streaming data between Connection and ClientIO. we're triggering a wakeup on that timer for every packet we receive, instead of once when the entire 4mb i/o completes

@mattbenjamin

Copy link
Copy Markdown
Contributor

@cbodley I assume that timer could eventually be eliminated?

@cbodley

cbodley commented Sep 26, 2022

Copy link
Copy Markdown
Contributor Author

@cbodley I assume that timer could eventually be eliminated?

yeah, we just need some way to wake up ClientIO once their chunk of i/o completes. as a first draft, i used a timer to act like a condition variable here, but it's being notified far too often. once we convert this to a one-time notification, we can use a different primitive like ceph::async::Completion to avoid the need for file descriptors and system calls associated with eventfd

@cbodley

cbodley commented Sep 27, 2022

Copy link
Copy Markdown
Contributor Author

updated the read path (corresponding to PutObj) and the PUT performance is much closer to tcp's:

~/ceph/build $ time SSL_CERT_FILE=cert.crt ~/curl/build/src/curl --http3 --aws-sigv4 aws:amz:us-east-1:s3 -u '0555b35654ad1656d804:h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==' https://localhost:8000/testbucket/128m.iso -T 128m.iso

real    0m1.077s
user    0m0.108s
sys     0m0.660s

@cbodley

cbodley commented Jun 5, 2024 •

Copy link
Copy Markdown
Contributor Author

changes:

  • rebased over asio::spawn() changes, switched to any_io_executor, depends on boost 1.85
  • bumped quiche version from 0.16.0 to 0.21.0
  • reenabled pacing delays which were broken on 0.16.0. take pacing hint from first packet instead of last
  • h3_zero example now supports --threads option
  • fixed error handling to prevent exceptions from leaking

@cbodley

cbodley commented Jun 12, 2024

Copy link
Copy Markdown
Contributor Author

performance looks fine against the h3_zero example server. it's also fine for GET requests to rgw's /zero api, but PUTs are extremely slow. wireshark shows tons of tiny packets being exchanged there, ie separate ACKs of individual packets

cbodley added 8 commits July 21, 2024 10:27
dump_body() and recv_body() both catch exceptions and return negative
error codes. handle negative values as errors instead of trying to catch
them

errors here led to later crashes when trying to use a null s->formatter
to format the error response. s->formatter is now allowed on init()

Signed-off-by: Casey Bodley <[email protected]>
rgw frontends throw rgw::io::Exception = std::system_error for io
errors, but other internal exceptions from boost::system::system_error
may also escape from ClientIO. instead of trying to catch and rethrow as
rgw::io::Exception, catch both types in the rgw_rest.cc helpers

Signed-off-by: Casey Bodley <[email protected]>
Signed-off-by: Casey Bodley <[email protected]>
this allows http/1.1 clients to discover the presence of an http/3 endpoint

Signed-off-by: Casey Bodley <[email protected]>
the cert= and key= options were renamed to match beast's
ssl_certificate= and ssl_private_key=

Signed-off-by: Casey Bodley <[email protected]>
StreamIO tracks read and write state separately so that it can handle a
read and a write at the same time

Signed-off-by: Casey Bodley <[email protected]>
each time the Listener calls recvmmsg() to read an array of packets, it
groups those packets by their associated Connection. this allows it to
deliver all of its packets to the Connection in a single call to
async_handle_packets()

this avoids the need for multiple round trips between the Listener's
executor and the Connection's. it also allows the Connection to process
all of the packets before calling writer_wake() to send response packets
or acks

Signed-off-by: Casey Bodley <[email protected]>
Signed-off-by: Casey Bodley <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

1 similar comment
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions

github-actions Bot commented Apr 3, 2025

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions

github-actions Bot commented Jun 2, 2025

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions

github-actions Bot commented Jul 2, 2025

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@RaminNietzsche

Copy link
Copy Markdown
Member

@cbodley — rebased wip-rgw-h3 onto current main and resolved conflicts on a fork branch:

Branch: RaminNietzsche/ceph:wip-rgw-h3 (10 commits; DNM CI commit dropped)

Rebase / conflict resolution:

  • Rebased onto ceph/main (2026-06-22)
  • rgw_appmain.cc: use context_pool_holder.get() (matches current beast/kms path); fixed #ifdef HAVE_QUICHE / quiche frontend registration (was closing rgw-nfs block)
  • rgw_asio_{client,frontend}.cc: merged Alt-Svc headers with main's keepalive / expect100continue / optional_yield beast async path
  • doc/radosgw/frontends.rst: kept :ref: style + Quiche section + Alt-Svc/TLS links
  • Skipped DNM: enable WITH_RADOSGW_QUICHE by default for CI — WITH_RADOSGW_QUICHE stays OFF

Suggested next steps:

  1. git fetch https://github.com/RaminNietzsche/ceph.git wip-rgw-h3
  2. Reset your branch or cherry-pick the series
  3. jenkins test make check (with -DWITH_RADOSGW_QUICHE=ON)
  4. Functional test with curl --http3 per src/rgw/h3/README.md

Experimental HTTP/3 frontend — happy to help with further review items (unit/qa tests, i/o optimizations from PR TODO).

@mkogan1

mkogan1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

@RaminNietzsche

after ❯ git cherry-pick -ex 70d9eef9b383c8f4475051d8b1ce124dd20a617d^..fdc41e70618aea80bc630724197a898b3333425b

there is a build error

FAILED: src/rgw/CMakeFiles/rgw_a.dir/rgw_asio_client.cc.o 
/usr/bin/ccache /opt/rh/gcc-toolset-15/root/usr/bin/g++ -DBOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION -DBOOST_ASIO_NO_TS_EXECUTORS -DBOOST_USE_VALGRIND -DCLS_CLIENT_HIDE_IOCTX -DHAVE_CONFIG_H -DXXH_NO_INLINE_HINTS=1 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE -D__CEPH__ -D__STDC_FORMAT_MACROS -D__linux__ -I/mnt/sdb/src-git/ceph--up/build/src/include -I/mnt/sdb/src-git/ceph--up/src -I/mnt/sdb/src-git/ceph--up/src/dmclock/support/src -I/mnt/sdb/src-git/ceph--up/src/rgw -I/mnt/sdb/src-git/ceph--up/src/rgw/driver/rados -I/mnt/sdb/src-git/ceph--up/src/libkmip -I/mnt/sdb/src-git/ceph--up/src/rgw/services -I/mnt/sdb/src-git/ceph--up/src/BLAKE3/c -I/mnt/sdb/src-git/ceph--up/src/dmclock/src -isystem /mnt/sdb/src-git/ceph--up/build/boost/include -isystem /mnt/sdb/src-git/ceph--up/build/include -isystem /mnt/sdb/src-git/ceph--up/src/xxHash -isystem /mnt/sdb/src-git/ceph--up/src/fmt/include -isystem /mnt/sdb/src-git/ceph--up/src/s3select/rapidjson/include -O2 -g -DNDEBUG -std=c++23 -fPIC -fdiagnostics-color=always -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -Wall -fno-strict-aliasing -fsigned-char -Wtype-limits -Wignored-qualifiers -Wpointer-arith -Werror=format-security -Winit-self -Wno-unknown-pragmas -Wnon-virtual-dtor -Wno-ignored-qualifiers -ftemplate-depth-1024 -DBOOST_ALLOW_DEPRECATED_HEADERS -Wpessimizing-move -Wredundant-move -Wstrict-null-sentinel -Woverloaded-virtual -fstack-protector-strong -fdiagnostics-color=always -Werror=vla -MD -MT src/rgw/CMakeFiles/rgw_a.dir/rgw_asio_client.cc.o -MF src/rgw/CMakeFiles/rgw_a.dir/rgw_asio_client.cc.o.d -o src/rgw/CMakeFiles/rgw_a.dir/rgw_asio_client.cc.o -c /mnt/sdb/src-git/ceph--up/src/rgw/rgw_asio_client.cc
/mnt/sdb/src-git/ceph--up/src/rgw/rgw_asio_client.cc: In member function ‘virtual size_t rgw::asio::ClientIO::complete_header()’:
/mnt/sdb/src-git/ceph--up/src/rgw/rgw_asio_client.cc:162:16: error: expression cannot be used as a function
  162 |   if (keepalive()) {
      |       ~~~~~~~~~^~

myb it should be keep_alive() ?

@RaminNietzsche

Copy link
Copy Markdown
Member

@mkogan1 Thanks for catching this — you're right, it should be keep_alive().

That was my mistake in the Alt-Svc / beast merge: I called the keepalive member as if it were a function instead of using the keep_alive() accessor from rgw_asio_client.h.

Fixed in RaminNietzsche/ceph:wip-rgw-h3 (commit 78ad5c93f92). I rebuilt locally and make completed cleanly, including:

[591/591 (100%) ] Linking CXX executable bin/unittest_rgw_cors

Sorry for the noise, and thanks again for testing the cherry-pick series.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants