arut / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
13.51k stars 3.52k forks source link

should improve performance, not better than srs(3.0release) now #1097

Open jingshaoqi opened 7 years ago

jingshaoqi commented 7 years ago

I compare performance between srs(https://github.com/ossrs/srs) and nginx-rtmp-module. I found latter occupy double cpu than srs. I use 5000 stream(1Mbps) to pull. I suggest to improve performance.

the follow is cpuprofile information:

Total: 7907 samples 7025 88.8% 88.8% 7025 88.8% libc_send ??:? 270 3.4% 92.3% 270 3.4% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:989 145 1.8% 94.1% 145 1.8% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:851 (discriminator 1) 81 1.0% 95.1% 106 1.3% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:539 50 0.6% 95.8% 50 0.6% ngx_unix_send /home/beauty/workspace/nginx/nginx-1.12.1/src/os/unix/ngx_send.c:36 36 0.5% 96.2% 48 0.6% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:545 25 0.3% 96.5% 25 0.3% ngx_event_process_posted /home/beauty/workspace/nginx/nginx-1.12.1/src/event/ngx_event_posted.c:35 23 0.3% 96.8% 23 0.3% ngx_rtmp_update_bandwidth /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_bandwidth.c:15 22 0.3% 97.1% 22 0.3% ngx_rtmp_send_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:743 21 0.3% 97.4% 7120 90.0% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:522 20 0.3% 97.6% 7045 89.1% ngx_unix_send /home/beauty/workspace/nginx/nginx-1.12.1/src/os/unix/ngx_send.c:34 16 0.2% 97.8% 16 0.2% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:547 15 0.2% 98.0% 15 0.2% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:500 14 0.2% 98.2% 14 0.2% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:542 11 0.1% 98.3% 11 0.1% ngx_rtmp_free_shared_chain /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_shared.c:64 11 0.1% 98.5% 11 0.1% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:871 11 0.1% 98.6% 11 0.1% ngx_rtmp_send_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:715 10 0.1% 98.7% 10 0.1% ngx_rtmp_send_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:748 9 0.1% 98.8% 9 0.1% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:860 8 0.1% 98.9% 7439 94.1% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:993 8 0.1% 99.0% 8 0.1% ngx_rtmp_send_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:731 7 0.1% 99.1% 7 0.1% libc_recv ??:? 7 0.1% 99.2% 7 0.1% ngx_rtmp_send_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:749 6 0.1% 99.3% 6 0.1% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:504 4 0.1% 99.3% 4 0.1% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:1001 4 0.1% 99.4% 4 0.1% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:1007 3 0.0% 99.4% 3 0.0% ngx_event_process_posted /home/beauty/workspace/nginx/nginx-1.12.1/src/event/ngx_event_posted.c:19 3 0.0% 99.5% 3 0.0% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:518 3 0.0% 99.5% 3 0.0% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:532 3 0.0% 99.5% 3 0.0% ngx_rtmp_send_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:712 2 0.0% 99.6% 2 0.0% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:524 2 0.0% 99.6% 2 0.0% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:538 2 0.0% 99.6% 2 0.0% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:557 2 0.0% 99.6% 2 0.0% ngx_unix_send /home/beauty/workspace/nginx/nginx-1.12.1/src/os/unix/ngx_send.c:15 2 0.0% 99.7% 2 0.0% ngx_unix_send /home/beauty/workspace/nginx/nginx-1.12.1/src/os/unix/ngx_send.c:73 1 0.0% 99.7% 1 0.0% nss_passwd_lookup /build/glibc-t3gR2i/glibc-2.23/string/../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:2005 1 0.0% 99.7% 1 0.0% nss_passwd_lookup /build/glibc-t3gR2i/glibc-2.23/string/../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:61 1 0.0% 99.7% 1 0.0% __nss_passwd_lookup /build/glibc-t3gR2i/glibc-2.23/string/../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:79 1 0.0% 99.7% 1 0.0% ngx_event_process_init /home/beauty/workspace/nginx/nginx-1.12.1/src/event/ngx_event.c:720 (discriminator 1) 1 0.0% 99.7% 1 0.0% ngx_rtmp_append_shared_bufs /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_shared.c:108 1 0.0% 99.7% 1 0.0% ngx_rtmp_dash_video /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/dash/ngx_rtmp_dash_module.c:1163 (discriminator 1) 1 0.0% 99.8% 1 0.0% ngx_rtmp_free_shared_chain /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_shared.c:71 1 0.0% 99.8% 1 0.0% ngx_rtmp_handshake /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handshake.c:581 1 0.0% 99.8% 1 0.0% ngx_rtmp_hls_video /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/hls/ngx_rtmp_hls_module.c:1862 (discriminator 1) 1 0.0% 99.8% 1 0.0% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:871 (discriminator 2) 1 0.0% 99.8% 1 0.0% ngx_rtmp_prepare_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:568 1 0.0% 99.8% 1 0.0% ngx_rtmp_prepare_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:619 1 0.0% 99.8% 1 0.0% ngx_rtmp_receive_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:769 1 0.0% 99.8% 1 0.0% ngx_rtmp_recv /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:238 1 0.0% 99.9% 1 0.0% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:491 1 0.0% 99.9% 1 0.0% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:516 1 0.0% 99.9% 1 0.0% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:541 1 0.0% 99.9% 1 0.0% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:544 1 0.0% 99.9% 1 0.0% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:553 1 0.0% 99.9% 1 0.0% ngx_rtmp_send_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:723 1 0.0% 99.9% 1 0.0% ngx_rtmp_send_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:730 1 0.0% 99.9% 1 0.0% ngx_rtmp_send_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:735 1 0.0% 100.0% 1 0.0% ngx_rtmp_send_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:739 (discriminator 1) 1 0.0% 100.0% 1 0.0% ngx_rtmp_update_bandwidth /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_bandwidth.c:24 1 0.0% 100.0% 1 0.0% ngx_rtmp_update_bandwidth /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_bandwidth.c:25 1 0.0% 100.0% 1 0.0% ngx_unix_send /home/beauty/workspace/nginx/nginx-1.12.1/src/os/unix/ngx_send.c:39 0 0.0% 100.0% 7907 100.0% __libc_start_main /build/glibc-t3gR2i/glibc-2.23/csu/../csu/libc-start.c:291 0 0.0% 100.0% 7907 100.0% _start ??:? 0 0.0% 100.0% 7907 100.0% main /home/beauty/workspace/nginx/nginx-1.12.1/src/core/nginx.c:372 0 0.0% 100.0% 3 0.0% memmove (inline) /usr/include/x86_64-linux-gnu/bits/string3.h:59 0 0.0% 100.0% 7906 100.0% ngx_epoll_process_events /home/beauty/workspace/nginx/nginx-1.12.1/src/event/modules/ngx_epoll_module.c:902 0 0.0% 100.0% 1 0.0% ngx_event_accept /home/beauty/workspace/nginx/nginx-1.12.1/src/event/ngx_event_accept.c:309 0 0.0% 100.0% 7906 100.0% ngx_process_events_and_timers /home/beauty/workspace/nginx/nginx-1.12.1/src/event/ngx_event.c:242 0 0.0% 100.0% 1 0.0% ngx_rtmp_handshake_recv /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handshake.c:456 0 0.0% 100.0% 1 0.0% ngx_rtmp_handshake_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handshake.c:520 0 0.0% 100.0% 1 0.0% ngx_rtmp_init_connection /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_init.c:138 0 0.0% 100.0% 1 0.0% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:805 0 0.0% 100.0% 2 0.0% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:807 0 0.0% 100.0% 3 0.0% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:930 0 0.0% 100.0% 1 0.0% ngx_rtmp_live_av /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_live_module.c:968 0 0.0% 100.0% 7892 99.8% ngx_rtmp_receive_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:799 0 0.0% 100.0% 3 0.0% ngx_rtmp_recv /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:244 0 0.0% 100.0% 7 0.1% ngx_rtmp_recv /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:256 0 0.0% 100.0% 7893 99.8% ngx_rtmp_recv /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:464 0 0.0% 100.0% 28 0.4% ngx_rtmp_send /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:561 0 0.0% 100.0% 7370 93.2% ngx_rtmp_send_message /home/beauty/workspace/nginx/nginx-1.12.1/../nginx-rtmp-module/ngx_rtmp_handler.c:744 0 0.0% 100.0% 1 0.0% ngx_single_process_cycle /home/beauty/workspace/nginx/nginx-1.12.1/src/os/unix/ngx_process_cycle.c:299 0 0.0% 100.0% 7906 100.0% ngx_single_process_cycle /home/beauty/workspace/nginx/nginx-1.12.1/src/os/unix/ngx_process_cycle.c:309 0 0.0% 100.0% 7 0.1% ngx_unix_recv /home/beauty/workspace/nginx/nginx-1.12.1/src/os/unix/ngx_recv.c:69 0 0.0% 100.0% 7 0.1% recv (inline) /usr/include/x86_64-linux-gnu/bits/socket2.h:44

nginx_cpuprofile.txt

yxchng commented 6 years ago

does that mean srs is better than nginx-rtmp?