From fc9855bc7ac0cf92b5fd657a30e4be9b13e78af5 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 19 Dec 2019 15:04:14 +0800 Subject: [PATCH] Refine the RTMP iovs cache increasing to much faster. --- README.md | 1 + trunk/src/protocol/srs_rtmp_stack.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4465f6011..cd85423c0 100755 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2019-12-19, Refine the RTMP iovs cache increasing to much faster. * v3.0, 2019-12-19, Fix [#1524][bug #1524], memory leak for amf0 strict array. 3.0.75 * v3.0, 2019-12-19, Fix random build failed bug for modules. * v3.0, 2019-12-19, Fix [#1520][bug #1520] and [#1223][bug #1223], bug for origin cluster 3+ servers. 3.0.74 diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index 2ff3a94f2..89105bf6f 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -231,7 +231,7 @@ SrsProtocol::SrsProtocol(ISrsProtocolReadWriter* io) in_chunk_size = SRS_CONSTS_RTMP_PROTOCOL_CHUNK_SIZE; out_chunk_size = SRS_CONSTS_RTMP_PROTOCOL_CHUNK_SIZE; - nb_out_iovs = SRS_CONSTS_IOVS_MAX; + nb_out_iovs = 8 * SRS_CONSTS_IOVS_MAX; out_iovs = (iovec*)malloc(sizeof(iovec) * nb_out_iovs); // each chunk consumers atleast 2 iovs srs_assert(nb_out_iovs >= 2); @@ -486,11 +486,11 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg // for we donot know how many messges maybe to send entirely, // we just alloc the iovs, it's ok. if (iov_index >= nb_out_iovs - 2) { - srs_warn("resize iovs %d => %d, max_msgs=%d", nb_out_iovs, nb_out_iovs + SRS_CONSTS_IOVS_MAX, SRS_PERF_MW_MSGS); - - nb_out_iovs += SRS_CONSTS_IOVS_MAX; + int ov = nb_out_iovs; + nb_out_iovs = 2 * nb_out_iovs; int realloc_size = sizeof(iovec) * nb_out_iovs; out_iovs = (iovec*)realloc(out_iovs, realloc_size); + srs_warn("resize iovs %d => %d, max_msgs=%d", ov, nb_out_iovs, SRS_PERF_MW_MSGS); } // to next pair of iovs