Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance optimization: split all the members of dpvs connection into two groups for its initialization. #598

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

andrewhit
Copy link

  • TCP CPS can be increased by 10% for the single core with TCP flood traffic
    sent by hping3.

@@ -98,7 +98,6 @@ static struct dp_vs_conn *dp_vs_conn_alloc(enum dpvs_fwd_mode fwdmode,
return NULL;
}

memset(conn, 0, sizeof(struct dp_vs_conn));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it safe to use uninitialized dp_vs_conn? Did you examine every field of dp_vs_conn and check whether it may be used uninitialized?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been tested and no issue is found.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think uninitialized dp_vs_conn is good idea. Someday add some field in dp_vs_conn, it may lead problem.

For uninitialized dp_vs_conn maybe we can do something in dp_vs_conn_free before invoke rte_mempool_put?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fnat_seq needs to be initialized as 0, otherwise it brings the fault to tcp connections. Additionally, double assignment for the same field of dpvs connection is not good to CPS performance.

@ywc689 ywc689 added the pr/to-confirm-needs consider whether the feature of pr is needed label Jul 19, 2020
@ywc689 ywc689 added pr/to-test-codes Compile and test the patch of pr to verify if it works. pr/needs-confirmed the feature in the pr is what we need,and list what cases should be checked in later stages and removed pr/to-confirm-needs consider whether the feature of pr is needed labels Jul 20, 2020
@ywc689
Copy link
Collaborator

ywc689 commented Jul 28, 2020

DPVS crashed after a 2-hours stress test using this patch. Traces show mbuf is tainted.

#0  0x00007ffff6b315f7 in raise () from /lib64/libc.so.6
#1  0x00007ffff6b32ce8 in abort () from /lib64/libc.so.6
#2  0x00007ffff6b2a566 in __assert_fail_base () from /lib64/libc.so.6
#3  0x00007ffff6b2a612 in __assert_fail () from /lib64/libc.so.6
#4  0x0000000000689b51 in netif_port_get (id=65535) at /home/wencyu/github/dpvs/src/netif.c:3173
#5  0x0000000000687258 in lcore_process_packets (qconf=0x14d8a80 <lcore_conf+3551552>, mbufs=0x14d8a90 <lcore_conf+3551568>, cid=4 '\004', count=3, pkts_from_ring=false) at /home/wencyu/github/dpvs/src/netif.c:2325
#6  0x0000000000687cd7 in lcore_job_recv_fwd (arg=0x0) at /home/wencyu/github/dpvs/src/netif.c:2442
#7  0x00000000006961c3 in do_lcore_job (job=0xc61040 <netif_jobs>) at /home/wencyu/github/dpvs/src/scheduler.c:153
#8  0x00000000006962f7 in dpvs_job_loop (arg=0x0) at /home/wencyu/github/dpvs/src/scheduler.c:201
#9  0x0000000000548894 in eal_thread_loop ()
#10 0x00007ffff70d0dc5 in start_thread () from /lib64/libpthread.so.0
#11 0x00007ffff6bf221d in clone () from /lib64/libc.so.6

@ywc689 ywc689 added pr/codes-test-failed compile problem exists or specified test cases not passed and removed pr/to-test-codes Compile and test the patch of pr to verify if it works. labels Jul 28, 2020
@andrewhit
Copy link
Author

andrewhit commented Jul 28, 2020

DPVS crashed after a 2-hours stress test using this patch. Traces show mbuf is tainted.

#0  0x00007ffff6b315f7 in raise () from /lib64/libc.so.6
#1  0x00007ffff6b32ce8 in abort () from /lib64/libc.so.6
#2  0x00007ffff6b2a566 in __assert_fail_base () from /lib64/libc.so.6
#3  0x00007ffff6b2a612 in __assert_fail () from /lib64/libc.so.6
#4  0x0000000000689b51 in netif_port_get (id=65535) at /home/wencyu/github/dpvs/src/netif.c:3173
#5  0x0000000000687258 in lcore_process_packets (qconf=0x14d8a80 <lcore_conf+3551552>, mbufs=0x14d8a90 <lcore_conf+3551568>, cid=4 '\004', count=3, pkts_from_ring=false) at /home/wencyu/github/dpvs/src/netif.c:2325
#6  0x0000000000687cd7 in lcore_job_recv_fwd (arg=0x0) at /home/wencyu/github/dpvs/src/netif.c:2442
#7  0x00000000006961c3 in do_lcore_job (job=0xc61040 <netif_jobs>) at /home/wencyu/github/dpvs/src/scheduler.c:153
#8  0x00000000006962f7 in dpvs_job_loop (arg=0x0) at /home/wencyu/github/dpvs/src/scheduler.c:201
#9  0x0000000000548894 in eal_thread_loop ()
#10 0x00007ffff70d0dc5 in start_thread () from /lib64/libpthread.so.0
#11 0x00007ffff6bf221d in clone () from /lib64/libc.so.6

Which test case are you running? Do you have the backtrace in detail?

@ywc689
Copy link
Collaborator

ywc689 commented Jul 28, 2020

I patched the codes to the lastest devel branch, and tested it using the following the fullnat services. Run the case with 1Gbps/70Wpps HTTP traffic in total, dpvs crashed after serveral hours.

[root@~ dpvs]# ipvsadm -ln
IP Virtual Server version 0.0.0 (size=0)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.88.30:80 wrr persistent 15 synproxy conn_timeout 5
  -> 192.168.88.15:80             FullNat 100    0          0         
  -> 192.168.88.115:80            FullNat 100    89         16802     
  -> 192.168.88.215:80            FullNat 100    0          0         
TCP  192.168.88.32:80 rr
  -> 192.168.88.15:80             FullNat 100    29         1688      
  -> 192.168.88.115:80            FullNat 100    32         1684      
  -> 192.168.88.215:80            FullNat 100    29         1690      
TCP  [2001::30]:8080 conhash sip synproxy
  -> 192.168.88.15:80             FullNat 100    89         7500      
  -> 192.168.88.115:80            FullNat 100    0          0         
  -> 192.168.88.215:80            FullNat 100    0          0         
[root@~ dpvs]# dpip link show -s
1: dpdk0: socket 0 mtu 1500 rx-queue 8 tx-queue 8
    UP 10000 Mbps full-duplex auto-nego 
    addr A0:36:9F:74:EC:F0 OF_RX_IP_CSUM OF_TX_IP_CSUM OF_TX_TCP_CSUM OF_TX_UDP_CSUM 
    ipackets            opackets            ibytes              obytes              
    15164676896         15212314092         2989493919579       2994458765519       
    ierrors             oerrors             imissed             rx_nombuf           
    0                   0                   0                   0                   
    mbuf-avail          mbuf-inuse          
    507958              16329   

@andrewhit
Copy link
Author

Okay. We will duplicate this issue and fix it.

@andrewhit
Copy link
Author

andrewhit commented Jul 29, 2020

It seems related to the below configuration and it is day 1 issue. Have you tested without the patch of this PR?

# persistence_timeout 15

@ywc689
Copy link
Collaborator

ywc689 commented Jul 29, 2020

I tested the current devel branch codes with this case. It ran about 2 days no crash.

@andrewhit
Copy link
Author

andrewhit commented Aug 5, 2020

I have figured out some solution which will be sent out soon.

@andrewhit andrewhit closed this Aug 5, 2020
@andrewhit andrewhit deleted the dpvs-bug-21 branch August 5, 2020 14:07
@andrewhit andrewhit restored the dpvs-bug-21 branch August 6, 2020 03:27
@andrewhit andrewhit reopened this Aug 6, 2020
@andrewhit andrewhit changed the title ipvs: no need to zero the bytes of the newly allocated dpvs connection. ipvs: split all the members of dpvs connection into two groups for its initialization for the benefit of CPS. Aug 10, 2020
@andrewhit andrewhit changed the title ipvs: split all the members of dpvs connection into two groups for its initialization for the benefit of CPS. performance optimization: split all the members of dpvs connection into two groups for its initialization. Aug 10, 2020
@andrewhit
Copy link
Author

With this patch, TCP CPS can be increased by 10% with 14 CPU cores used.

Copy link
Collaborator

@ywc689 ywc689 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that many members of dp_vs_conn are still zerod with memset. Are you sure the latest patch make 10% performance enhancement?

Besides, function pointer members (such as packet_xmit, packet_out_xmit) should always be zerod, because it's a disater if they are not assigned before use.

include/ipvs/conn.h Show resolved Hide resolved
src/ipvs/ip_vs_conn.c Show resolved Hide resolved
@andrewhit
Copy link
Author

It seems that many members of dp_vs_conn are still zerod with memset. Are you sure the latest patch make 10% performance enhancement?

Besides, function pointer members (such as packet_xmit, packet_out_xmit) should always be zerod, because it's a disater if they are not assigned before use.

packet_xmit and packet_out_xmit() is initialized within dp_vs_conn_bind_dest() invoked by dp_vs_conn_new().

@andrewhit
Copy link
Author

Please have a check on the latest patch.

@ywc689
Copy link
Collaborator

ywc689 commented Aug 25, 2020

@andrewhit The latest patch itself is all OK now. But I'm concerned about its easy use and safety. For example, just as what you say, packet_xmit and packet_out_xmit are initialized in dp_vs_conn_bind_dest, the initialization of the two function pointers are determined by other modules outside of dp_vs_conn_new. This a not a good practice of defensive programming.
We'll evalute the preforamnce, and determine whether adopt this PR or not later.

@ywc689 ywc689 added the pr/to-evaluate-performance the pr is required a performance evaluation label Aug 25, 2020
@ywc689 ywc689 removed the pr/codes-test-failed compile problem exists or specified test cases not passed label Aug 25, 2020
zhuangyan added 2 commits August 3, 2022 10:47
- TCP CPS can be increased by 10% for the single core with TCP flood traffic
  sent by hping3.
initialization and it's for the benefit of CPS.

a) Remove the operation of bezeroing all the members of dpvs connection within
   dp_vs_conn_alloc().

b) Each member of dpvs connection is initialized ONCE via dp_vs_conn_pre_init()
   or dp_vs_conn_new().

  - dp_vs_conn_pre_init() initializes all the members of one group as 0, but
    ack_mbuf.

  - dp_vs_conn_new() initializes all the members of the other group with the
    specific values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/needs-confirmed the feature in the pr is what we need,and list what cases should be checked in later stages pr/to-evaluate-performance the pr is required a performance evaluation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants