Skip to content

Commit

Permalink
LibUring: Enable liburing usage for SCTP data delivery (#1249)
Browse files Browse the repository at this point in the history
liburing: Enable liburing usage for SCTP data delivery
  • Loading branch information
jmillan authored Dec 4, 2023
1 parent bf57b8a commit b986e21
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
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();
#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

0 comments on commit b986e21

Please sign in to comment.