正在显示
4 个修改的文件
包含
39 行增加
和
1 行删除
| @@ -1110,6 +1110,11 @@ void SrsRtmpConn::change_mw_sleep(int sleep_ms) | @@ -1110,6 +1110,11 @@ void SrsRtmpConn::change_mw_sleep(int sleep_ms) | ||
| 1110 | // socket send buffer, system will double it. | 1110 | // socket send buffer, system will double it. |
| 1111 | int nb_sbuf = socket_buffer_size / 2; | 1111 | int nb_sbuf = socket_buffer_size / 2; |
| 1112 | 1112 | ||
| 1113 | + // override the send buffer by macro. | ||
| 1114 | + #ifdef SRS_PERF_SO_SNDBUF_SIZE | ||
| 1115 | + nb_sbuf = SRS_PERF_SO_SNDBUF_SIZE / 2; | ||
| 1116 | + #endif | ||
| 1117 | + | ||
| 1113 | // set the socket send buffer when required larger buffer | 1118 | // set the socket send buffer when required larger buffer |
| 1114 | if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &nb_sbuf, sock_buf_size) < 0) { | 1119 | if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &nb_sbuf, sock_buf_size) < 0) { |
| 1115 | srs_warn("set sock SO_SENDBUF=%d failed.", nb_sbuf); | 1120 | 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. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 130 | 34 | +#define VERSION_REVISION 131 |
| 35 | 35 | ||
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
| @@ -169,6 +169,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -169,6 +169,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 169 | */ | 169 | */ |
| 170 | //#define SRS_PERF_TCP_NODELAY | 170 | //#define SRS_PERF_TCP_NODELAY |
| 171 | #undef SRS_PERF_TCP_NODELAY | 171 | #undef SRS_PERF_TCP_NODELAY |
| 172 | +/** | ||
| 173 | +* set the socket send buffer, | ||
| 174 | +* to force the server to send smaller tcp packet. | ||
| 175 | +* @see https://github.com/winlinvip/simple-rtmp-server/issues/320 | ||
| 176 | +* @remark undef it to auto calc it by merged write sleep ms. | ||
| 177 | +* @remark only apply it when SRS_PERF_MW_SO_RCVBUF is defined. | ||
| 178 | +*/ | ||
| 179 | +#ifdef SRS_PERF_MW_SO_SNDBUF | ||
| 180 | + //#define SRS_PERF_SO_SNDBUF_SIZE 1024 | ||
| 181 | + #undef SRS_PERF_SO_SNDBUF_SIZE | ||
| 182 | +#endif | ||
| 172 | 183 | ||
| 173 | #endif | 184 | #endif |
| 174 | 185 |
| @@ -148,6 +148,24 @@ void show_macro_features() | @@ -148,6 +148,24 @@ void show_macro_features() | ||
| 148 | srs_trace("MW(merged-write) default sleep %d", SRS_PERF_MW_SLEEP); | 148 | srs_trace("MW(merged-write) default sleep %d", SRS_PERF_MW_SLEEP); |
| 149 | srs_trace("read chunk stream cache cid [0, %d)", SRS_PERF_CHUNK_STREAM_CACHE); | 149 | srs_trace("read chunk stream cache cid [0, %d)", SRS_PERF_CHUNK_STREAM_CACHE); |
| 150 | srs_trace("default gop cache %d, play queue %ds", SRS_PERF_GOP_CACHE, SRS_PERF_PLAY_QUEUE); | 150 | srs_trace("default gop cache %d, play queue %ds", SRS_PERF_GOP_CACHE, SRS_PERF_PLAY_QUEUE); |
| 151 | + | ||
| 152 | +#ifndef SRS_PERF_COMPLEX_SEND | ||
| 153 | + srs_warn("complex send algorithm disabled."); | ||
| 154 | +#else | ||
| 155 | + srs_trace("complex send algorithm enabled."); | ||
| 156 | +#endif | ||
| 157 | + | ||
| 158 | +#ifdef SRS_PERF_TCP_NODELAY | ||
| 159 | + srs_warn("TCP_NODELAY enabled, hurts performance."); | ||
| 160 | +#else | ||
| 161 | + srs_trace("TCP_NODELAY disabled."); | ||
| 162 | +#endif | ||
| 163 | + | ||
| 164 | +#ifdef SRS_PERF_SO_SNDBUF_SIZE | ||
| 165 | + srs_warn("socket send buffer size %d", SRS_PERF_SO_SNDBUF_SIZE); | ||
| 166 | +#else | ||
| 167 | + srs_trace("auto guess socket send buffer by merged write"); | ||
| 168 | +#endif | ||
| 151 | 169 | ||
| 152 | int possible_mr_latency = 0; | 170 | int possible_mr_latency = 0; |
| 153 | #ifdef SRS_PERF_MERGED_READ | 171 | #ifdef SRS_PERF_MERGED_READ |
| @@ -170,6 +188,10 @@ void check_macro_features() | @@ -170,6 +188,10 @@ void check_macro_features() | ||
| 170 | #warning "using develop SRS, please use release instead." | 188 | #warning "using develop SRS, please use release instead." |
| 171 | srs_warn("SRS %s is develop branch, please use %s instead", RTMP_SIG_SRS_VERSION, RTMP_SIG_SRS_RELEASE); | 189 | srs_warn("SRS %s is develop branch, please use %s instead", RTMP_SIG_SRS_VERSION, RTMP_SIG_SRS_RELEASE); |
| 172 | #endif | 190 | #endif |
| 191 | + | ||
| 192 | +#if defined(SRS_PERF_SO_SNDBUF_SIZE) && !defined(SRS_PERF_MW_SO_SNDBUF) | ||
| 193 | + #error "SRS_PERF_SO_SNDBUF_SIZE depends on SRS_PERF_MW_SO_SNDBUF" | ||
| 194 | +#endif | ||
| 173 | } | 195 | } |
| 174 | 196 | ||
| 175 | /** | 197 | /** |
-
请 注册 或 登录 后发表评论