正在显示
2 个修改的文件
包含
15 行增加
和
2 行删除
| @@ -49,6 +49,7 @@ using namespace std; | @@ -49,6 +49,7 @@ using namespace std; | ||
| 49 | #include <srs_protocol_msg_array.hpp> | 49 | #include <srs_protocol_msg_array.hpp> |
| 50 | #include <srs_protocol_amf0.hpp> | 50 | #include <srs_protocol_amf0.hpp> |
| 51 | #include <srs_app_recv_thread.hpp> | 51 | #include <srs_app_recv_thread.hpp> |
| 52 | +#include <srs_core_performance.hpp> | ||
| 52 | 53 | ||
| 53 | // when stream is busy, for example, streaming is already | 54 | // when stream is busy, for example, streaming is already |
| 54 | // publishing, when a new client to request to publish, | 55 | // publishing, when a new client to request to publish, |
| @@ -591,7 +592,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd) | @@ -591,7 +592,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd) | ||
| 591 | // no message to send, sleep a while. | 592 | // no message to send, sleep a while. |
| 592 | if (count <= 0) { | 593 | if (count <= 0) { |
| 593 | srs_verbose("sleep for no messages to send"); | 594 | srs_verbose("sleep for no messages to send"); |
| 594 | - st_usleep(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); | 595 | + st_usleep(SRS_PERF_SEND_MSGS_CACHE * 1000); |
| 595 | } | 596 | } |
| 596 | 597 | ||
| 597 | // reportable | 598 | // reportable |
| @@ -64,8 +64,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -64,8 +64,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 64 | * buffer=65536B, small=4096B, sleep=780ms | 64 | * buffer=65536B, small=4096B, sleep=780ms |
| 65 | * that is, when got nread bytes smaller than 4KB, sleep(780ms). | 65 | * that is, when got nread bytes smaller than 4KB, sleep(780ms). |
| 66 | */ | 66 | */ |
| 67 | -#define SRS_PERF_MERGED_READ | ||
| 68 | #undef SRS_PERF_MERGED_READ | 67 | #undef SRS_PERF_MERGED_READ |
| 68 | +#define SRS_PERF_MERGED_READ | ||
| 69 | + | ||
| 70 | +/** | ||
| 71 | +* the send cache time in ms. | ||
| 72 | +* to improve send performance, cache msgs and send in a time. | ||
| 73 | +* for example, cache 500ms videos and audios, then convert all these | ||
| 74 | +* msgs to iovecs, finally use writev to send. | ||
| 75 | +* @remark this largely improve performance, from 3.5k+ to 7.5k+. | ||
| 76 | +* the latency+ when cache+. | ||
| 77 | +* @remark the socket send buffer default to 185KB, it large enough. | ||
| 78 | +* @see https://github.com/winlinvip/simple-rtmp-server/issues/194 | ||
| 79 | +*/ | ||
| 80 | +#define SRS_PERF_SEND_MSGS_CACHE 500 | ||
| 69 | 81 | ||
| 70 | #endif | 82 | #endif |
| 71 | 83 |
-
请 注册 或 登录 后发表评论