Use flat_map in ReceiveStatisticsImpl
std::unordered_map represents ~0.57% CPU in a loaded media server, which is expected to be reduced by using flat_map and its increased cache locality compared to std::unordered_map, which use quite a few allocations and indirections. The number of SSRCs tracked by this class is expected to be low and infrequently updated, but as GetOrCreateStatistician is called for every incoming RTP packet, lookups are frequent. Bug: webrtc:12689 Change-Id: I9a2c3798dcc7822f518e8f2624e78fceacd12d27 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/225202 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Victor Boivie <boivie@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34430}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
ac5f2e7203
commit
18649971ab
@ -14,7 +14,6 @@
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -22,6 +21,7 @@
|
||||
#include "modules/include/module_common_types_public.h"
|
||||
#include "modules/rtp_rtcp/include/receive_statistics.h"
|
||||
#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
|
||||
#include "rtc_base/containers/flat_map.h"
|
||||
#include "rtc_base/rate_statistics.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/thread_annotations.h"
|
||||
@ -195,8 +195,7 @@ class ReceiveStatisticsImpl : public ReceiveStatistics {
|
||||
size_t last_returned_ssrc_idx_;
|
||||
std::vector<uint32_t> all_ssrcs_;
|
||||
int max_reordering_threshold_;
|
||||
std::unordered_map<uint32_t /*ssrc*/,
|
||||
std::unique_ptr<StreamStatisticianImplInterface>>
|
||||
flat_map<uint32_t /*ssrc*/, std::unique_ptr<StreamStatisticianImplInterface>>
|
||||
statisticians_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user