1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine for bug #241, increase the small bytes for merged read.

This commit is contained in:
winlin 2014-12-04 09:10:57 +08:00
parent d1d6023c70
commit 315f981821
4 changed files with 19 additions and 19 deletions

View file

@ -37,14 +37,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_MR_AVERAGE_BITRATE_KBPS 1000 #define SRS_MR_AVERAGE_BITRATE_KBPS 1000
#define SRS_MR_MIN_BITRATE_KBPS 32 #define SRS_MR_MIN_BITRATE_KBPS 32
// the max sleep time in ms // the max sleep time in ms
#define SRS_MR_MAX_SLEEP_MS 3000 #define SRS_MR_MAX_SLEEP_MS 2500
// the max small bytes to group // the max small bytes to group
#define SRS_MR_SMALL_BYTES 64 #define SRS_MR_SMALL_BYTES 4096
// the percent of buffer to set as small bytes // the percent of buffer to set as small bytes
#define SRS_MR_SMALL_PERCENT 100 #define SRS_MR_SMALL_PERCENT 100
// set the socket buffer to specified KB. // set the socket buffer to specified bytes.
// the underlayer api will set to 2*SRS_MR_SOCKET_BUFFER KB. // the underlayer api will set to SRS_MR_SOCKET_BUFFER bytes.
#define SRS_MR_SOCKET_BUFFER 32 #define SRS_MR_SOCKET_BUFFER SOCKET_READ_SIZE
ISrsMessageHandler::ISrsMessageHandler() ISrsMessageHandler::ISrsMessageHandler()
{ {
@ -299,15 +299,15 @@ void SrsPublishRecvThread::on_thread_start()
// we donot set the auto response to false, // we donot set the auto response to false,
// for the main thread never send message. // for the main thread never send message.
// socket recv buffer. // socket recv buffer, system will double it.
int nb_rbuf = SRS_MR_SOCKET_BUFFER * 1024; int nb_rbuf = SRS_MR_SOCKET_BUFFER / 2;
socklen_t sock_buf_size = sizeof(int); socklen_t sock_buf_size = sizeof(int);
if (setsockopt(mr_fd, SOL_SOCKET, SO_RCVBUF, &nb_rbuf, sock_buf_size) < 0) { if (setsockopt(mr_fd, SOL_SOCKET, SO_RCVBUF, &nb_rbuf, sock_buf_size) < 0) {
srs_warn("set sock SO_RCVBUF=%d failed.", nb_rbuf); srs_warn("set sock SO_RCVBUF=%d failed.", nb_rbuf);
} }
getsockopt(mr_fd, SOL_SOCKET, SO_RCVBUF, &nb_rbuf, &sock_buf_size); getsockopt(mr_fd, SOL_SOCKET, SO_RCVBUF, &nb_rbuf, &sock_buf_size);
srs_trace("set socket buffer to %d, actual %d KB", SRS_MR_SOCKET_BUFFER, nb_rbuf / 1024); srs_trace("set socket buffer to %d, actual %d KB", SRS_MR_SOCKET_BUFFER / 1024, nb_rbuf / 1024);
// enable the merge read // enable the merge read
// @see https://github.com/winlinvip/simple-rtmp-server/issues/241 // @see https://github.com/winlinvip/simple-rtmp-server/issues/241
@ -381,7 +381,7 @@ void SrsPublishRecvThread::on_buffer_change(int nb_buffer)
// set percent. // set percent.
mr_small_bytes = (int)(nb_buffer / SRS_MR_SMALL_PERCENT); mr_small_bytes = (int)(nb_buffer / SRS_MR_SMALL_PERCENT);
// select the smaller // select the smaller
mr_small_bytes = srs_min(mr_small_bytes, SRS_MR_SMALL_BYTES); mr_small_bytes = srs_max(mr_small_bytes, SRS_MR_SMALL_BYTES);
// the recv sleep is [buffer / max_kbps, buffer / min_kbps] // the recv sleep is [buffer / max_kbps, buffer / min_kbps]
// for example, buffer is 256KB, max kbps is 10Mbps, min kbps is 10Kbps, // for example, buffer is 256KB, max kbps is 10Mbps, min kbps is 10Kbps,

0
trunk/src/qt/srs/srs-qt.pro.user Normal file → Executable file
View file

View file

@ -27,16 +27,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_kernel_log.hpp> #include <srs_kernel_log.hpp>
#include <srs_kernel_utility.hpp> #include <srs_kernel_utility.hpp>
// 4KB=4096
// 8KB=8192
// 16KB=16384
// 32KB=32768
// 64KB=65536
// @see https://github.com/winlinvip/simple-rtmp-server/issues/241
#define SOCKET_READ_SIZE 65536
// the max buffer for user space socket buffer.
#define SOCKET_MAX_BUF 65536
IMergeReadHandler::IMergeReadHandler() IMergeReadHandler::IMergeReadHandler()
{ {
} }

View file

@ -34,6 +34,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_protocol_io.hpp> #include <srs_protocol_io.hpp>
// 4KB=4096
// 8KB=8192
// 16KB=16384
// 32KB=32768
// 64KB=65536
// @see https://github.com/winlinvip/simple-rtmp-server/issues/241
#define SOCKET_READ_SIZE 65536
// the max buffer for user space socket buffer.
#define SOCKET_MAX_BUF SOCKET_READ_SIZE
/** /**
* to improve read performance, merge some packets then read, * to improve read performance, merge some packets then read,
* when it on and read small bytes, we sleep to wait more data., * when it on and read small bytes, we sleep to wait more data.,