Skip to content

Commit

Permalink
Use msdk metrics_monitor to replace intel_gpu_top (open-webrtc-toolki…
Browse files Browse the repository at this point in the history
  • Loading branch information
daijh authored and xiandeatintel committed Oct 10, 2019
1 parent c0f305d commit 86e506e
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 84 deletions.
14 changes: 0 additions & 14 deletions scripts/installCentOSDeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,10 @@ install_boost(){
fi
}

enable_intel_gpu_top() {
# make intel-gpu-tools accessable by non-root users.
sudo chmod a+rw /sys/devices/pci0000:00/0000:00:02.0/resource*
# make the above change effect at every system startup.
sudo chmod +x /etc/rc.local /etc/rc.d/rc.local
if sudo grep -RInqs "chmod a+rw /sys/devices/pci0000:00/0000:00:02.0/resource*" /etc/rc.local; then
echo "intel-gpu-tools has been authorised to non-root users."
else
sudo sh -c "echo \"chmod a+rw /sys/devices/pci0000:00/0000:00:02.0/resource*\" >> /etc/rc.local"
fi
}

installYumDeps(){
sudo -E yum groupinstall " Development Tools" "Development Libraries " -y
sudo -E yum install zlib-devel pkgconfig git libcurl-devel.x86_64 curl log4cxx-devel gcc gcc-c++ bzip2 bzip2-devel bzip2-libs python-devel nasm libXext-devel libXfixes-devel libpciaccess-devel libX11-devel yasm cmake -y
sudo -E yum install rabbitmq-server mongodb mongodb-server java-1.7.0-openjdk gyp intel-gpu-tools which libtool freetype-devel -y
enable_intel_gpu_top

sudo -E yum install glib2-devel boost-devel -y
}

Expand Down
13 changes: 0 additions & 13 deletions scripts/installUbuntuDeps.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
#!/bin/bash

enable_intel_gpu_top() {
# make intel-gpu-tools accessable by non-root users.
sudo chmod a+rw /sys/devices/pci0000:00/0000:00:02.0/resource*
# make the above change effect at every system startup.
sudo chmod +x /etc/rc.local /etc/rc.d/rc.local
if sudo grep -RInqs "chmod a+rw /sys/devices/pci0000:00/0000:00:02.0/resource*" /etc/rc.local; then
echo "intel-gpu-tools has been authorised to non-root users."
else
sudo sh -c "echo \"chmod a+rw /sys/devices/pci0000:00/0000:00:02.0/resource*\" >> /etc/rc.local"
fi
}

install_apt_deps(){
sudo -E apt-get update -y
sudo -E apt-get install git make gcc g++ libglib2.0-dev pkg-config libboost-regex-dev libboost-thread-dev libboost-system-dev liblog4cxx-dev rabbitmq-server mongodb openjdk-8-jre curl libboost-test-dev nasm yasm gyp libx11-dev libkrb5-dev intel-gpu-tools m4 autoconf libtool automake cmake libfreetype6-dev -y
enable_intel_gpu_top
}

install_mediadeps_nonfree(){
Expand Down
30 changes: 18 additions & 12 deletions scripts/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,21 +329,27 @@ function packAddon(target) {
let dummyOpenh264 = path.join(rootDir, 'third_party/openh264/pseudo-openh264.so');
execSync(`cp -av ${dummyOpenh264} ${libOpenh264}`);
}
if (target.rules.name.indexOf('video') === 0) {
let vasrc = path.join(depsDir, 'bin/vainfo');
let vadist = path.join(packDist, 'bin');
if (fs.existsSync(vasrc)) {
if (!fs.existsSync(vadist)) {
execSync(`mkdir -p ${vadist}`);
}
execSync(`cp -av ${vasrc} ${vadist}`);
}
}
if (options['archive'] && !options['no-pseudo']) {
let libSvtHevcEnc = path.join(libDist, 'libSvtHevcEnc.so.1');

let libSvtHevcEnc = path.join(libDist, 'libSvtHevcEnc.so.1');
if (options['archive'] && fs.existsSync(libSvtHevcEnc) && !options['no-pseudo']) {
let dummySvtHevcEnc = path.join(rootDir, 'third_party/SVT-HEVC/pseudo-svtHevcEnc.so');
execSync(`cp -av ${dummySvtHevcEnc} ${libSvtHevcEnc}`);
}

if (target.rules.name.indexOf('video') === 0
|| target.rules.name.indexOf('analytics') === 0) {
if (fs.existsSync('/opt/intel/mediasdk')) {
let dst_bin = path.join(packDist, 'bin');
let dst_lib = path.join(packDist, 'lib');
if (!fs.existsSync(dst_bin)) {
execSync(`mkdir -p ${dst_bin}`);
}

execSync(`find /opt/intel/mediasdk -type f -name metrics_monitor | xargs -I '{}' cp -av '{}' ${dst_bin}`);
execSync(`find /opt/intel/mediasdk -type f -name libcttmetrics.so | xargs -I '{}' cp -av '{}' ${dst_lib}`);
}
}

console.log(target.rules.name, '- Pack addon finished.');
});
}
Expand Down
1 change: 1 addition & 0 deletions scripts/release/daemon-bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ case $startStop in
video-agent )
cd ${OWT_HOME}/video_agent
export LD_LIBRARY_PATH=./lib:${LD_LIBRARY_PATH}
export PATH=./bin:/opt/intel/mediasdk/bin:${PATH}
nohup nice -n ${OWT_NICENESS} ./OWT-MCU-Agent . -U video\
> "${stdout}" 2>&1 </dev/null &
echo $! > ${pid}
Expand Down
6 changes: 3 additions & 3 deletions scripts/release/daemon-mcu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ case $startStop in
video-agent )
cd ${OWT_HOME}/video_agent
export LD_LIBRARY_PATH=./lib:${LD_LIBRARY_PATH}
export PATH=/opt/intel/mediasdk/bin:${PATH}
export PATH=./bin:/opt/intel/mediasdk/bin:${PATH}
nohup nice -n ${OWT_NICENESS} node . -U video\
> "${stdout}" 2>&1 </dev/null &
echo $! > ${pid}
;;
analytics-agent )
cd ${OWT_HOME}/analytics_agent
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./lib
export PATH=${PATH}:/opt/intel/mediasdk/bin
export LD_LIBRARY_PATH=./lib:${LD_LIBRARY_PATH}
export PATH=./bin:/opt/intel/mediasdk/bin:${PATH}
nohup nice -n ${OWT_NICENESS} node . -U analytics\
> "${stdout}" 2>&1 </dev/null &
echo $! > ${pid}
Expand Down
7 changes: 7 additions & 0 deletions scripts/release/init-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ bin=`dirname "$0"`
bin=`cd "$bin"; pwd`
ROOT=`cd "${bin}/.."; pwd`

SUDO=""
if [[ $EUID -ne 0 ]]; then
SUDO="sudo -E"
fi

OWT_UPDATE_DONE=false
HAVE_AUTH_UPDATE=false

Expand Down Expand Up @@ -65,6 +70,8 @@ init_hardware()
${ROOT}/management_api/init.sh
${ROOT}/video_agent/init.sh --hardware
fi

${SUDO} sh -c "echo 0 >> /proc/sys/kernel/perf_event_paranoid"
}

init_auth()
Expand Down
17 changes: 2 additions & 15 deletions source/agent/video/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@ usage() {
echo
}

enable_intel_gpu_top() {
echo "Enable Intel GPU Top"
# make intel-gpu-tools accessable by non-root users.
${SUDO} chmod a+rw /sys/devices/pci0000:00/0000:00:02.0/resource*
# make the above change effect at every system startup.
${SUDO} chmod +x /etc/rc.local /etc/rc.d/rc.local
if ${SUDO} grep -RInqs "chmod a+rw /sys/devices/pci0000:00/0000:00:02.0/resource*" /etc/rc.local; then
echo "intel-gpu-tools has been authorised to non-root users."
else
${SUDO} sh -c "echo \"chmod a+rw /sys/devices/pci0000:00/0000:00:02.0/resource*\" >> /etc/rc.local"
fi
}

install_deps() {
local OS=$(${this}/detectOS.sh | awk '{print tolower($0)}')
echo $OS
Expand Down Expand Up @@ -91,7 +78,7 @@ install_deps
${this}/install_ffmpeg.sh

if ${HARDWARE_DEPS} ; then
enable_intel_gpu_top
:
else
# Install if no input for 15s
read -t 15 -p "Installing OpenH264 Video Codec Library provided by Cisco Systems, Inc? [Yes/no]" yn
Expand All @@ -100,4 +87,4 @@ else
[Nn]* ) ;;
* ) echo && . ${this}/install_openh264.sh;;
esac
fi
fi
52 changes: 25 additions & 27 deletions source/common/loadCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,37 +119,35 @@ var networkCollector = function (period, interf, max_scale, on_load) {
};

var gpuCollector = function (period, on_load) {
var child = child_process.spawn('intel_gpu_top', ['-s', '200']);
var child = child_process.exec('stdbuf -o0 metrics_monitor 100 1000');
var cpu_load = 0,
cpu_collector = new cpuCollector(period, function (data) {cpu_load = data;});

var renders = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], render_sum = 0,
bitstreams = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], bitstream_sum = 0,
blitters = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], blitter_sum = 0,
load = 0;
var load = 0;
child.stdout.on('data', function (data) {
var lines = data.toString().split('\n');

lines.forEach(function (line) {
var m = null;
if ((m = line.match(/\s+render busy:\s+(\d+)%/)) && m !== null && m.length > 1) {
var render = Number(m[1]),
old = renders.shift();
renders.push(render);
render_sum = render_sum - old + render;
} else if ((m = line.match(/\s+bitstream busy:\s+(\d+)%/)) && m !== null && m.length > 1) {
var bitstream = Number(m[1]),
old = bitstreams.shift();
bitstreams.push(bitstream);
bitstream_sum = bitstream_sum - old + bitstream;
} else if ((m = line.match(/\s+blitter busy:\s+(\d+)%/)) && m !== null && m.length > 1) {
var blitter = Number(m[1]),
old = blitters.shift();
blitters.push(blitter);
blitter_sum = blitter_sum - old + blitter;
}
});
load = (Math.floor(Math.max(render_sum, bitstream_sum, blitter_sum) / 10)) / 100;
var usage_sum = 0, samples = 0;
var lines = data.toString().split('\n');

var i = lines.length > 10 ? lines.length - 10 : 0;
for (; i < lines.length; i++) {
var engine_list = lines[i].split('\t');
var engine_max_usage = 0;
for (var engine of engine_list) {
var m = null;
if ((m = engine.match(/\s+usage:\s+(\d+\.\d+)/)) && m !== null && m.length > 1) {
var engine_usage = Number(m[1]);
if (engine_max_usage < engine_usage)
engine_max_usage = engine_usage;
}
}
usage_sum = usage_sum + engine_max_usage;
samples = samples + 1;
}

if (samples > 0)
load = (usage_sum / samples) / 100;
else
load = 0;
});

var interval = setInterval(function () {
Expand Down

0 comments on commit 86e506e

Please sign in to comment.