Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-12-04 14:58:40 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f57801eb46c16755b173984b915a4166922df6a6
f57801eb
1 parent
b84e8784
fix #249, cache the chunk headers info to +5% or +10% performance. 2.0.51
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
52 行增加
和
9 行删除
trunk/src/core/srs_core.hpp
trunk/src/core/srs_core_performance.hpp
trunk/src/rtmp/srs_protocol_stack.cpp
trunk/src/rtmp/srs_protocol_stack.hpp
trunk/src/core/srs_core.hpp
查看文件 @
f57801e
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 5
0
#define VERSION_REVISION 5
1
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
#define RTMP_SIG_SRS_ROLE "origin/edge server"
...
...
trunk/src/core/srs_core_performance.hpp
查看文件 @
f57801e
...
...
@@ -79,5 +79,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define SRS_PERF_SEND_MSGS_CACHE 500
/**
* how many chunk stream to cache, [0, N].
* to imporove about 10% performance when chunk size small, and 5% for large chunk.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/249
*/
#define SRS_PERF_CHUNK_STREAM_CACHE 16
#endif
...
...
trunk/src/rtmp/srs_protocol_stack.cpp
查看文件 @
f57801e
...
...
@@ -417,6 +417,16 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io)
warned_c0c3_cache_dry
=
false
;
auto_response_when_recv
=
true
;
cs_cache
=
new
SrsChunkStream
*
[
SRS_PERF_CHUNK_STREAM_CACHE
];
for
(
int
cid
=
0
;
cid
<
SRS_PERF_CHUNK_STREAM_CACHE
;
cid
++
)
{
SrsChunkStream
*
cs
=
new
SrsChunkStream
(
cid
);
// set the perfer cid of chunk,
// which will copy to the message received.
cs
->
header
.
perfer_cid
=
cid
;
cs_cache
[
cid
]
=
cs
;
}
}
SrsProtocol
::~
SrsProtocol
()
...
...
@@ -448,6 +458,13 @@ SrsProtocol::~SrsProtocol()
free
(
out_iovs
);
out_iovs
=
NULL
;
}
// free all chunk stream cache.
for
(
int
i
=
0
;
i
<
SRS_PERF_CHUNK_STREAM_CACHE
;
i
++
)
{
SrsChunkStream
*
cs
=
cs_cache
[
i
];
srs_freep
(
cs
);
}
srs_freep
(
cs_cache
);
}
void
SrsProtocol
::
set_auto_response
(
bool
v
)
...
...
@@ -1102,17 +1119,30 @@ int SrsProtocol::recv_interlaced_message(SrsMessage** pmsg)
// get the cached chunk stream.
SrsChunkStream
*
chunk
=
NULL
;
if
(
chunk_streams
.
find
(
cid
)
==
chunk_streams
.
end
())
{
chunk
=
chunk_streams
[
cid
]
=
new
SrsChunkStream
(
cid
);
// set the perfer cid of chunk,
// which will copy to the message received.
chunk
->
header
.
perfer_cid
=
cid
;
srs_verbose
(
"cache new chunk stream: fmt=%d, cid=%d"
,
fmt
,
cid
);
}
else
{
chunk
=
chunk_streams
[
cid
];
// use chunk stream cache to get the chunk info.
// @see https://github.com/winlinvip/simple-rtmp-server/issues/249
if
(
cid
<
SRS_PERF_CHUNK_STREAM_CACHE
)
{
// chunk stream cache hit.
srs_verbose
(
"cs-cache hit, cid=%d"
,
cid
);
// already init, use it direclty
chunk
=
cs_cache
[
cid
];
srs_verbose
(
"cached chunk stream: fmt=%d, cid=%d, size=%d, message(type=%d, size=%d, time=%"
PRId64
", sid=%d)"
,
chunk
->
fmt
,
chunk
->
cid
,
(
chunk
->
msg
?
chunk
->
msg
->
size
:
0
),
chunk
->
header
.
message_type
,
chunk
->
header
.
payload_length
,
chunk
->
header
.
timestamp
,
chunk
->
header
.
stream_id
);
}
else
{
// chunk stream cache miss, use map.
if
(
chunk_streams
.
find
(
cid
)
==
chunk_streams
.
end
())
{
chunk
=
chunk_streams
[
cid
]
=
new
SrsChunkStream
(
cid
);
// set the perfer cid of chunk,
// which will copy to the message received.
chunk
->
header
.
perfer_cid
=
cid
;
srs_verbose
(
"cache new chunk stream: fmt=%d, cid=%d"
,
fmt
,
cid
);
}
else
{
chunk
=
chunk_streams
[
cid
];
srs_verbose
(
"cached chunk stream: fmt=%d, cid=%d, size=%d, message(type=%d, size=%d, time=%"
PRId64
", sid=%d)"
,
chunk
->
fmt
,
chunk
->
cid
,
(
chunk
->
msg
?
chunk
->
msg
->
size
:
0
),
chunk
->
header
.
message_type
,
chunk
->
header
.
payload_length
,
chunk
->
header
.
timestamp
,
chunk
->
header
.
stream_id
);
}
}
// chunk stream message header
...
...
trunk/src/rtmp/srs_protocol_stack.hpp
查看文件 @
f57801e
...
...
@@ -205,6 +205,12 @@ private:
*/
std
::
map
<
int
,
SrsChunkStream
*>
chunk_streams
;
/**
* cache some frequently used chunk header.
* cs_cache, the chunk stream cache.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/249
*/
SrsChunkStream
**
cs_cache
;
/**
* bytes buffer cache, recv from skt, provide services for stream.
*/
SrsFastBuffer
*
in_buffer
;
...
...
请
注册
或
登录
后发表评论