From 723873b841ea12a814b983b71933389245fd07e1 Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Tue, 27 Apr 2021 10:13:46 +0200 Subject: [PATCH] Use unordered map in RoundRobinPacketQueue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In highly loaded Media Servers, RoundRobinPacketQueue's usage of std::map attributes to around 0.3% CPU. In profiling, it has been found that it's the `streams_` map that is the culprit and std::map::find being the function that is used most. By using an unordered map, lookups should be faster. This will be evaluated and if this commit doesn't show results, it will be reverted. Bug: webrtc:12689 Change-Id: Ia368f1184130298cfbb9064528828435aa7a5c66 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/216320 Reviewed-by: Erik Språng Commit-Queue: Victor Boivie Cr-Commit-Position: refs/heads/master@{#33848} --- modules/pacing/round_robin_packet_queue.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/pacing/round_robin_packet_queue.h b/modules/pacing/round_robin_packet_queue.h index 9446a8e174..cad555a1af 100644 --- a/modules/pacing/round_robin_packet_queue.h +++ b/modules/pacing/round_robin_packet_queue.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "absl/types/optional.h" #include "api/transport/webrtc_key_value_config.h" @@ -163,7 +164,7 @@ class RoundRobinPacketQueue { std::multimap stream_priorities_; // A map of SSRCs to Streams. - std::map streams_; + std::unordered_map streams_; // The enqueue time of every packet currently in the queue. Used to figure out // the age of the oldest packet in the queue.