winlin

for #405, improve the http flv to 3k. 2.0.170

@@ -718,6 +718,7 @@ The play HTTP FLV benchmark by [SB](https://github.com/simple-rtmp-server/srs-be @@ -718,6 +718,7 @@ The play HTTP FLV benchmark by [SB](https://github.com/simple-rtmp-server/srs-be
718 | 2014-05-24 | 2.0.167 | 1.0k(1000) | players | 82% | 86MB | - | 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 | [code][p17] | 719 | 2014-05-24 | 2.0.168 | 2.3k(2300) | players | 92% | 276MB | [code][p17] |
720 | 2014-05-24 | 2.0.169 | 3.0k(3000) | players | 94% | 188MB | [code][p18] | 720 | 2014-05-24 | 2.0.169 | 3.0k(3000) | players | 94% | 188MB | [code][p18] |
  721 +| 2014-05-24 | 2.0.170 | 3.0k(3000) | players | 89% | 96MB | [code][p19] |
721 722
722 ### Latency benchmark 723 ### Latency benchmark
723 724
@@ -66,11 +66,14 @@ SrsHttpResponseWriter::SrsHttpResponseWriter(SrsStSocket* io) @@ -66,11 +66,14 @@ SrsHttpResponseWriter::SrsHttpResponseWriter(SrsStSocket* io)
66 content_length = -1; 66 content_length = -1;
67 written = 0; 67 written = 0;
68 header_sent = false; 68 header_sent = false;
  69 + nb_iovss_cache = 0;
  70 + iovss_cache = NULL;
69 } 71 }
70 72
71 SrsHttpResponseWriter::~SrsHttpResponseWriter() 73 SrsHttpResponseWriter::~SrsHttpResponseWriter()
72 { 74 {
73 srs_freep(hdr); 75 srs_freep(hdr);
  76 + srs_freep(iovss_cache);
74 } 77 }
75 78
76 int SrsHttpResponseWriter::final_request() 79 int SrsHttpResponseWriter::final_request()
@@ -173,8 +176,12 @@ int SrsHttpResponseWriter::writev(iovec* iov, int iovcnt, ssize_t* pnwrite) @@ -173,8 +176,12 @@ int SrsHttpResponseWriter::writev(iovec* iov, int iovcnt, ssize_t* pnwrite)
173 176
174 // send in chunked encoding. 177 // send in chunked encoding.
175 int nb_iovss = iovcnt * 4; 178 int nb_iovss = iovcnt * 4;
176 - iovec* iovss = new iovec[nb_iovss];  
177 - SrsAutoFree(iovec, iovss); 179 + iovec* iovss = iovss_cache;
  180 + if (nb_iovss_cache < nb_iovss) {
  181 + srs_freep(iovss_cache);
  182 + nb_iovss_cache = nb_iovss;
  183 + iovss = iovss_cache = new iovec[nb_iovss];
  184 + }
178 185
179 char* pheader_cache = header_cache; 186 char* pheader_cache = header_cache;
180 for (int i = 0; i < iovcnt; i++) { 187 for (int i = 0; i < iovcnt; i++) {
@@ -85,7 +85,10 @@ class SrsHttpResponseWriter : public ISrsHttpResponseWriter @@ -85,7 +85,10 @@ class SrsHttpResponseWriter : public ISrsHttpResponseWriter
85 private: 85 private:
86 SrsStSocket* skt; 86 SrsStSocket* skt;
87 SrsHttpHeader* hdr; 87 SrsHttpHeader* hdr;
  88 +private:
88 char header_cache[SRS_HTTP_HEADER_CACHE_SIZE]; 89 char header_cache[SRS_HTTP_HEADER_CACHE_SIZE];
  90 + iovec* iovss_cache;
  91 + int nb_iovss_cache;
89 private: 92 private:
90 // reply header has been (logically) written 93 // reply header has been (logically) written
91 bool header_wrote; 94 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 169 34 +#define VERSION_REVISION 170
35 35
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"