Optimize HTTP/2 upstream backpressure#74
Open
xchacha20-poly1305 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Summary
Make HTTP/2 upstream back-pressure honor all three relevant limits — peer
session window, peer stream window, and local data-source queue capacity — so
callers stop over-committing bytes. Also split the TCP socket's single 128 KiB
constant into a 4 MiB queue threshold and a 256 KiB per-write cap to avoid
starving the upper layer on fast links.
Changes
core/src/http2_upstream.cpp:Http2Upstream::send()clampslengthtoavailable_to_send(id)and returns the actual bytes accepted instead ofunconditionally reporting
length.net/src/http2.cpp:http_session_available_to_write()returnsmin(session_window, stream_window, DATA_QUEUE_SIZE − pending)for non-zero stream IDs.data_source_add()rejects writes that would overflowDATA_QUEUE_SIZEwith
NGHTTP2_ERR_BUFFER_ERRORbefore touching the evbuffer.net/src/tcp_socket.cpp: ReplaceMAX_WRITE_BUFFER_LENwithMAX_WRITE_QUEUE_LEN(4 MiB, used bytcp_socket_available_to_write) andMAX_SINGLE_WRITE_LEN(256 KiB, passed tobufferevent_set_max_single_write).net/test/test_http2.cpp(+net/CMakeLists.txt): New unit test coveringboth stream-window and session-window back-pressure transitions.
common/src/event_loop.cpp,net/src/os_tunnel.cpp,tcpip/test/test_vpn_packet_pool.cpp: Replacestd::unique_ptr<T>{new T{}}with
std::make_unique<T>().Tests
net/test/test_http2.cppexercises stream-window exhaustion, queue-cap exhaustion, and recovery via
WINDOW_UPDATEon both the stream and the connection)make test)/benchon this PR to dispatch theendpoint-bench workflow (
.github/workflows/bench.yml), then paste theresults into the Benchmarks section below
Benchmarks
Need to run
/benchcommand. Skip for now.Checklist