winlin

for #405, improve the HTTP FLV delivery 1k to 2.3k. 2.0.168

@@ -326,7 +326,7 @@ Remark: @@ -326,7 +326,7 @@ Remark:
326 * 2014-04-28, [Release v1.0-mainline2](https://github.com/simple-rtmp-server/srs/releases/tag/1.0.mainline2), support [dvr](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_DVR), android, [edge](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_Edge). 35255 lines.<br/> 326 * 2014-04-28, [Release v1.0-mainline2](https://github.com/simple-rtmp-server/srs/releases/tag/1.0.mainline2), support [dvr](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_DVR), android, [edge](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_Edge). 35255 lines.<br/>
327 * 2014-04-07, [Release v1.0-mainline](https://github.com/simple-rtmp-server/srs/releases/tag/1.0.mainline), support [arm](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SrsLinuxArm), [init.d](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_LinuxService), http [server](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_HTTPServer)/[api](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_HTTPApi), [ingest](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SampleIngest). 30000 lines.<br/> 327 * 2014-04-07, [Release v1.0-mainline](https://github.com/simple-rtmp-server/srs/releases/tag/1.0.mainline), support [arm](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SrsLinuxArm), [init.d](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_LinuxService), http [server](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_HTTPServer)/[api](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_HTTPApi), [ingest](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SampleIngest). 30000 lines.<br/>
328 * 2013-12-25, [Release v0.9](https://github.com/simple-rtmp-server/srs/releases/tag/0.9), support bandwidth test, player/encoder/chat [demos](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SampleDemo). 20926 lines.<br/> 328 * 2013-12-25, [Release v0.9](https://github.com/simple-rtmp-server/srs/releases/tag/0.9), support bandwidth test, player/encoder/chat [demos](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SampleDemo). 20926 lines.<br/>
329 -* 2013-12-08, [Release v0.8](https://github.com/simple-rtmp-server/srs/releases/tag/0.8), support [http hooks callback](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_HTTPCallback), update [st_load](https://github.com/winlinvip/st-load). 19186 lines.<br/> 329 +* 2013-12-08, [Release v0.8](https://github.com/simple-rtmp-server/srs/releases/tag/0.8), support [http hooks callback](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_HTTPCallback), update [SB](https://github.com/simple-rtmp-server/srs-bench). 19186 lines.<br/>
330 * 2013-12-03, [Release v0.7](https://github.com/simple-rtmp-server/srs/releases/tag/0.7), support [live stream transcoding](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_FFMPEG). 17605 lines.<br/> 330 * 2013-12-03, [Release v0.7](https://github.com/simple-rtmp-server/srs/releases/tag/0.7), support [live stream transcoding](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_FFMPEG). 17605 lines.<br/>
331 * 2013-11-29, [Release v0.6](https://github.com/simple-rtmp-server/srs/releases/tag/0.6), support [forward](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_Forward) stream to origin/edge. 16094 lines.<br/> 331 * 2013-11-29, [Release v0.6](https://github.com/simple-rtmp-server/srs/releases/tag/0.6), support [forward](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_Forward) stream to origin/edge. 16094 lines.<br/>
332 * 2013-11-26, [Release v0.5](https://github.com/simple-rtmp-server/srs/releases/tag/0.5), support [HLS(m3u8)](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_DeliveryHLS), fragment and window. 14449 lines.<br/> 332 * 2013-11-26, [Release v0.5](https://github.com/simple-rtmp-server/srs/releases/tag/0.5), support [HLS(m3u8)](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_DeliveryHLS), fragment and window. 14449 lines.<br/>
@@ -521,7 +521,7 @@ Remark: @@ -521,7 +521,7 @@ Remark:
521 * v1.0, 2014-06-27, SRS online 30days with RTMP/HLS. 521 * v1.0, 2014-06-27, SRS online 30days with RTMP/HLS.
522 * v1.0, 2014-06-25, fix [#108](https://github.com/simple-rtmp-server/srs/issues/108), support config time jitter for encoder non-monotonical stream. 0.9.133 522 * v1.0, 2014-06-25, fix [#108](https://github.com/simple-rtmp-server/srs/issues/108), support config time jitter for encoder non-monotonical stream. 0.9.133
523 * v1.0, 2014-06-23, support report summaries in heartbeat. 0.9.132 523 * v1.0, 2014-06-23, support report summaries in heartbeat. 0.9.132
524 -* v1.0, 2014-06-22, performance refine, support [3k+](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_Performance#%E6%80%A7%E8%83%BD%E4%BE%8B%E8%A1%8C%E6%8A%A5%E5%91%8A4k) connections(270kbps). 0.9.130 524 +* v1.0, 2014-06-22, performance refine, support [3k+](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_Performance#performancereport4k) connections(270kbps). 0.9.130
525 * v1.0, 2014-06-21, support edge [token traverse](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_DRM#tokentraverse), fix [#104](https://github.com/simple-rtmp-server/srs/issues/104). 0.9.129 525 * v1.0, 2014-06-21, support edge [token traverse](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_DRM#tokentraverse), fix [#104](https://github.com/simple-rtmp-server/srs/issues/104). 0.9.129
526 * v1.0, 2014-06-19, add connections count to api summaries. 0.9.127 526 * v1.0, 2014-06-19, add connections count to api summaries. 0.9.127
527 * v1.0, 2014-06-19, add srs bytes and kbps to api summaries. 0.9.126 527 * v1.0, 2014-06-19, add srs bytes and kbps to api summaries. 0.9.126
@@ -614,7 +614,7 @@ Remark: @@ -614,7 +614,7 @@ Remark:
614 * v0.8, 2013-12-08, support multiple http hooks for a event. 614 * v0.8, 2013-12-08, support multiple http hooks for a event.
615 * v0.8, 2013-12-07, support http callback hooks, on_connect. 615 * v0.8, 2013-12-07, support http callback hooks, on_connect.
616 * v0.8, 2013-12-07, support network based cli and json result, add CherryPy 3.2.4. 616 * v0.8, 2013-12-07, support network based cli and json result, add CherryPy 3.2.4.
617 -* v0.8, 2013-12-07, update http/hls/rtmp load test tool [st_load](https://github.com/winlinvip/st-load), use SRS rtmp sdk. 617 +* v0.8, 2013-12-07, update http/hls/rtmp load test tool [SB](https://github.com/simple-rtmp-server/srs-bench), use SRS rtmp sdk.
618 * v0.8, 2013-12-06, support max_connections, drop if exceed. 618 * v0.8, 2013-12-06, support max_connections, drop if exceed.
619 * v0.8, 2013-12-05, support log_dir, write ffmpeg log to file. 619 * v0.8, 2013-12-05, support log_dir, write ffmpeg log to file.
620 * v0.8, 2013-12-05, fix the forward/hls/encoder bug. 620 * v0.8, 2013-12-05, fix the forward/hls/encoder bug.
@@ -672,9 +672,9 @@ Performance benchmark history, on virtual box. @@ -672,9 +672,9 @@ Performance benchmark history, on virtual box.
672 * See also: [Performance for x86/x64 Test Guide](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_Performance) 672 * See also: [Performance for x86/x64 Test Guide](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_Performance)
673 * See also: [Performance for RaspberryPi](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_RaspberryPi) 673 * See also: [Performance for RaspberryPi](https://github.com/simple-rtmp-server/srs/wiki/v1_CN_RaspberryPi)
674 674
675 -### Play benchmark 675 +### Play RTMP benchmark
676 676
677 -The play benchmark by [st-load](https://github.com/winlinvip/st-load): 677 +The play RTMP benchmark by [SB](https://github.com/simple-rtmp-server/srs-bench):
678 678
679 679
680 | Update | SRS | Clients | Type | CPU | Memory | Commit | 680 | Update | SRS | Clients | Type | CPU | Memory | Commit |
@@ -692,9 +692,9 @@ The play benchmark by [st-load](https://github.com/winlinvip/st-load): @@ -692,9 +692,9 @@ The play benchmark by [st-load](https://github.com/winlinvip/st-load):
692 | 2014-12-05 | 2.0.57 | 9.0k(9000) | players | 90% | 468MB | [code][p11] | 692 | 2014-12-05 | 2.0.57 | 9.0k(9000) | players | 90% | 468MB | [code][p11] |
693 | 2014-12-07 | 2.0.67 | 10k(10000) | players | 95% | 656MB | [code][p12] | 693 | 2014-12-07 | 2.0.67 | 10k(10000) | players | 95% | 656MB | [code][p12] |
694 694
695 -### Publish benchmark 695 +### Publish RTMP benchmark
696 696
697 -The publish benchmark by [st-load](https://github.com/winlinvip/st-load): 697 +The publish RTMP benchmark by [SB](https://github.com/simple-rtmp-server/srs-bench):
698 698
699 | Update | SRS | Clients | Type | CPU | Memory | Commit | 699 | Update | SRS | Clients | Type | CPU | Memory | Commit |
700 | ------------- | --------- | ------------- | ------------- | --------- | -------- | ------------ | 700 | ------------- | --------- | ------------- | ------------- | --------- | -------- | ------------ |
@@ -708,6 +708,16 @@ The publish benchmark by [st-load](https://github.com/winlinvip/st-load): @@ -708,6 +708,16 @@ The publish benchmark by [st-load](https://github.com/winlinvip/st-load):
708 | 2014-12-04 | 2.0.51 | 2.5k(2500) | publishers | 91% | 259MB | [code][p4] | 708 | 2014-12-04 | 2.0.51 | 2.5k(2500) | publishers | 91% | 259MB | [code][p4] |
709 | 2014-12-04 | 2.0.52 | 4.0k(4000) | publishers | 80% | 331MB | [code][p5] | 709 | 2014-12-04 | 2.0.52 | 4.0k(4000) | publishers | 80% | 331MB | [code][p5] |
710 710
  711 +### Play HTTP FLV benchmark
  712 +
  713 +The play HTTP FLV benchmark by [SB](https://github.com/simple-rtmp-server/srs-bench):
  714 +
  715 +
  716 +| Update | SRS | Clients | Type | CPU | Memory | Commit |
  717 +| ------------- | --------- | ------------- | ------------- | --------- | -------- | ------------ |
  718 +| 2014-05-24 | 2.0.167 | 1.0k(1000) | players | 82% | 86MB | - |
  719 +| 2014-05-24 | 2.0.168 | 2.3k(2300) | players | 92% | 276MB | - |
  720 +
711 ### Latency benchmark 721 ### Latency benchmark
712 722
713 The latency between encoder and player with realtime config( 723 The latency between encoder and player with realtime config(
@@ -123,16 +123,20 @@ int SrsHttpResponseWriter::write(char* data, int size) @@ -123,16 +123,20 @@ int SrsHttpResponseWriter::write(char* data, int size)
123 } 123 }
124 124
125 // send in chunked encoding. 125 // send in chunked encoding.
126 - std::stringstream ss;  
127 - ss << hex << size << SRS_HTTP_CRLF;  
128 - std::string ch = ss.str();  
129 - if ((ret = skt->write((void*)ch.data(), (int)ch.length(), NULL)) != ERROR_SUCCESS) {  
130 - return ret;  
131 - }  
132 - if ((ret = skt->write((void*)data, size, NULL)) != ERROR_SUCCESS) {  
133 - return ret;  
134 - }  
135 - if ((ret = skt->write((void*)SRS_HTTP_CRLF, 2, NULL)) != ERROR_SUCCESS) { 126 + int nb_size = snprintf(header_cache, SRS_HTTP_HEADER_CACHE_SIZE, "%x", size);
  127 +
  128 + iovec iovs[4];
  129 + iovs[0].iov_base = (char*)header_cache;
  130 + iovs[0].iov_len = (int)nb_size;
  131 + iovs[1].iov_base = (char*)SRS_HTTP_CRLF;
  132 + iovs[1].iov_len = 2;
  133 + iovs[2].iov_base = (char*)data;
  134 + iovs[2].iov_len = size;
  135 + iovs[3].iov_base = (char*)SRS_HTTP_CRLF;
  136 + iovs[3].iov_len = 2;
  137 +
  138 + ssize_t nwrite;
  139 + if ((ret = skt->writev(iovs, 4, &nwrite)) != ERROR_SUCCESS) {
136 return ret; 140 return ret;
137 } 141 }
138 142
@@ -71,6 +71,8 @@ class SrsHttpMessage; @@ -71,6 +71,8 @@ class SrsHttpMessage;
71 71
72 #ifdef SRS_AUTO_HTTP_PARSER 72 #ifdef SRS_AUTO_HTTP_PARSER
73 73
  74 +#define SRS_HTTP_HEADER_CACHE_SIZE 16
  75 +
74 /** 76 /**
75 * response writer use st socket 77 * response writer use st socket
76 */ 78 */
@@ -79,6 +81,7 @@ class SrsHttpResponseWriter : public ISrsHttpResponseWriter @@ -79,6 +81,7 @@ class SrsHttpResponseWriter : public ISrsHttpResponseWriter
79 private: 81 private:
80 SrsStSocket* skt; 82 SrsStSocket* skt;
81 SrsHttpHeader* hdr; 83 SrsHttpHeader* hdr;
  84 + char header_cache[SRS_HTTP_HEADER_CACHE_SIZE];
82 private: 85 private:
83 // reply header has been (logically) written 86 // reply header has been (logically) written
84 bool header_wrote; 87 bool header_wrote;
@@ -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 167 34 +#define VERSION_REVISION 168
35 35
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"