winlin

for #320, set socket send buffer to smaller macro. 2.0.131

... ... @@ -1110,6 +1110,11 @@ void SrsRtmpConn::change_mw_sleep(int sleep_ms)
// socket send buffer, system will double it.
int nb_sbuf = socket_buffer_size / 2;
// override the send buffer by macro.
#ifdef SRS_PERF_SO_SNDBUF_SIZE
nb_sbuf = SRS_PERF_SO_SNDBUF_SIZE / 2;
#endif
// set the socket send buffer when required larger buffer
if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &nb_sbuf, sock_buf_size) < 0) {
srs_warn("set sock SO_SENDBUF=%d failed.", nb_sbuf);
... ...
... ... @@ -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 130
#define VERSION_REVISION 131
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
... ...
... ... @@ -169,6 +169,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//#define SRS_PERF_TCP_NODELAY
#undef SRS_PERF_TCP_NODELAY
/**
* set the socket send buffer,
* to force the server to send smaller tcp packet.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/320
* @remark undef it to auto calc it by merged write sleep ms.
* @remark only apply it when SRS_PERF_MW_SO_RCVBUF is defined.
*/
#ifdef SRS_PERF_MW_SO_SNDBUF
//#define SRS_PERF_SO_SNDBUF_SIZE 1024
#undef SRS_PERF_SO_SNDBUF_SIZE
#endif
#endif
... ...
... ... @@ -148,6 +148,24 @@ void show_macro_features()
srs_trace("MW(merged-write) default sleep %d", SRS_PERF_MW_SLEEP);
srs_trace("read chunk stream cache cid [0, %d)", SRS_PERF_CHUNK_STREAM_CACHE);
srs_trace("default gop cache %d, play queue %ds", SRS_PERF_GOP_CACHE, SRS_PERF_PLAY_QUEUE);
#ifndef SRS_PERF_COMPLEX_SEND
srs_warn("complex send algorithm disabled.");
#else
srs_trace("complex send algorithm enabled.");
#endif
#ifdef SRS_PERF_TCP_NODELAY
srs_warn("TCP_NODELAY enabled, hurts performance.");
#else
srs_trace("TCP_NODELAY disabled.");
#endif
#ifdef SRS_PERF_SO_SNDBUF_SIZE
srs_warn("socket send buffer size %d", SRS_PERF_SO_SNDBUF_SIZE);
#else
srs_trace("auto guess socket send buffer by merged write");
#endif
int possible_mr_latency = 0;
#ifdef SRS_PERF_MERGED_READ
... ... @@ -170,6 +188,10 @@ void check_macro_features()
#warning "using develop SRS, please use release instead."
srs_warn("SRS %s is develop branch, please use %s instead", RTMP_SIG_SRS_VERSION, RTMP_SIG_SRS_RELEASE);
#endif
#if defined(SRS_PERF_SO_SNDBUF_SIZE) && !defined(SRS_PERF_MW_SO_SNDBUF)
#error "SRS_PERF_SO_SNDBUF_SIZE depends on SRS_PERF_MW_SO_SNDBUF"
#endif
}
/**
... ...