From 78bed75ef73dd3466de1f8d26b6738e7bb0bdd25 Mon Sep 17 00:00:00 2001 From: Matt Joras Date: Thu, 5 May 2022 16:22:02 -0700 Subject: [PATCH] Use a reserved std::vector in RegularQuicWritePacket Summary: The code has changed since this was made an inlined vector. We now see higher cost from copy operations due to this rather than being able to move the data around. Reviewed By: bschlinker Differential Revision: D36151209 fbshipit-source-id: 0b10558c6bd8ebfea9bb960aac36a6c4044fc95f --- quic/api/test/QuicTransportFunctionsTest.cpp | 2 +- quic/api/test/QuicTransportTest.cpp | 2 +- quic/codec/Types.h | 6 ++++-- quic/loss/test/QuicLossFunctionsTest.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/quic/api/test/QuicTransportFunctionsTest.cpp b/quic/api/test/QuicTransportFunctionsTest.cpp index 65dd54f29..d3617053e 100644 --- a/quic/api/test/QuicTransportFunctionsTest.cpp +++ b/quic/api/test/QuicTransportFunctionsTest.cpp @@ -88,7 +88,7 @@ void writeCryptoDataProbesToSocketForTest( } RegularQuicWritePacket stripPaddingFrames(RegularQuicWritePacket packet) { - SmallVec trimmedFrames{}; + RegularQuicWritePacket::Vec trimmedFrames{}; for (auto frame : packet.frames) { if (!frame.asPaddingFrame()) { trimmedFrames.push_back(frame); diff --git a/quic/api/test/QuicTransportTest.cpp b/quic/api/test/QuicTransportTest.cpp index e7feb2719..0662a7985 100644 --- a/quic/api/test/QuicTransportTest.cpp +++ b/quic/api/test/QuicTransportTest.cpp @@ -125,7 +125,7 @@ class QuicTransportTest : public Test { }; RegularQuicWritePacket stripPaddingFrames(RegularQuicWritePacket packet) { - SmallVec trimmedFrames{}; + RegularQuicWritePacket::Vec trimmedFrames{}; for (auto frame : packet.frames) { if (!frame.asPaddingFrame()) { trimmedFrames.push_back(frame); diff --git a/quic/codec/Types.h b/quic/codec/Types.h index 916cc5c29..45a4a1656 100644 --- a/quic/codec/Types.h +++ b/quic/codec/Types.h @@ -1062,11 +1062,13 @@ struct RegularQuicPacket : public RegularPacket { * A representation of a regular packet that is written to the network. */ struct RegularQuicWritePacket : public RegularPacket { - using Vec = SmallVec; + using Vec = std::vector; Vec frames; explicit RegularQuicWritePacket(PacketHeader&& headerIn) - : RegularPacket(std::move(headerIn)) {} + : RegularPacket(std::move(headerIn)) { + frames.reserve(8); + } }; /** diff --git a/quic/loss/test/QuicLossFunctionsTest.cpp b/quic/loss/test/QuicLossFunctionsTest.cpp index 401332ebc..ab9abcf68 100644 --- a/quic/loss/test/QuicLossFunctionsTest.cpp +++ b/quic/loss/test/QuicLossFunctionsTest.cpp @@ -309,7 +309,7 @@ PacketNum QuicLossFunctionsTest::sendPacket( } RegularQuicWritePacket stripPaddingFrames(RegularQuicWritePacket packet) { - SmallVec trimmedFrames{}; + RegularQuicWritePacket::Vec trimmedFrames{}; for (auto frame : packet.frames) { if (!frame.asPaddingFrame()) { trimmedFrames.push_back(frame);