ansyun / dpdk-ans

ANS(Accelerated Network Stack) on DPDK, DPDK native TCP/IP stack.
https://ansyun.com
BSD 3-Clause "New" or "Revised" License
1.15k stars 322 forks source link

Low TCP TX performance #119

Closed YoannGh closed 4 years ago

YoannGh commented 4 years ago

Using ANS, I am not able to send TCP data as much as Linux can.

I have been running the following code for 1 second, with data_len = 10 bytes, the ans_module file to switch between Linux stack and ANS and a TCP server that is counting tot_recv_len :

while (1) {
    ret = send(fd, data, data_len, 0);
    // usleep(1);
    if (ret > 0) {
        tot_sent_len += ret;
    } else {
        if (errno == EAGAIN)
            eagain_cnt++;
        else
            fail_cnt++;
    }
}

For linux the socket is set to non blocking.

This is the results I get:

For 1 second send/receive eagain_cnt fail_cnt tot_sent_len tot_sent_recv
Linux 164 0 10 108 790 10 108 790
Linux with usleep 3 0 175 600 175 600
ANS 453 694 0 4 860 10
ANS with usleep 0 0 176 970 176 970

I have tried to use ANS epoll to wait for the socket to becoming writable but it seems that epoll_wait never returns the EPOLLOUT event. My guess is that ANS is buffering TCP data but does not send it to the remote server. Then next calls to anssock_send return EAGAIN because the ANS TCP buffer is full?

YoannGh commented 4 years ago

Not sure why but setting TCP_NODELAY socket option solved the problem. Now ANS achieves the same performance as Linux.