Unverified 提交 df26c9ed authored 作者: José Luis Millán's avatar José Luis Millán 提交者: GitHub

SeqManager: performance, invert std::distance range (#1068)

* SeqManager: performance, invert std::distance range

Fixes #1067.

There are way more dropped elements in the range [begin(), input] than
[input, end()] and std::distance complexity is linear.

* SeqManager: performance, explicitly insert the dropped input at the end

Which is more performant as std::set does not need to calculate its
position.

* Update CHANGELOG
上级 d146ee5b
# Changelog
### 3.11.24
* `SeqManager`: Fix performance regression ([PR #1068](https://github.com/versatica/mediasoup/pull/1068), thanks to @vpalmisano for properly reporting).
### 3.11.23
* Node: Fix `appData` for `Transport` and `RtpObserver` parent classes ([PR #1066](https://github.com/versatica/mediasoup/pull/1066)).
......
......@@ -59,7 +59,10 @@ namespace RTC
if (SeqManager<T, N>::IsSeqHigherThan(input, this->maxInput))
{
this->maxInput = input;
this->dropped.insert(input);
// Insert input in the last position.
// Explicitly indicate insert() to add the input at the end, which is
// more performant.
this->dropped.insert(this->dropped.end(), input);
ClearDropped();
}
......@@ -104,15 +107,13 @@ namespace RTC
// There are dropped inputs, calculate 'base' for this input.
else
{
auto droppedCount = this->dropped.size();
// Get the first dropped input which is higher than or equal 'input'.
auto it = this->dropped.lower_bound(input);
// There are dropped inputs lower than 'input'.
if (it != this->dropped.begin())
{
auto count = std::distance(this->dropped.begin(), it);
base = (this->base - count) & MaxValue;
}
droppedCount -= std::distance(it, this->dropped.end());
base = (this->base - droppedCount) & MaxValue;
}
done:
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论