From bcb21f1b46fcd5c3383e3db2844f2f4b1f1b9639 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Fri, 5 Jul 2024 15:01:40 +0100 Subject: [PATCH 1/2] Keep capacity when dropping pending reads in the stream channel Motivation: When the stream channel has closed it drops all of its pending reads. It does this by calling 'removeAll()' on its CircularBuffer. The buffers underlying storage is emptied and then a `nil` is appended (internally CircularBuffer is never empty) which triggers an allocation. Modifications: - Remove all but keep capacity Result: Fewer allocations --- Sources/NIOHTTP2/HTTP2StreamChannel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/NIOHTTP2/HTTP2StreamChannel.swift b/Sources/NIOHTTP2/HTTP2StreamChannel.swift index 1d39b678..5f793343 100644 --- a/Sources/NIOHTTP2/HTTP2StreamChannel.swift +++ b/Sources/NIOHTTP2/HTTP2StreamChannel.swift @@ -728,7 +728,7 @@ private extension HTTP2StreamChannel { /// Drop all pending reads. private func dropPendingReads() { /// We don't need to report the dropped reads, just remove them all. - self.pendingReads.removeAll() + self.pendingReads.removeAll(keepingCapacity: true) } /// Deliver all pending reads to the channel. From 377c7155b07c2302f7783a6cc4766e7612e291e2 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Fri, 5 Jul 2024 16:57:05 +0100 Subject: [PATCH 2/2] update alloc limits --- docker/docker-compose.2204.510.yaml | 28 ++++++++++++++-------------- docker/docker-compose.2204.58.yaml | 28 ++++++++++++++-------------- docker/docker-compose.2204.59.yaml | 28 ++++++++++++++-------------- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/docker/docker-compose.2204.510.yaml b/docker/docker-compose.2204.510.yaml index 9500e234..a4d3ec2b 100644 --- a/docker/docker-compose.2204.510.yaml +++ b/docker/docker-compose.2204.510.yaml @@ -28,25 +28,25 @@ services: test: image: swift-nio-http2:22.04-5.10 environment: - - MAX_ALLOCS_ALLOWED_1k_requests_inline_interleaved=34150 - - MAX_ALLOCS_ALLOWED_1k_requests_inline_noninterleaved=33100 - - MAX_ALLOCS_ALLOWED_1k_requests_interleaved=40150 - - MAX_ALLOCS_ALLOWED_1k_requests_noninterleaved=39100 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=286050 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response_inline=271050 - - MAX_ALLOCS_ALLOWED_client_server_request_response=255050 - - MAX_ALLOCS_ALLOWED_client_server_request_response_inline=246050 - - MAX_ALLOCS_ALLOWED_client_server_request_response_many=1200050 - - MAX_ALLOCS_ALLOWED_client_server_request_response_many_inline=891050 - - MAX_ALLOCS_ALLOWED_create_client_stream_channel=38050 - - MAX_ALLOCS_ALLOWED_create_client_stream_channel_inline=38050 + - MAX_ALLOCS_ALLOWED_1k_requests_inline_interleaved=33150 + - MAX_ALLOCS_ALLOWED_1k_requests_inline_noninterleaved=32100 + - MAX_ALLOCS_ALLOWED_1k_requests_interleaved=39150 + - MAX_ALLOCS_ALLOWED_1k_requests_noninterleaved=38100 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=284050 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response_inline=269050 + - MAX_ALLOCS_ALLOWED_client_server_request_response=253050 + - MAX_ALLOCS_ALLOWED_client_server_request_response_inline=244050 + - MAX_ALLOCS_ALLOWED_client_server_request_response_many=1198050 + - MAX_ALLOCS_ALLOWED_client_server_request_response_many_inline=889050 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel=37050 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel_inline=37050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form=200050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace=200050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace_from_long_string=300050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace_from_short_string=200050 - MAX_ALLOCS_ALLOWED_hpack_decoding=5050 - - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent=292650 - - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent_inline=291750 + - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent=282650 + - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent_inline=281750 - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error shell: diff --git a/docker/docker-compose.2204.58.yaml b/docker/docker-compose.2204.58.yaml index 6fb8982a..0dedb051 100644 --- a/docker/docker-compose.2204.58.yaml +++ b/docker/docker-compose.2204.58.yaml @@ -28,25 +28,25 @@ services: test: image: swift-nio-http2:22.04-5.8 environment: - - MAX_ALLOCS_ALLOWED_1k_requests_inline_interleaved=34150 - - MAX_ALLOCS_ALLOWED_1k_requests_inline_noninterleaved=33100 - - MAX_ALLOCS_ALLOWED_1k_requests_interleaved=40150 - - MAX_ALLOCS_ALLOWED_1k_requests_noninterleaved=39100 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=286050 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response_inline=271050 - - MAX_ALLOCS_ALLOWED_client_server_request_response=255050 - - MAX_ALLOCS_ALLOWED_client_server_request_response_inline=246050 - - MAX_ALLOCS_ALLOWED_client_server_request_response_many=1200050 - - MAX_ALLOCS_ALLOWED_client_server_request_response_many_inline=891050 - - MAX_ALLOCS_ALLOWED_create_client_stream_channel=38050 - - MAX_ALLOCS_ALLOWED_create_client_stream_channel_inline=38050 + - MAX_ALLOCS_ALLOWED_1k_requests_inline_interleaved=33150 + - MAX_ALLOCS_ALLOWED_1k_requests_inline_noninterleaved=32100 + - MAX_ALLOCS_ALLOWED_1k_requests_interleaved=39150 + - MAX_ALLOCS_ALLOWED_1k_requests_noninterleaved=38100 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=284050 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response_inline=269050 + - MAX_ALLOCS_ALLOWED_client_server_request_response=253050 + - MAX_ALLOCS_ALLOWED_client_server_request_response_inline=244050 + - MAX_ALLOCS_ALLOWED_client_server_request_response_many=1198050 + - MAX_ALLOCS_ALLOWED_client_server_request_response_many_inline=889050 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel=37050 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel_inline=37050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form=200050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace=200050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace_from_long_string=300050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace_from_short_string=200050 - MAX_ALLOCS_ALLOWED_hpack_decoding=5050 - - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent=292650 - - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent_inline=291750 + - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent=282650 + - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent_inline=281750 - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error shell: diff --git a/docker/docker-compose.2204.59.yaml b/docker/docker-compose.2204.59.yaml index 82d376a7..5562f641 100644 --- a/docker/docker-compose.2204.59.yaml +++ b/docker/docker-compose.2204.59.yaml @@ -28,25 +28,25 @@ services: test: image: swift-nio-http2:22.04-5.9 environment: - - MAX_ALLOCS_ALLOWED_1k_requests_inline_interleaved=34150 - - MAX_ALLOCS_ALLOWED_1k_requests_inline_noninterleaved=33100 - - MAX_ALLOCS_ALLOWED_1k_requests_interleaved=40150 - - MAX_ALLOCS_ALLOWED_1k_requests_noninterleaved=39100 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=286050 - - MAX_ALLOCS_ALLOWED_client_server_h1_request_response_inline=271050 - - MAX_ALLOCS_ALLOWED_client_server_request_response=255050 - - MAX_ALLOCS_ALLOWED_client_server_request_response_inline=246050 - - MAX_ALLOCS_ALLOWED_client_server_request_response_many=1200050 - - MAX_ALLOCS_ALLOWED_client_server_request_response_many_inline=891050 - - MAX_ALLOCS_ALLOWED_create_client_stream_channel=38050 - - MAX_ALLOCS_ALLOWED_create_client_stream_channel_inline=38050 + - MAX_ALLOCS_ALLOWED_1k_requests_inline_interleaved=33150 + - MAX_ALLOCS_ALLOWED_1k_requests_inline_noninterleaved=32100 + - MAX_ALLOCS_ALLOWED_1k_requests_interleaved=39150 + - MAX_ALLOCS_ALLOWED_1k_requests_noninterleaved=38100 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response=284050 + - MAX_ALLOCS_ALLOWED_client_server_h1_request_response_inline=269050 + - MAX_ALLOCS_ALLOWED_client_server_request_response=253050 + - MAX_ALLOCS_ALLOWED_client_server_request_response_inline=244050 + - MAX_ALLOCS_ALLOWED_client_server_request_response_many=1198050 + - MAX_ALLOCS_ALLOWED_client_server_request_response_many_inline=889050 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel=37050 + - MAX_ALLOCS_ALLOWED_create_client_stream_channel_inline=37050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form=200050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace=200050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace_from_long_string=300050 - MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace_from_short_string=200050 - MAX_ALLOCS_ALLOWED_hpack_decoding=5050 - - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent=292650 - - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent_inline=291750 + - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent=282650 + - MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent_inline=281750 - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error shell: