<div dir="ltr"><div>Hi</div><div>Thanks a lot for your suggestions. I executed perf top for 2 participants. The o/p looks like this. I'm trying to figure out information displayed by the tool. it seems like the kernel takes almost 50 % of cpu and most of it is finish_task_switch and in soft irq. other calls like malloc, free ,pad_push consume most cpu. The tool displays the result in percentage. My guess is   5.17 % means  out of 14 % (total cpu percentage of the server), 5.17 % is consumed by finish_task_switch ?  Is that observation correct ? If so, how could we reduce that cpu load consumed ? Even other functions that are consuming are all related to glibc and kernel.  <br></div><div>Samples: 70K of event 'cpu-clock:pppH', 4000 Hz, Event count (approx.): 3675894121 lost: 0/0 drop: 0/0<br>Overhead  Shared Object                 Symbol<br>   5.17%  [kernel]                      [k] finish_task_switch<br>   5.15%  [kernel]                      [k] _raw_spin_unlock_irqrestore<br>   2.96%  <a href="http://libc-2.28.so">libc-2.28.so</a>                  [.] _int_malloc<br>   2.73%  <a href="http://libc-2.28.so">libc-2.28.so</a>                  [.] _int_free<br>   2.56%  [kernel]                      [k] __softirqentry_text_start<br>   2.25%  [kernel]                      [k] cpuidle_enter_state<br>   2.01%  libgobject-2.0.so.0.6600.3    [.] g_type_check_instance_is_fundamentally_a<br>   1.83%  perf                          [.] evsel__parse_sample<br>   1.68%  [kernel]                      [k] do_syscall_64<br>   1.17%  libglib-2.0.so.0.6600.3       [.] g_mutex_lock<br>   1.13%  [kernel]                      [k] vmxnet3_tq_xmit.isra.63<br>   1.05%  <a href="http://libc-2.28.so">libc-2.28.so</a>                  [.] malloc<br>   0.82%  perf                          [.] dso__find_symbol<br>   0.82%  libgstreamer-1.0.so.0.2100.0  [.] gst_pad_push_data<br>   0.77%  perf                          [.] perf_mmap__read_event<br>   0.74%  <a href="http://libc-2.28.so">libc-2.28.so</a>                  [.] cfree@GLIBC_2.2.5<br>   0.73%  <a href="http://libc-2.28.so">libc-2.28.so</a>                  [.] syscall<br>   0.68%  libglib-2.0.so.0.6600.3       [.] g_mutex_unlock<br>   0.64%  perf                          [.] 0x000000000027a1c7<br>   0.63%  [kernel]                      [k] nft_do_chain<br>   0.58%  libglib-2.0.so.0.6600.3       [.] g_slice_alloc<br>   0.55%  libcrypto.so.1.1.1g           [.] sha1_block_data_order_ssse3<br>   0.55%  [kernel]                      [k] menu_reflect<br>   0.49%  [kernel]                      [k] cpuidle_reflect<br>   0.49%  [kernel]                      [k] do_idle<br>   0.48%  <a href="http://libpthread-2.28.so">libpthread-2.28.so</a>            [.] __pthread_mutex_lock<br>   0.47%  <a href="http://libc-2.28.so">libc-2.28.so</a>                  [.] __memmove_sse2_unaligned_erms<br>   0.46%  libgobject-2.0.so.0.6600.3    [.] g_type_check_instance_cast<br>   0.44%  [kernel]                      [k] vmxnet3_poll_rx_only<br>   0.42%  libgstreamer-1.0.so.0.2100.0  [.] gst_mini_object_unref<br>   0.42%  [kernel]                      [k] __audit_syscall_entry<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 26, 2022 at 3:51 AM Olivier Crête <<a href="mailto:olivier.crete@collabora.com">olivier.crete@collabora.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I'd start by running "perf top" to know exactly what is using CPU time.<br>
I'm surprised that the nicesrc threads are taking so much, all this<br>
does is receive the packets and feed them to a queue. The queue1 thread<br>
is probably the one does DTLS, so it's less surprising that they would<br>
use CPU time. But it's hard to say anything definitive without doing<br>
profiling on your system.<br>
<br>
Olivier<br>
<br>
<br>
On Thu, 2022-08-25 at 23:51 +0530, Pradeep Acharya via gstreamer-devel<br>
wrote:<br>
> Hi ,<br>
> Any suggestions on reducing CPU utilization would be helpful.<br>
> Regards<br>
> Pradeep<br>
> <br>
> On Thu, Aug 4, 2022 at 7:06 PM Pradeep Acharya<br>
> <<a href="mailto:pradeep.acharya1008@gmail.com" target="_blank">pradeep.acharya1008@gmail.com</a>> wrote:<br>
> > Hi,<br>
> > This is a query related to CPU utilization and any optimization can<br>
> > be done to reduce the CPU utilization.i've a media server that<br>
> > connects to web app applications running in the browser  . The<br>
> > media server uses webrtc bin plugin .<br>
> > I use a single socket to transmit and receive audio/video .  I've<br>
> > attached the png files extracted from the Dot file. Below is<br>
> > configuration details of the server used<br>
> > <br>
> > Num of CPU cores: 8<br>
> > Model: Intel(R) Xeon(R) CPU  X5650  @ 2.67GHz<br>
> > Audio codec: opus <br>
> > video codec : VP8 <br>
> > video encoding by clients: 640 x480 @ ~ 500 kbps<br>
> > <br>
> > The server does not decode or encode the RTP but just forward from<br>
> > one client to another. When I execute the top command, I find that<br>
> > the cpu % is around 14 to 16 % just for 2 clients . The cpu<br>
> > utilization goes up higher and higher as the number of clients<br>
> > connected to the server increases. For 8 participants it goes<br>
> > beyond 400% , distributed among the cores. output of the top<br>
> > command <br>
> > <br>
> > 2329570 root     -11   0 4074924  73708  18920 S   2.0   1.3  <br>
> > 0:01.80 queue1:src<br>
> > 2331060 root     -11   0 4074924  73708  18920 S   1.7   1.3  <br>
> > 0:01.45 nicesrc1:src<br>
> > 2329568 root     -11   0 4074924  73708  18920 S   1.3   1.3  <br>
> > 0:05.39 nicesrc0:src<br>
> > 2329569 root     -11   0 4074924  73708  18920 S   1.3   1.3  <br>
> > 0:04.39 queue0:src<br>
> > 2331061 root     -11   0 4074924  73708  18920 S   1.3   1.3  <br>
> > 0:01.38 queue2:src<br>
> > 2331062 root     -11   0 4074924  73708  18920 S   1.0   1.3  <br>
> > 0:01.41 queue3:src<br>
> > 2329567 root     -11   0 4074924  73708  18920 S   0.7   1.3  <br>
> > 0:01.64 rtpsession-rtcp<br>
> > 2329583 root     -11   0 4074924  73708  18920 S   0.7   1.3  <br>
> > 0:00.94 rtpjitterbuffer<br>
> > 2331058 root     -11   0 4074924  73708  18920 S   0.7   1.3  <br>
> > 0:00.39 appsrc_Audio_36<br>
> > 2331059 root     -11   0 4074924  73708  18920 S   0.7   1.3  <br>
> > 0:00.64 rtpsession-rtcp<br>
> > 2331079 root     -11   0 4074924  73708  18920 S   0.7   1.3  <br>
> > 0:00.42 rtpjitterbuffer<br>
> > 2331080 root     -11   0 4074924  73708  18920 S   0.7   1.3  <br>
> > 0:00.38 rtpjitterbuffer<br>
> > 2329580 root     -11   0 4074924  73708  18920 S   0.3   1.3  <br>
> > 0:00.08 timer<br>
> > 2329582 root     -11   0 4074924  73708  18920 S   0.3   1.3  <br>
> > 0:01.42 rtpjitterbuffer<br>
> > 2329584 root     -11   0 4074924  73708  18920 S   0.3   1.3  <br>
> > 0:00.51 rtpjitterbuffer<br>
> > 2331070 root     -11   0 4074924  73708  18920 S   0.3   1.3  <br>
> > 0:00.40 appsrc_Audio_13<br>
> > 2331084 root     -11   0 4074924  73708  18920 S   0.3   1.3  <br>
> > 0:00.20 rtpjitterbuffer<br>
> > <br>
> > From the above, I see that nicesrc plugin takes around 2 % of cpu<br>
> > of one client  I think this plugin receives packets and puts them<br>
> > to queue. Should this thread take 2 % cpu to receive RTP packets<br>
> > from socket and put them to queue ?<br>
> > other elements like nicesink, rtpjitterbuffer ,appsrc thread<br>
> > consume CPU. Features like do-nack and TWCC are enabled for video <br>
> > <br>
> > 1. Is there any benchmark of CPU utilization that the webrtcbin<br>
> > plugin should take for a 2 way TX and RX of audio,video RTP<br>
> > packets @ 500 kbps ?  <br>
> > 2. ARe there any element property config changes that need to be<br>
> > done to reduce CPU utilization ?<br>
> > 3. How to proceed to reduce cpu utilization ? Any suggestions that<br>
> > help me  in figuring out are welcome<br>
> > <br>
> >  <br>
> > Thanks <br>
> > Pradeep<br>
<br>
-- <br>
Olivier Crête<br>
<a href="mailto:olivier.crete@collabora.com" target="_blank">olivier.crete@collabora.com</a><br>
</blockquote></div>