Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibUring: Enable liburing usage for SCTP data delivery #1249

Merged
merged 4 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog


### Next

* LibUring: Enable liburing usage for SCTP data delivery ([PR 1249](https://github.com/versatica/mediasoup/pull/1249)).


### 3.13.7

* Update worker dependencies ([PR #1201](https://github.com/versatica/mediasoup/pull/1201)):
Expand Down
17 changes: 17 additions & 0 deletions worker/src/DepUsrSCTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// #define MS_LOG_DEV_LEVEL 3

#include "DepUsrSCTP.hpp"
#ifdef MS_LIBURING_SUPPORTED
#include "DepLibUring.hpp"
#endif
#include "DepLibUV.hpp"
#include "Logger.hpp"
#include <usrsctp.h>
Expand Down Expand Up @@ -249,7 +252,21 @@ void DepUsrSCTP::Checker::OnTimer(TimerHandle* /*timer*/)
auto nowMs = DepLibUV::GetTimeMs();
const int elapsedMs = this->lastCalledAtMs ? static_cast<int>(nowMs - this->lastCalledAtMs) : 0;

#ifdef MS_LIBURING_SUPPORTED
// Activate liburing usage.
// 'usrsctp_handle_timers()' will synchronously call the send/recv
// callbacks for the pending data. If there are multiple messages to be
// sent over the network then we will send those messages within a single
// system call.
DepLibUring::SetActive();
#endif

usrsctp_handle_timers(elapsedMs);

#ifdef MS_LIBURING_SUPPORTED
// Submit all prepared submission entries.
DepLibUring::Submit();
ibc marked this conversation as resolved.
Show resolved Hide resolved
#endif

this->lastCalledAtMs = nowMs;
}
19 changes: 17 additions & 2 deletions worker/src/RTC/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,9 +921,24 @@ namespace RTC

auto& dataConsumers = this->mapDataProducerDataConsumers.at(dataProducer);

for (auto* dataConsumer : dataConsumers)
if (!dataConsumers.empty())
{
dataConsumer->SendMessage(msg, len, ppid, subchannels, requiredSubchannel);
#ifdef MS_LIBURING_SUPPORTED
// Activate liburing usage.
// The effective sending could be synchronous, thus we would send those
// messages within a single system call.
DepLibUring::SetActive();
#endif

for (auto* dataConsumer : dataConsumers)
{
dataConsumer->SendMessage(msg, len, ppid, subchannels, requiredSubchannel);
}

#ifdef MS_LIBURING_SUPPORTED
// Submit all prepared submission entries.
DepLibUring::Submit();
#endif
}
}

Expand Down