Trying to lower server CPU usage which is high with plugin enabled
AnsweredHi,
I have created a plugin which is taking frame only every second, encoding to JPG and sending over HTTP to dedicated server. There are about 100 cameras running on single NX server. Without plugin CPU usage is about 20%. With plugin enabled CPU usage is as follow:
Cameras: 0 -> 20%
Cameras 10 -> 25%
Cameras 20 -> 28%
Cameras 30 -> 34%
Cameras 40 -> 48%
Cameras 50 -> 55%
Cameras 60 -> 83%
Cameras 70 -> 95%
Cameras 80 and above -> 100% and got warning about plugin skipping frames
I use BGR format on plugin so in engine.cpp there is: needUncompressedVideoFrames_bgr
I clearly don't need server to encoder and provider every single frame which is causing this high CPU usage. Is there any manifest option or other way to run this operations less frequently?
Upgrading CPUs is not an option because there are already about 20 setups running NX server.
NX server version: 4.2
With regards,
Eryk
-
Hi Eryk Jaskowiec,
The default internal Server format for uncompressed frames is yuv420. That means, when the Server decoded video frames, it does to yuv420.
When you request another format, needUncompressedVideoFrames_bgr in your case, you make the Server to transcode EVERY yuv420 frame to BGR.
I see two options.
1. Request yuv420. Encode to JPG. Send to over HTTP.
2. Request yuv420. Send yuv420 frame over HTTP. Encode to JPG in the dedicated server.
0 -
Thanks for replaying Andrey Terentyev.
That was my first thought to changed this format so I made little refactor of my code yesterday to request and encode YUV420 format. I have successfully encode grayscale image (first plane). Had some problems with adding color to my image. Finally solved it with best answer of this tread: https://stackoverflow.com/questions/50230188/yuv420-to-bgr-image-from-pixel-pointers
We need to define 3 channels as:
cv::Mat y(height, width, CV_8UC1, (void*)videoFrame->data(0), (size_t)videoFrame->lineSize((0)));
cv::Mat u(half_height, half_width, CV_8UC1, (void*)videoFrame->data(1), (size_t)videoFrame->lineSize((1)));
cv::Mat v(half_height, half_width, CV_8UC1, (void*)videoFrame->data(2), (size_t)videoFrame->lineSize((2)));There is some related topic. Maybe we can link it.
https://support.networkoptix.com/hc/en-us/community/posts/360037395653-Convert-IUncompressedVideoFrame-to-OpenCV-Mat-Today I plan to make a CPU stress tests to see if something changed. I will give info about load change :)
0 -
Unfortunately nothing changed after changing from BGR to YUV420. Below table of load:
Cameras
CPU%
0
20
10
28
20
34
30
40
40
50
50
55
60
80
70
90
80
100
Any other ideas how we can optimize this? Maybe some change in SDK to request for frames less frequently?
0 -
Hi,
Could you test the load without frame transcoding inside your plugin?
Just request yuv420 frames from the Server.
In your plugin, do nothing regarding frame transcoding, just exit the DeviceAgent::pushCompressedVideoFrame() returning true.
What's the load?
0 -
Hi,
more info about server running NX server:CPU: Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz 2.40 GHz
RAM: 32GBI made test with empty plugin as you suggest. Results:
Cameras - CPU%
0 - 20%
10 - 23%
20 - 25%
30 - 27%
40 - 29%
50 - 31%
60 - 33%
70 - 36%
80 - 45%
90 - 55%
100 - 80% to 95% (big increase here)
104 - 80% to 100%There is a little improvement without my logic but I can imagine that resizing and encoding 100 x 4K/FHD YUV420 images to JPG in one second can take this additional 20% of CPU.
Without any plugin enabled CPU load is constant (about 20%).
Empty plugin still utilise a lot of CPU. That's why I asked if there is possibility to run plugin only in (configured) intervals as I don't need every single frame from cameras.With regards,
Eryk0 -
Hi,
That's why I asked if there is possibility to run plugin only in (configured) intervals as I don't need every single frame from cameras.
At the moment there is no such possibility.
0 -
Ok, just to clarify.
ATM there is no way to run any plugin on system where we have more than 100 cameras?
The only way to to this is to split to two servers each with 64 cameras?
0 -
Hi,
No to both questions.
The number of cameras and plugins per server depends on the computing power of the Server (CPU, RAM, HDD speed), video stream settings on cameras (FPS, resolution), network bandwidth, your recording policy. You can adjust settings to address your objective.
For example, 20 cameras with 4K resolution at 30 FPS does not produce the same load as 20 cameras with 1024x768 at 15 FPS.
There are recommended values based on general considerations and good practice. For instance, it's recommended keeping CPU load about 70%
You can use our calculator for planing your system http://nx.networkoptix.com/calculator/
As per plugins, the load should be tested case by case depending on the plugin.
You can ask more questions on system planning in the "Nx Wintess Software Suite" section.https://support.networkoptix.com/hc/en-us/community/topics/360001610173-Nx-Witness-Software-Suite
0
Please sign in to leave a comment.
Comments
8 comments