winlin

fix #257, server latency is 0.1s+, the bottleneck is encoder. 2.0.71

... ... @@ -786,6 +786,10 @@ The latency between encoder and player with realtime config(
</tr>
</table>
We use FMLE as encoder to benchmark. The latency of server is 0.1s+,
and the bottleneck is on the encoder. For more information, read
[bug #257](https://github.com/winlinvip/simple-rtmp-server/issues/257#issuecomment-66864413).
## Architecture
SRS always use the most simple architecture to support complex transaction.
... ...
... ... @@ -589,11 +589,12 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd)
bool user_specified_duration_to_stop = (req->duration > 0);
int64_t starttime = -1;
// setup the realtime.
realtime = _srs_config->get_realtime_enabled(req->vhost);
// setup the mw config.
// when mw_sleep changed, resize the socket send buffer.
mw_enabled = true;
change_mw_sleep(_srs_config->get_mw_sleep_ms(req->vhost));
realtime = _srs_config->get_realtime_enabled(req->vhost);
while (true) {
// to use isolate thread to recv, can improve about 33% performance.
... ... @@ -641,23 +642,6 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd)
srs_error("get messages from consumer failed. ret=%d", ret);
return ret;
}
#ifdef SRS_PERF_QUEUE_COND_WAIT
// we use wait timeout to get messages,
// for min latency event no message incoming,
// so the count maybe zero.
srs_info("mw wait %dms and got %d msgs %d(%"PRId64"-%"PRId64")ms",
mw_sleep, count,
(count > 0? msgs.msgs[count - 1]->timestamp - msgs.msgs[0]->timestamp : 0),
(count > 0? msgs.msgs[0]->timestamp : 0),
(count > 0? msgs.msgs[count - 1]->timestamp : 0));
#else
if (count <= 0) {
srs_info("mw sleep %dms for no msg", mw_sleep);
st_usleep(mw_sleep * 1000);
}
#endif
srs_info("got %d msgs, min=%d, mw=%d", count, SRS_PERF_MW_MIN_MSGS, mw_sleep);
// reportable
if (pithy_print.can_print()) {
... ... @@ -671,6 +655,29 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd)
);
}
// we use wait timeout to get messages,
// for min latency event no message incoming,
// so the count maybe zero.
if (count > 0) {
srs_verbose("mw wait %dms and got %d msgs %d(%"PRId64"-%"PRId64")ms",
mw_sleep, count,
(count > 0? msgs.msgs[count - 1]->timestamp - msgs.msgs[0]->timestamp : 0),
(count > 0? msgs.msgs[0]->timestamp : 0),
(count > 0? msgs.msgs[count - 1]->timestamp : 0));
}
if (count <= 0) {
#ifndef SRS_PERF_QUEUE_COND_WAIT
srs_info("mw sleep %dms for no msg", mw_sleep);
st_usleep(mw_sleep * 1000);
#else
srs_verbose("mw wait %dms and got nothing.", mw_sleep);
#endif
// ignore when nothing got.
continue;
}
srs_info("got %d msgs, min=%d, mw=%d", count, SRS_PERF_MW_MIN_MSGS, mw_sleep);
// only when user specifies the duration,
// we start to collect the durations for each message.
if (user_specified_duration_to_stop) {
... ...
... ... @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 70
#define VERSION_REVISION 71
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
#define RTMP_SIG_SRS_ROLE "origin/edge server"
... ...