Page 4 of 12
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Wed Jul 06, 2011 8:13 am
by mastertheknife
Hi everyone,
In the last days, i updated the patch in the main post:
1) I relocated the standard alarmedpixels code and after relocation to its own function, it began working faster, even faster than the sse2 alarmedpixels code, so i left the sse2 alarmedpixels code included but not used. I could confirm this in my ZM test box and my home server. I suspect relocating the code to its own function allows the compiler to make better use of the available registers.
Just for comparison, here is the CPU usage of the zma process with the same settings used in the previous test:
Code: Select all
Patch - 32bit:
Standard alarmedpixels, before relocation: 15%
SSE2 alarmedpixels: 14%
Standard alarmedpixels, after relocation: 12%
Patch - 24bit:
Standard alarmedpixels, before relocation: 18%
SSE2 alarmedpixels: 17%
Standard alarmedpixels, after relocation: 15%
Patch - 8bit greyscale:
Standard alarmedpixels, before relocation: 9%
SSE2 alarmedpixels: 8%
Standard alarmedpixels, after relocation: 6%
2) I added support for the JPEG and MJPEG capture palettes, which are used by many USB cameras.
Most USB cameras support the YUYV capture palette and MJPEG(or JPEG). The YUYV capture palette usually requires less CPU time than the JPEG\MJPEG capture palettes, which require decompression of the JPEG. However, USB bandwidth is limited and because of that, many USB cameras only support a small range of resolutions and frame rates when using the YUYV capture palette, and because the JPEG\MJPEG capture palettes were unsupported, people were using mjpeg_streamer as a workaround to this problem.
So now you shouldn't need mjpeg_streamer anymore, enjoy.
3) I added automatic capture palette selection for the local cameras code, this can be enabled by selecting the "Auto" capture palette.
This is mainly to help new users that set up their first monitor and have no idea what capture palette they should use. This works by probing the device for a list of capture palettes it supports and selecting a one based on a priority list for the selected target colourspace.
4) Fixed few small long time bugs, such as alarm lasting forever once triggered or zma crashing when linked to a disabled monitor.
5) Allow the blend percent to be zero, to disable image blending in case anyone wants that.
About the future. I am looking to complete some other stuff and then rebase the patch against the latest SVN version, submit it to Phil and hopefully he approves it
mastertheknife.
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Sat Jul 09, 2011 7:31 pm
by CoYoTe
After a week running 4 different servers with this patches (the F revision, thx mastertheknife for passing it to me before publishing) the results are:
Stability: perfect, no server hangs.
Performance: System load reduced 10~25%. Some servers records on all cams, some do not, but all shows an increase in the global performance. A variety of PC configurations was used. Little sempron LE to Intel I3 or Athlon X3, with 2 or 4 gb ram and running other tasks (like asterisk or virtualbox)
The autodetect mode in colorspace works perfect, detecting ip cams and capture boards (pico2000, gv250, gv800) best colorspaces to work.
Tests to do: USB cams, and more IP CAMS models (at higher resolutions, i use all the systems at 352x288)
Please if someones can give more feedback, welcome.
Greetz.
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Mon Jul 11, 2011 12:17 am
by vraa
Bloody fantastic good job!
My laptop is out, otherwise I'd let you know in IRC
We have deployed your performance patches in about 20 locations so far, drastic drop in load
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Mon Jul 11, 2011 10:33 pm
by graphicw
With the success of this patch that we are seeing, I hope it ends up incorporated in Zoneminder.
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Sat Jul 16, 2011 4:29 pm
by CoYoTe
2 weeks up and running without issues on all my servers.
Greetz
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Sun Jul 17, 2011 9:10 pm
by mastertheknife
Thats awesome! Glad to hear
and really thanks for trying!
I believe there are no bugs in the patch uploaded in the last 1-2 months. Most changes since v1f were minor, such as allow ZM to compile on platforms without SSE (by defining ZM_STRIP_SSE to strip all the SSE code), etc.
I recently ordered some cheap <$10 USB cameras, mostly from dealextreme along with USB 1.1 extender (using ethernet cable, up to 30m) and a PCI USB 2.0 card (480mbps shared through 4-5 USB ports), In order to test the JPEG\MJPEG capture palettes, compare the cameras and see how well cheap USB webcams fit in CCTV. It should all arrive within a month hopefully.
mastertheknife
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Fri Jul 29, 2011 9:51 am
by zoneminder
I have now applied this patch, and some related mods, against 1.25.0. I plan to release 1.25.0 in the next day or so, which will not contain the mods, but immediately make a 1.25.1 RC available which will contain the patched code. That way if there are problem people can flick between the two versions to determine whether it's a problem with 1.25.0 in general or the patches from 1.25.1
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Fri Jul 29, 2011 12:03 pm
by mastertheknife
zoneminder wrote:I have now applied this patch, and some related mods, against 1.25.0. I plan to release 1.25.0 in the next day or so, which will not contain the mods, but immediately make a 1.25.1 RC available which will contain the patched code. That way if there are problem people can flick between the two versions to determine whether it's a problem with 1.25.0 in general or the patches from 1.25.1
Thats awesome Phil! I've been very busy lately with a new job so i didn't have much time to rebase the patch and all that. Thanks! I will pull the SVN to verify the required bits are there and working.
mastertheknife
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Fri Jul 29, 2011 12:09 pm
by zoneminder
Ok, I won't check the changes into the trunk until just after 1.25.0 is released but that should only be a day or two.
One other thing I meant to ask. The Colours column that has been added to the Monitors table has a default of 1. For the upgrade script is the some better logic about what this should be set to. For instance if Palette is X or Y, then Colours should be 1, if Palette is A or B then... etc etc. If I spent a little more time on it I could probably work it out but I thought I would ask in case you have a simple answer first.
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Fri Jul 29, 2011 4:37 pm
by mastertheknife
I think the correct behavior should be to check if the palette is greyscale, if not, set to 3 (24bit). This can be done by adding an UPDATE SQL statement that changes the colours to 3 where palette != grayscale, right after the ALTER TABLE statement.
But this is all up to you of course
Also, i can easily rebase the patch in the thread for you against the latest SVN. Git is wonderful.
UPDATE: I am now rebasing the patch in this thread against SVN version 3487. So far its going slowly because there are many conflicts that require manual editing (many code did change indeed) but i will be done by tomorrow
mastertheknife
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Fri Jul 29, 2011 10:18 pm
by zoneminder
Ok, cool. I will wait for the 'official' version then. I didn't have too much trouble applying the patch to 1.25.0, it was only zm_remote_camera_rtsp.cpp I think that wasn't trivial.
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Sun Jul 31, 2011 7:39 pm
by mastertheknife
zoneminder wrote:Ok, cool. I will wait for the 'official' version then. I didn't have too much trouble applying the patch to 1.25.0, it was only zm_remote_camera_rtsp.cpp I think that wasn't trivial.
I finished today and so far its working great!
http://i.imgur.com/s8gFb.jpg
I also love the new logging, its awesome and i can now view errors and such directly from my cellphone!
http://i.imgur.com/ComE7.jpg
I have attached a patch against SVN revision 3487. Make sure to grab a clean copy of SVN revision 3487. Need to put the patch in the same folder and run:
Code: Select all
patch -p1 -i zm_r3487-perfpatch_v1l.patch
After that proceed as normal (configure, make, make install, zmupdate.pl). Although depending on what SQL file you used to create your database, might need to run an SQL query to add the "Colours" colum to the Monitors table.
In case zm_event.cpp fails to patch or compile, i attached it anyway.
Now its all up to you
EDIT: Attachments removed. Relocated to the bottom of the first post.
mastertheknife
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Tue Aug 02, 2011 4:33 am
by jbmia
Just wanted to drop in and give you another big thanks for all your effort...
I'm a newb here, but I'm learning fast... I've got 3 usb cams running right now (with a pico card and some analog cams on the way).. but the usb web cams were a major major pain... I had to resort to mjpg-streamer, which is a great workaround, but the patch you've provided allows me to just select mjpg and be done with it... Nice.
Another thing that really really helped me out was tracking down and installing Sys::Mmap... F'ing around with shmmax was a real drag and took alot of pleasure out of using ZM... Now that I don't have lots of stuff going spontaneously red on me, I'm a happy camper!
Oh yeah, and the install.. just worked.. what a concept..
I'll be tweaking more and tracking the performance increase over the coming days... but again. Big thanks for your effort (and of course to Mr. ZoneMinder to...)!
What a powerful set of tools...
jbmia
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Tue Aug 02, 2011 2:32 pm
by mastertheknife
jbmia,
Thank you! I'm glad to hear
mastertheknife
Re: ZM 1.24.4 Performance Patch - Completed
Posted: Wed Aug 03, 2011 6:01 pm
by mastertheknife
Hi,
I see the SVN repository has been updated. Attached is the patch rebased against SVN revision 3493.
EDIT: Attachment removed. Relocated to the bottom of the first post.
mastertheknife