SRS效能 記憶體優化工具用法

2021-08-09 09:36:32 字數 2173 閱讀 1318

srs提供了一系列工具來定位效能瓶頸和記憶體洩漏,這些在./configure && make後的summary中是有給出來用法的,不過不是很方便,所以特地把用法寫到這個文章中。

文中所有的工具,對於其他的linux程式也是有用的。

備註:所有工具用起來都會導致srs效能低下,所以除非是排查問題,否則不要開啟這些選項。

gperf是google tcmalloc提供的cpu和記憶體工具,參考gperf。

gmd是gperf提供的記憶體defense工具,檢測記憶體越界和野指標。一般在越界寫入時,可能不會立刻導致破壞,而是在切換到其他執行緒使用被破壞的物件時才會發現破壞了,所以這種記憶體問題很難排查;gmd能在越界和野指標使用時直接core dump,定位在那個出問題的地方。參考gmd。

usage:

# build srs with gmd.

./configure --with-gperf --with-gmd && make

# start srs with gmd.

env tcmalloc_page_fence=1 ./objs/srs -c conf/console.conf

gmc是記憶體洩漏檢測工具,參考gmc。

usage:

# build srs with gmc

./configure --with-gperf --with-gmc && make

# start srs with gmc

env pprof_path=./objs/pprof heapcheck=normal ./objs/srs -c conf/console.conf 2>gmc.log

# or ctrl+c to

stop gmc

killall -2 srs

# to analysis memory leak

cat gmc.log

usage:

# build srs with gmp

./configure --with-gperf --with-gmp && make

# start srs with gmp

./objs/srs -c conf/console.conf

# or ctrl+c to stop gmp

killall -2 srs

# to analysis memory profile

./objs/pprof --text objs/srs gperf.srs.gmp*

gcp是cpu效能分析工具,就是一般講的效能瓶頸,看哪個函式呼叫占用過多的cpu。參考gcp。

usage:

# build srs with gcp

./configure --with-gperf --with-gcp && make

# start srs with gcp

./objs/srs -c conf/console.conf

# or ctrl+c to stop gcp

killall -2 srs

# to analysis cpu profile

./objs/pprof --text objs/srs gperf.srs.gcp*

gprof是個gnu的cpu效能分析工具。參考srs gprof,以及gnu gprof。

usage:

# build srs with gprof

./configure --with-gprof && make

# start srs with gprof

./objs/srs -c conf/console.conf

# or ctrl+c to stop gprof

killall -2 srs

# to analysis result.

gprof -b ./objs/srs gmon.out

valgrind是大名鼎鼎的c分析工具,srs因為使用了st所以最初不支援valgrind的分析,所以需要給st打patch才能用,目前還沒有合併到srs。

給st打patch支援valgrind,參考state-threads,詳細的資訊可以參考st#2。

SRS採用記憶體磁碟優化效能

srs是流 直播伺服器,可以將rtmp轉為hls協議,hls協議包含.m3u8和.ts檔案,一般是存在磁碟上,但借助linux的系統特性,可以將這些檔案儲存到磁碟上,從而降低磁碟讀寫次數,並提高流 的效能。dev shm是linux下的記憶體檔案系統目錄,具體介紹可見 srs的配置可以參照下面進行設...

Android效能優化工具 bootchart

1.安裝bootchart sudo apt get install bootchart 2.編譯bootchart 由於5.1原始碼預設編譯時是不編譯bootchart的,需要開啟該編譯項 touch system core init init.c 由於該檔案對應的映象檔案為boot.img,需要...

SQL效能優化工具TKPROF

全名為trace kernel profile,用來格式化跟蹤檔案,是乙個命令列工具。主要的格式例如以下 tkprof tracefile outputfile tracefile 要分析的trace檔案 outputfile 格式化後的檔案 可選引數及說明例如以下 explain 為每乙個sql語...