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

tcp slowdown when recv large stream #127

Closed
up0617 opened this issue May 22, 2020 · 0 comments
Closed

tcp slowdown when recv large stream #127

up0617 opened this issue May 22, 2020 · 0 comments

Comments

@up0617
Copy link

up0617 commented May 22, 2020

I'm trying to recv files via DPDK TCP sock.
I found that DPDK ANS is faster at low size file but slower at big size than kernel, as below.

kernel dpdk-ans Size
0.014478 0.018714 9.2M
0.007788 0.009212 3.8M
0.004526 0.003432 1.3M
0.002268 0.001319 212K

(*sec)

I just wonder if It is a known issue.

I tried some settings to optimize performance(cpu affinity, pinning, numa, tcp_nodelay, change BURST_TX_DRAIN_US, MAX_TX_BURST and etc...) but these make no difference.

Below is my send/recv logic.

#define SEND_MAX_SIZE (8192)

#senderside code
int sendData(int sockfd, FILE * fp, char *path, int fileSize){
    int readLen;
    char buf[SEND_MAX_SIZE];  
    while ((readLen = fread(buf, sizeof(char), SEND_MAX_SIZE, fp))>0) {
        int sendLen = readLen;
        int sent = 0;
        int totalsend = 0;
        while(sendLen){
    #ifdef DPDK_Enabled
            sent = anssock_send(sockfd, buf+totalsend, sendLen, 0);
    #else
            sent = send(sockfd, buf+totalsend, sendLen, 0);
    #endif
            if (sent < 0)
            {
                sent = 0;
                if ( errno == EAGAIN){
                    continue;
                }
                else {
                    return -1;
                }
            }
            sendLen -= sent;
            totalsend += sent;
        }
    }
    return 0;
}

#recv side code
void recvFile(struct epoll_event event, char* filename, int fileSize)
{
    int totalRecv = 0;
    
    char *recvBuf = Files[fileidx].buf;

    while (fileSize)
    {
        int recvsize = SEND_MAX_SIZE > fileSize ? fileSize : SEND_MAX_SIZE;
#ifdef DPDK_Enabled
        int recv_len = anssock_recv(event.data.fd, recvBuf+totalRecv, recvsize, 0);
#else
        int recv_len = recv(event.data.fd, recvBuf+totalRecv, recvsize, 0);
#endif
        if (recv_len<=0){
            if ( errno == EAGAIN){
                continue;
            }
            close(event.data.fd);
            exit(EXIT_FAILURE);
        }
        fileSize -= recv_len;
        totalRecv += recv_len;
    }
    return;
}
@up0617 up0617 closed this as completed Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant