diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 3ba916879..9c60430e2 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -49,6 +49,7 @@ using namespace std; #include #include #include +#include // when stream is busy, for example, streaming is already // publishing, when a new client to request to publish, @@ -591,7 +592,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd) // no message to send, sleep a while. if (count <= 0) { srs_verbose("sleep for no messages to send"); - st_usleep(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); + st_usleep(SRS_PERF_SEND_MSGS_CACHE * 1000); } // reportable diff --git a/trunk/src/core/srs_core_performance.hpp b/trunk/src/core/srs_core_performance.hpp index ef207c3d5..f07e2bd37 100644 --- a/trunk/src/core/srs_core_performance.hpp +++ b/trunk/src/core/srs_core_performance.hpp @@ -64,8 +64,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * buffer=65536B, small=4096B, sleep=780ms * that is, when got nread bytes smaller than 4KB, sleep(780ms). */ -#define SRS_PERF_MERGED_READ #undef SRS_PERF_MERGED_READ +#define SRS_PERF_MERGED_READ + +/** +* the send cache time in ms. +* to improve send performance, cache msgs and send in a time. +* for example, cache 500ms videos and audios, then convert all these +* msgs to iovecs, finally use writev to send. +* @remark this largely improve performance, from 3.5k+ to 7.5k+. +* the latency+ when cache+. +* @remark the socket send buffer default to 185KB, it large enough. +* @see https://github.com/winlinvip/simple-rtmp-server/issues/194 +*/ +#define SRS_PERF_SEND_MSGS_CACHE 500 #endif