Page 1 of 1

Multiple zma processes on Record - ARM platform

Posted: Fri Dec 28, 2018 7:00 am
by snake
I did some benchmarking of ZM and found that Modect performed better than Record. It looks like Record spawns a number of zma daemons that load the CPU. This was using ZM 1.32.2 on the RPI 3. To install, I used Raspbian Stretch Lite, and added the sid and experimental repos, per the guide here: https://wiki.zoneminder.com/Debian

This is after a reboot, and there are no other visible errors. I tried enabling logs, but zma_m1 only mentions that the shared memory is not initialized by the daemon (when in record). I did not check zma_m1 when in modect.

I wonder if anyone else is seeing this? Based on my older setup, I understand there is typically 1 zma process per camera.

Here are two screenshots that illustrate the behaviour I am seeing:
record_highcpuuse_multiplezma.jpg
record_highcpuuse_multiplezma.jpg (244.89 KiB) Viewed 2660 times
modect_lowcpuuse.jpg
modect_lowcpuuse.jpg (236.84 KiB) Viewed 2660 times

Re: Multiple zma processes on Record - ARM platform

Posted: Fri Dec 28, 2018 1:32 pm
by knight-of-ni
You have an abnormal condition. You should have precisely one zma running, but it looks like you have 10 in that first screenshot!
See how the Log button is red? That means you have errors. What do those errors say?

Try stopping zoneminder, verify there are no zm* processes, then start zoneminder back up while watching your logs. What I expect to see is zma failing, then zmwatch tries to spawn a new zma, but the old zma does not die.

What is the resolution and frame rate of the camera in question?
What are you writing events to?

Re: Multiple zma processes on Record - ARM platform

Posted: Mon Dec 31, 2018 11:22 pm
by snake
record_multiplezmas_weblog2.jpg
record_multiplezmas_weblog2.jpg (322.85 KiB) Viewed 2624 times
The errors don't seem to indicate anything regarding ZMA. I tried changing Analysis Frames, as well as increasing Buffer frames, but there is no difference.

Resolution is 800x600. FPS is limited at 20, and ZMC records around 11FPS. I tried limiting FPS at the camera to 3, restarting ZM, but the issue remains. I am writing the the default /var/cache/zoneminder/events which is an SD card.

I did some more testing, and Mocord has the same issue. Monitor, Nodect, and Modect do not have issues with ZMA (Nodect and Monitor don't run ZMA).

I will attach the logs in the next post...

Re: Multiple zma processes on Record - ARM platform

Posted: Mon Dec 31, 2018 11:23 pm
by snake
Debug and Info logs attached.

Re: Multiple zma processes on Record - ARM platform

Posted: Tue Jan 01, 2019 2:03 pm
by knight-of-ni
The first thing you need to do, before anything else is fix those buffer overruns. That is the biggest source of your troubles.
You are hitting a resource bottleneck on your hardware, and as long as you see those errors in your logs, ZoneMinder will not be stable (i.e. zma, zmaudit, zmfilter, any zm process will be subject to failure).

You need to slow down your capture (just like the warning says) so lower the frame rates in your camera to something more reasonable, like 5 fps. Even that may not be enough. SD cards are the slowest thing you can buy these days in terms of read/write speeds. You need to write to something else. An SSD attached to USB is about the best you can do with the rpi. That's how I did it:
https://zoneminder.blogspot.com/p/raspberry-pi-3.html

You could also use a NAS if you have one.

Maybe I am misreading you logs, but it looks like you are attempting to use x264 encode. That mode is not currently compatible on Arm architecture, and I'm not sure how you even enabled it since we disabled it from the gui. It will appear to work, but the recorded video will not be playable. Passthrough should work though.

Turn off zmaudit.

Re: Multiple zma processes on Record - ARM platform

Posted: Mon Jan 07, 2019 3:19 am
by snake
knight-of-ni wrote: Tue Jan 01, 2019 2:03 pm Maybe I am misreading you logs, but it looks like you are attempting to use x264 encode. That mode is not currently compatible on Arm architecture, and I'm not sure how you even enabled it since we disabled it from the gui. It will appear to work, but the recorded video will not be playable. Passthrough should work though.
This turned out to be the bug. This was a fresh install - I had not set anything in the Storage tab, so what you saw was correct. It was attempting to use x264 encode, and somewhere the error was of the multiple ZMA entries. Once I disabled x264 encode (and I also set it to save JPEG frames (as encode is disabled, and this is MJPEG, not an H264 stream - so passthrough doesn't make sense)), then the multiple ZMAs disappeared. I'm not sure what the best solution is, but my initial thought is to not default to x264 encode in ARM. Maybe it should never default to H264 encode... Not sure.

Note that once I set "Video Writer" to disabled, then it was not possible to choose x264 encode, as you mentioned. But on a default ZM 1.32.2 install Video Writer is set to x264 encode, even if it's not functional on ARM, and must be deselected.

Otherwise, working good. I have an RPI3 w/ 800x600 MJPEG 10FPS Load of about 1.
Now I can return to benchmarking this.