Use unordered_map in RTCPReceiver

In highly loaded media servers, RTCPReceiver's use of std::map
attributes to ~0.5% CPU. It's mostly ::find and the [] operator, and
they are all keyed by SSRC, which is an unordered data type. This makes
these maps suitable as unordered maps, as they have constant time
complexity for lookups.

Bug: webrtc:12689
Change-Id: I7b305e233fcbed0e452632946ab0de5ee66f8dda
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/216321
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33850}
This commit is contained in:
Victor Boivie
2021-04-27 10:24:01 +02:00
committed by WebRTC LUCI CQ
parent 306b1393cb
commit 0c563a42ec
2 changed files with 17 additions and 9 deletions

View File

@ -51,6 +51,7 @@ using rtcp::ReceiveTimeInfo;
using ::testing::_;
using ::testing::AllOf;
using ::testing::ElementsAreArray;
using ::testing::Eq;
using ::testing::Field;
using ::testing::InSequence;
using ::testing::IsEmpty;
@ -1266,16 +1267,17 @@ TEST(RtcpReceiverTest, TmmbrThreeConstraintsTimeOut) {
mocks.clock.AdvanceTimeMilliseconds(5000);
}
// It is now starttime + 15.
std::vector<rtcp::TmmbItem> candidate_set = receiver.TmmbrReceived();
ASSERT_EQ(3u, candidate_set.size());
EXPECT_EQ(30000U, candidate_set[0].bitrate_bps());
EXPECT_THAT(receiver.TmmbrReceived(),
AllOf(SizeIs(3),
Each(Property(&rtcp::TmmbItem::bitrate_bps, Eq(30'000U)))));
// We expect the timeout to be 25 seconds. Advance the clock by 12
// seconds, timing out the first packet.
mocks.clock.AdvanceTimeMilliseconds(12000);
candidate_set = receiver.TmmbrReceived();
ASSERT_EQ(2u, candidate_set.size());
EXPECT_EQ(kSenderSsrc + 1, candidate_set[0].ssrc());
EXPECT_THAT(receiver.TmmbrReceived(),
UnorderedElementsAre(
Property(&rtcp::TmmbItem::ssrc, Eq(kSenderSsrc + 1)),
Property(&rtcp::TmmbItem::ssrc, Eq(kSenderSsrc + 2))));
}
TEST(RtcpReceiverTest, Callbacks) {