-
Notifications
You must be signed in to change notification settings - Fork 5.5k
quiche: Implement QuicStreamBufferAllocator #6550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
fe99129
e94e659
1591f79
827b033
1115d12
01a2e33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #pragma once | ||
|
|
||
| // NOLINT(namespace-envoy) | ||
|
|
||
| // This file is part of the QUICHE platform implementation, and is not to be | ||
| // consumed or referenced directly by other Envoy code. It serves purely as a | ||
| // porting layer for QUICHE. | ||
|
|
||
| #include "quiche/quic/core/quic_simple_buffer_allocator.h" | ||
|
|
||
| namespace quic { | ||
|
|
||
| // Implements the interface required by | ||
| // https://quiche.googlesource.com/quiche/+/refs/heads/master/quic/platform/api/quic_stream_buffer_allocator.h | ||
| // with the default implementation provided by QUICHE. | ||
| using QuicStreamBufferAllocatorImpl = SimpleBufferAllocator; | ||
|
|
||
| } // namespace quic |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,10 @@ | |
| #include <fstream> | ||
| #include <unordered_set> | ||
|
|
||
| #include "common/memory/stats.h" | ||
| #include "common/network/utility.h" | ||
|
|
||
| #include "test/common/stats/stat_test_utility.h" | ||
| #include "test/extensions/transport_sockets/tls/ssl_test_utility.h" | ||
| #include "test/mocks/api/mocks.h" | ||
| #include "test/test_common/environment.h" | ||
|
|
@@ -42,20 +44,20 @@ | |
| #include "quiche/quic/platform/api/quic_server_stats.h" | ||
| #include "quiche/quic/platform/api/quic_sleep.h" | ||
| #include "quiche/quic/platform/api/quic_stack_trace.h" | ||
| #include "quiche/quic/platform/api/quic_stream_buffer_allocator.h" | ||
| #include "quiche/quic/platform/api/quic_string_piece.h" | ||
| #include "quiche/quic/platform/api/quic_test_output.h" | ||
| #include "quiche/quic/platform/api/quic_thread.h" | ||
| #include "quiche/quic/platform/api/quic_uint128.h" | ||
|
|
||
| using testing::_; | ||
| using testing::HasSubstr; | ||
|
|
||
| // Basic tests to validate functioning of the QUICHE quic platform | ||
| // implementation. For platform APIs in which the implementation is a simple | ||
| // typedef/passthrough to a std:: or absl:: construct, the tests are kept | ||
| // minimal, and serve primarily to verify the APIs compile and link without | ||
| // issue. | ||
|
|
||
| using testing::_; | ||
| using testing::HasSubstr; | ||
| using testing::Return; | ||
|
|
||
| namespace quic { | ||
|
|
@@ -572,5 +574,26 @@ TEST_F(QuicPlatformTest, FailToPickUnsedPort) { | |
| EXPECT_DEATH_LOG_TO_STDERR(QuicPickUnusedPortOrDie(), "Failed to pick a port for test."); | ||
| } | ||
|
|
||
| TEST_F(QuicPlatformTest, TestEnvoyQuicBufferAllocator) { | ||
| bool deterministic_stats = Envoy::Stats::TestUtil::hasDeterministicMallocStats(); | ||
| size_t start_mem; | ||
| if (deterministic_stats) { | ||
| start_mem = Envoy::Memory::Stats::totalCurrentlyAllocated(); | ||
| std::cerr << "start mem " << start_mem << "\n"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dd
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| } | ||
| QuicStreamBufferAllocator allocator; | ||
| char* p = allocator.New(1024); | ||
| if (deterministic_stats) { | ||
| EXPECT_LT(start_mem, Envoy::Memory::Stats::totalCurrentlyAllocated()); | ||
| std::cerr << "after New " << Envoy::Memory::Stats::totalCurrentlyAllocated() << "\n"; | ||
| } | ||
| EXPECT_NE(nullptr, p); | ||
| memset(p, 'a', 1024); | ||
| allocator.Delete(p); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could also in this test ensure that the total allocated bytes was the same before and after this delete, via
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| if (deterministic_stats) { | ||
| EXPECT_EQ(start_mem, Envoy::Memory::Stats::totalCurrentlyAllocated()); | ||
| } | ||
| } | ||
|
|
||
| } // namespace | ||
| } // namespace quic | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well just assign start_mem conditionally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done