Trying to lower server CPU usage which is high with plugin enabled

In Progress

Comments

8 comments

  • Avatar
    Andrey Terentyev

    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
    Comment actions Permalink
  • Avatar
    Eryk Jaskowiec

    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
    Comment actions Permalink
  • Avatar
    Eryk Jaskowiec

    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
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    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
    Comment actions Permalink
  • Avatar
    Eryk Jaskowiec

    Hi, 
    more info about server running NX server:

    CPU: Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz   2.40 GHz
    RAM: 32GB

    I 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,
    Eryk

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    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
    Comment actions Permalink
  • Avatar
    Eryk Jaskowiec

    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
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    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
    Comment actions Permalink

Please sign in to leave a comment.