Revert "Improve performance of RtpPacketHistory"
This reverts commit 9e380fd484db09c37323b90a19c5ce7965927975. Reason for revert: breaking downstream projects Original change's description: > Improve performance of RtpPacketHistory > > The data structures in RtpPacketHistory were chosen based on assumption > of few packets with possible sparse segments due to missing acking. > In practice high bitrate usages with full histories seem to be more of > a problem. > Due to that, change storage from an std::map to an std::deque and live > with potential segments of nullptr. Also limit size of padding prio > set so that doesn't become a bottleneck. > > Bug: webrtc:8975 > Change-Id: I3b6314fb3255937d25362ff2cd906efb7b1397f7 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145901 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29117} TBR=danilchap@webrtc.org,sprang@webrtc.org Change-Id: I5d5b74a6f4d60588e01a52dafe33e26deb9bdf77 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8975 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/152220 Reviewed-by: Qingsi Wang <qingsi@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29121}
This commit is contained in:
@ -11,7 +11,6 @@
|
||||
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_PACKET_HISTORY_H_
|
||||
#define MODULES_RTP_RTCP_SOURCE_RTP_PACKET_HISTORY_H_
|
||||
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
@ -54,8 +53,6 @@ class RtpPacketHistory {
|
||||
|
||||
// Maximum number of packets we ever allow in the history.
|
||||
static constexpr size_t kMaxCapacity = 9600;
|
||||
// Maximum number of entries in prioritized queue of padding packets.
|
||||
static constexpr size_t kMaxPaddingtHistory = 63;
|
||||
// Don't remove packets within max(1000ms, 3x RTT).
|
||||
static constexpr int64_t kMinPacketDurationMs = 1000;
|
||||
static constexpr int kMinPacketDurationRtt = 3;
|
||||
@ -174,6 +171,8 @@ class RtpPacketHistory {
|
||||
bool operator()(StoredPacket* lhs, StoredPacket* rhs) const;
|
||||
};
|
||||
|
||||
using StoredPacketIterator = std::map<uint16_t, StoredPacket>::iterator;
|
||||
|
||||
// Helper method used by GetPacketAndSetSendTime() and GetPacketState() to
|
||||
// check if packet has too recently been sent.
|
||||
bool VerifyRtt(const StoredPacket& packet, int64_t now_ms) const
|
||||
@ -182,11 +181,7 @@ class RtpPacketHistory {
|
||||
void CullOldPackets(int64_t now_ms) RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_);
|
||||
// Removes the packet from the history, and context/mapping that has been
|
||||
// stored. Returns the RTP packet instance contained within the StoredPacket.
|
||||
std::unique_ptr<RtpPacketToSend> RemovePacket(int packet_index)
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_);
|
||||
int GetPacketIndex(uint16_t sequence_number) const
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_);
|
||||
StoredPacket* GetStoredPacket(uint16_t sequence_number)
|
||||
std::unique_ptr<RtpPacketToSend> RemovePacket(StoredPacketIterator packet)
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_);
|
||||
static PacketState StoredPacketToPacketState(
|
||||
const StoredPacket& stored_packet);
|
||||
@ -197,13 +192,8 @@ class RtpPacketHistory {
|
||||
StorageMode mode_ RTC_GUARDED_BY(lock_);
|
||||
int64_t rtt_ms_ RTC_GUARDED_BY(lock_);
|
||||
|
||||
// Queue of stored packets, ordered by sequence number, with older packets in
|
||||
// the front and new packets being added to the back. Note that there may be
|
||||
// wrap-arounds so the back may have a lower sequence number.
|
||||
// Packets may also be removed out-of-order, in which case there will be
|
||||
// instances of StoredPacket with |packet_| set to nullptr. The first and last
|
||||
// entry in the queue will however always be populated.
|
||||
std::deque<StoredPacket> packet_history_ RTC_GUARDED_BY(lock_);
|
||||
// Map from rtp sequence numbers to stored packet.
|
||||
std::map<uint16_t, StoredPacket> packet_history_ RTC_GUARDED_BY(lock_);
|
||||
|
||||
// Total number of packets with inserted.
|
||||
uint64_t packets_inserted_ RTC_GUARDED_BY(lock_);
|
||||
@ -211,6 +201,10 @@ class RtpPacketHistory {
|
||||
// in GetPayloadPaddingPacket().
|
||||
PacketPrioritySet padding_priority_ RTC_GUARDED_BY(lock_);
|
||||
|
||||
// The earliest packet in the history. This might not be the lowest sequence
|
||||
// number, in case there is a wraparound.
|
||||
absl::optional<uint16_t> start_seqno_ RTC_GUARDED_BY(lock_);
|
||||
|
||||
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtpPacketHistory);
|
||||
};
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user