Libjpeg-turbo 1.0 beta Released!

Add any particular hints or tricks you have found to help with your ZoneMinder experience.
bobbozzo
Posts: 8
Joined: Fri Sep 10, 2010 9:55 pm

Post by bobbozzo » Sun Sep 12, 2010 6:16 am

knnniggett wrote:The following is one example, specific to Zoneminder, of what dcommander is saying. Find the line in your /etc/init.d/zm script that says "$command start" and place the following just prior to that.

For 64 bit systems:

Code: Select all

export LD_LIBRARY_PATH=/opt/libjpeg-turbo/lib64:$LD_LIBRARY_PATH
For 32 bit systems:

Code: Select all

export LD_LIBRARY_PATH=/opt/libjpeg-turbo/lib:$LD_LIBRARY_PATH

Hi, this isn't helping for me...
I'm running Fedora 12 on a Pentium4 with HT, SSE, & SSE2.

I installed the libjpeg-turbo rpm, and the libs are in /opt/libjpeg-turbo/lib and the tests for libjpeg-turbo work and are much faster (I used some large images linked from the site).

However, ZoneMinder is no faster with
export LD_LIBRARY_PATH=/opt/libjpeg-turbo/lib:$LD_LIBRARY_PATH
before
$command start

when restarting ZM with
service zoneminder restart


Am I missing something?

Thanks,
Bob

Flasheart
Posts: 345
Joined: Thu Jul 06, 2006 2:27 pm

Post by Flasheart » Sun Sep 12, 2010 8:55 am

After changing my four zm servers over, here are some Debian 32-bit instructions:

(Major load differences noticable. 1.46 to 0.34, 2.5 to 1.6, 3.16 to 2.0 and similar. This IS worth doing!)

Code: Select all

1. Visit http://sourceforge.net/projects/libjpeg-turbo/files/ and grab the latest .deb version. 

2. As root; dpkg -i libjpeg-turbo_1.0.1_i386.deb
This installs the package. 

3. Edit /etc/init.d/zoneminder
Add this line AFTER "ZM_PATH_BIN="/usr/bin""
export LD_LIBRARY_PATH=/opt/libjpeg-turbo/lib:$LD_LIBRARY_PATH 

4. Still as root, run: /etc/init.d/zoneminder restart


Job done. Once zm has restarted and settled down, you should see a significant reduction in load. Look at some live streams and recent recordings to verify all is working.

bobbozzo
Posts: 8
Joined: Fri Sep 10, 2010 9:55 pm

Post by bobbozzo » Sun Sep 12, 2010 10:02 am

Hi, thanks for the tip... unfortunately the RedHat init script is quite different.

I've decided to put the LD_LIBRARY_PATH setting in /etc/profile... it seems to be helping; the modect CPU usage is about the same, but recording is working MUCH better.

Thanks,
Bob

Flash_
Posts: 441
Joined: Wed Jan 11, 2006 12:19 pm

Post by Flash_ » Mon Sep 13, 2010 9:48 am

Some munin graphs of system load. Change to libjpg-turbo happened on the 12th from the standard debian libs.

Image

Image

Image

Pada
Posts: 69
Joined: Fri Jul 30, 2010 12:29 am

Post by Pada » Thu Oct 14, 2010 3:15 pm

How do I check whether ZM is using this libjpeg-turbo library?

Also, if ZM is feeding from mpeg cameras via RTSP and then streaming as mpeg again, then this library will not even be used?

beanfield
Posts: 4
Joined: Thu Aug 06, 2009 2:22 pm

Post by beanfield » Fri Nov 19, 2010 1:51 pm

Pada wrote:How do I check whether ZM is using this libjpeg-turbo library?

Also, if ZM is feeding from mpeg cameras via RTSP and then streaming as mpeg again, then this library will not even be used?
"sudo lsof /opt/libjpeg-turbo" will show you which programs are accessing files in that path. It stands for LiSt Open Files. You can specify a particular path to check, a particular pid (with -p), or all open files (with no args). So alternatively, you could do "sudo lsof |grep libjpeg.so.62.0.0" to get an idea of which programs are accessing any libjpeg.so.62.0.0 (whether or not it's in /opt/libjpeg-turbo). Or you could get the pids of your zoneminder processes and do "lsod -p PID".

In my case I ran the second command after installing libjpeg-turbo_1.0.1_amd64.deb from http://sourceforge.net/projects/libjpeg-turbo/files/ and modifying the init script. I can see zoneminder is not calling the libjpeg-turbo version of libjpeg.so.62.0.0. It's calling libjpeg from /usr/lib (default ubuntu version) instead of /opt/libjpeg-turbo (new enhanced version)
# lsof |grep libjpeg.so.62.0.0
...
zmc 5710 www-data mem REG 8,17 146032 3950487 /usr/lib/libjpeg.so.62.0.0
zmc 5715 www-data mem REG 8,17 146032 3950487 /usr/lib/libjpeg.so.62.0.0
zmc 5720 www-data mem REG 8,17 146032 3950487 /usr/lib/libjpeg.so.62.0.0
zma 5734 www-data mem REG 8,17 146032 3950487 /usr/lib/libjpeg.so.62.0.0
zma 5736 www-data mem REG 8,17 146032 3950487 /usr/lib/libjpeg.so.62.0.0
zma 5737 www-data mem REG 8,17 146032 3950487 /usr/lib/libjpeg.so.62.0.0
...
I'm running Ubuntu 10.10, so I did the following:

Code: Select all

# sudo gedit /etc/ld.so.conf.d/libjpeg-turbo.conf
This will be a new file, so just add in a line that says

Code: Select all

/opt/libjpeg-turbo/lib
Then run
# ldconfig
Finally restart zoneminder
# /etc/init.d/zoneminder restart
# lsof |grep libjpeg.so.62.0.0
...
zmc 6426 www-data mem REG 8,17 298151 3980 /opt/libjpeg-turbo/lib/libjpeg.so.62.0.0
zmc 6431 www-data mem REG 8,17 298151 3980 /opt/libjpeg-turbo/lib/libjpeg.so.62.0.0
zmc 6436 www-data mem REG 8,17 298151 3980 /opt/libjpeg-turbo/lib/libjpeg.so.62.0.0
zma 6451 www-data mem REG 8,17 298151 3980 /opt/libjpeg-turbo/lib/libjpeg.so.62.0.0
zma 6452 www-data mem REG 8,17 298151 3980 /opt/libjpeg-turbo/lib/libjpeg.so.62.0.0
zma 6453 www-data mem REG 8,17 298151 3980 /opt/libjpeg-turbo/lib/libjpeg.so.62.0.0
...
Notice how the path for this library is /opt/libjpeg-turbo? ^ verified to be using the new libjpeg-turbo.

Note: you won't need a modified init script after this...nor will you need to set LD_LIBRARY_PATH in your profile. If you only export it in your profile, it only works for programs running as that user. Likewise, if you only export it in the zoneminder init script, only zoneminder will use it. The way I described above will tell all programs to use /opt/libjpeg-turbo. This method should survive ubuntu updates.
Last edited by beanfield on Fri Nov 19, 2010 2:19 pm, edited 8 times in total.

Pada
Posts: 69
Joined: Fri Jul 30, 2010 12:29 am

Post by Pada » Fri Nov 19, 2010 2:00 pm

Thanks a million beanfield!

beanfield
Posts: 4
Joined: Thu Aug 06, 2009 2:22 pm

Post by beanfield » Fri Nov 19, 2010 2:01 pm

Pada wrote:Thanks a million beanfield!
np, be sure to follow up if you run into any issues. :D

Nate23
Posts: 9
Joined: Thu Oct 21, 2010 2:52 pm

Post by Nate23 » Wed Dec 01, 2010 5:17 pm

I have followed beanfields installation instructions step by step but i am not able to see the cpu load decrease everyone else is talking about. When I run the "lsof |grep libjpeg.so.62.0.0" command it shows:

zma 1626 www-data mem REG 8,1 329404 14549015 /opt/libjpeg-turbo/lib/libjpeg.so.62.0.0
zmc 1630 www-data mem REG 8,1 329404 14549015 /opt/libjpeg-turbo/lib/libjpeg.so.62.0.0

for all my camera's. Is there anything else I might be able to try to lower my cpu load?

Thanks

Pada
Posts: 69
Joined: Fri Jul 30, 2010 12:29 am

Post by Pada » Wed Dec 01, 2010 5:25 pm

Nate23: you will only see a decrease in CPU usage when ZM is saving the video streams as JPEG sequences to the hard drive OR when your cameras are feeding ZoneMinder via M-JPEG streams.
You will not see a decrease in CPU usage when you're feeding/streaming MPEG video streams!

Nate23
Posts: 9
Joined: Thu Oct 21, 2010 2:52 pm

Post by Nate23 » Wed Dec 01, 2010 6:04 pm

Pada wrote:Nate23: you will only see a decrease in CPU usage when ZM is saving the video streams as JPEG sequences to the hard drive OR when your cameras are feeding ZoneMinder via M-JPEG streams.
You will not see a decrease in CPU usage when you're feeding/streaming MPEG video streams!
I'm currently set to stream jpeg.

tibetfreedom
Posts: 163
Joined: Fri Oct 22, 2010 11:21 am

Post by tibetfreedom » Fri Dec 03, 2010 1:46 pm

knnniggett wrote:The following is one example, specific to Zoneminder, of what dcommander is saying. Find the line in your /etc/init.d/zm script that says "$command start" and place the following just prior to that.

For 64 bit systems:

Code: Select all

export LD_LIBRARY_PATH=/opt/libjpeg-turbo/lib64:$LD_LIBRARY_PATH
For 32 bit systems:

Code: Select all

export LD_LIBRARY_PATH=/opt/libjpeg-turbo/lib:$LD_LIBRARY_PATH
Thanks I loaded into /opt/ and this cut cpu from about 45% to 13% using intel core 2 duo 6600 nice

novazion
Posts: 19
Joined: Mon Mar 08, 2010 10:30 am

Post by novazion » Mon Dec 06, 2010 6:32 pm

Wonderful. that's impressive.
Thanks beanfield for your help.
Your short tuto just work well.

haus
Posts: 195
Joined: Thu Oct 11, 2007 5:10 am

Post by haus » Wed Dec 15, 2010 12:20 am

In my case I had to issue

Code: Select all

cd /usr/local/lib
rm -rf libjpeg.so.62
ln -s  /opt/libjpeg-turbo/lib/libjpeg.so.62.0.0 libjpeg.so.62
service zoneminder restart
Then "lsof | grep jpeg" at the command line shows I'm using /opt/libjpeg-turbo/lib/libjpeg.so.62.0.0. I think the line

Code: Select all

export LD_LIBRARY_PATH=/opt/libjpeg-turbo/lib:$LD_LIBRARY_PATH
in /etc/init.d/zoneminder didn't do anything in my case because after I put that line in and restarted zm it was still using the old jpeg libraries in /usr/local/lib.

Thanks to Yamanipanuchi for posting the solution in this thread:

http://www.zoneminder.com/forums/viewtopic.php?t=16762

PacoLM
Posts: 967
Joined: Wed Dec 02, 2009 9:55 pm
Location: Spain

Post by PacoLM » Wed Dec 15, 2010 7:36 am

Hi,

Will this work in armv5tel version of Debian/ZM???

Thanks in advance,

PacoLM

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests