mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-06 22:22:38 +03:00
Less direct Buf access in BufAccessor
Summary: **Context** The `BufAccessor` is used to access a contiguous section of memory. Right now, it works with a `Buf` under the hood. **Overall plan** The plan is to change the `BufAccessor` to use a `uint8_t*` instead. Since we're using section of contiguous memory, there's no need to use a chained buffer abstraction here. This'll move us closer to deprecating the usage `folly::IOBuf`. **What this diff is doing** Most use cases of the `BufAccessor` look like the following: ``` auto buf = bufAccessor.obtain(); // Do something with buf, like calling trimEnd bufAccessor.release(buf) ``` I'm adding APIs to the `BufAccessor` so that there's no need to `obtain()` and `release()` the `Buf`. We'd instead just call an API on the `BufAccessor`, which would call that same API on the underlying `folly::IOBuf`. Later on, we'll change the `BufAccessor` to use a `uint8_t*` under the hood. I'm currently leaving in the `obtain()`, `release()`, and `buf()` APIs because Fizz and the AsyncUDPSocket expect `folly::IOBuf` as inputs in many of their APIs. Once those callsites are migrated off `folly::IOBuf`, we can remove these APIs. Reviewed By: mjoras Differential Revision: D60973166 fbshipit-source-id: 52aa3541d0c4878c7ee8525d70ac280508b61e24
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9216eed3d8
commit
a84708be4b
@@ -4287,12 +4287,11 @@ TEST_F(QuicTransportFunctionsTest, ProbeWriteNewFunctionalFramesAckFreq) {
|
||||
TEST_F(QuicTransportFunctionsTest, WriteWithInplaceBuilder) {
|
||||
auto conn = createConn();
|
||||
conn->transportSettings.dataPathType = DataPathType::ContinuousMemory;
|
||||
auto simpleBufAccessor =
|
||||
std::make_unique<SimpleBufAccessor>(conn->udpSendPacketLen * 16);
|
||||
auto outputBuf = simpleBufAccessor->obtain();
|
||||
auto bufAccessor = std::make_unique<BufAccessor>(conn->udpSendPacketLen * 16);
|
||||
auto outputBuf = bufAccessor->obtain();
|
||||
auto bufPtr = outputBuf.get();
|
||||
simpleBufAccessor->release(std::move(outputBuf));
|
||||
conn->bufAccessor = simpleBufAccessor.get();
|
||||
bufAccessor->release(std::move(outputBuf));
|
||||
conn->bufAccessor = bufAccessor.get();
|
||||
conn->transportSettings.batchingMode = QuicBatchingMode::BATCHING_MODE_GSO;
|
||||
EventBase evb;
|
||||
std::shared_ptr<FollyQuicEventBase> qEvb =
|
||||
@@ -4330,12 +4329,11 @@ TEST_F(QuicTransportFunctionsTest, WriteWithInplaceBuilder) {
|
||||
TEST_F(QuicTransportFunctionsTest, WriteWithInplaceBuilderRollbackBuf) {
|
||||
auto conn = createConn();
|
||||
conn->transportSettings.dataPathType = DataPathType::ContinuousMemory;
|
||||
auto simpleBufAccessor =
|
||||
std::make_unique<SimpleBufAccessor>(conn->udpSendPacketLen * 16);
|
||||
auto outputBuf = simpleBufAccessor->obtain();
|
||||
auto bufAccessor = std::make_unique<BufAccessor>(conn->udpSendPacketLen * 16);
|
||||
auto outputBuf = bufAccessor->obtain();
|
||||
auto bufPtr = outputBuf.get();
|
||||
simpleBufAccessor->release(std::move(outputBuf));
|
||||
conn->bufAccessor = simpleBufAccessor.get();
|
||||
bufAccessor->release(std::move(outputBuf));
|
||||
conn->bufAccessor = bufAccessor.get();
|
||||
conn->transportSettings.batchingMode = QuicBatchingMode::BATCHING_MODE_GSO;
|
||||
EventBase evb;
|
||||
std::shared_ptr<FollyQuicEventBase> qEvb =
|
||||
@@ -4359,12 +4357,11 @@ TEST_F(QuicTransportFunctionsTest, WriteWithInplaceBuilderRollbackBuf) {
|
||||
TEST_F(QuicTransportFunctionsTest, WriteWithInplaceBuilderGSOMultiplePackets) {
|
||||
auto conn = createConn();
|
||||
conn->transportSettings.dataPathType = DataPathType::ContinuousMemory;
|
||||
auto simpleBufAccessor =
|
||||
std::make_unique<SimpleBufAccessor>(conn->udpSendPacketLen * 16);
|
||||
auto outputBuf = simpleBufAccessor->obtain();
|
||||
auto bufAccessor = std::make_unique<BufAccessor>(conn->udpSendPacketLen * 16);
|
||||
auto outputBuf = bufAccessor->obtain();
|
||||
auto bufPtr = outputBuf.get();
|
||||
simpleBufAccessor->release(std::move(outputBuf));
|
||||
conn->bufAccessor = simpleBufAccessor.get();
|
||||
bufAccessor->release(std::move(outputBuf));
|
||||
conn->bufAccessor = bufAccessor.get();
|
||||
conn->transportSettings.batchingMode = QuicBatchingMode::BATCHING_MODE_GSO;
|
||||
EventBase evb;
|
||||
std::shared_ptr<FollyQuicEventBase> qEvb =
|
||||
@@ -4409,7 +4406,7 @@ TEST_F(QuicTransportFunctionsTest, WriteProbingWithInplaceBuilder) {
|
||||
quic::test::MockAsyncUDPSocket mockSock(qEvb);
|
||||
EXPECT_CALL(mockSock, getGSO()).WillRepeatedly(Return(true));
|
||||
|
||||
SimpleBufAccessor bufAccessor(
|
||||
BufAccessor bufAccessor(
|
||||
conn->udpSendPacketLen * conn->transportSettings.maxBatchSize);
|
||||
conn->bufAccessor = &bufAccessor;
|
||||
auto buf = bufAccessor.obtain();
|
||||
|
Reference in New Issue
Block a user