mtcp-stack / mtcp

mTCP: A Highly Scalable User-level TCP Stack for Multicore Systems
Other
1.96k stars 432 forks source link

About mTCP Performance in File Sending #288

Closed agdomacena2 closed 4 years ago

agdomacena2 commented 4 years ago

Hi,

  1. I am sending a 322 MB file from a server that uses mTCP to another computer that runs on Linux and comparing it to just sending the file through the Linux TCP/IP stack. My server program for mTCP is a modified epserver, my server program for the Linux TCP/IP stack is a simple file sending server and my client program has a timer that gets the time that it takes for the file to be fully transferred from the server to the client. The results though show that the Linux TCP/IP stack is faster than the mTCP stack (3.51 seconds vs 3.76 seconds). Is this expected or should the mTCP stack be faster.

What I changed is the HandleReadEvent function where it sends the size of the file in bytes and uses the SendUntilAvailable function to send the file to any client who connects to the server.

Relevant Code for mTCP

    sv->fsize = fcache[0].size;
    sv->fidx = 0;
    size = sv->fsize;
    rd = mtcp_write(ctx->mctx, sockid, &size, sizeof(int));

    sv->rspheader_sent = TRUE;

    ev.events = MTCP_EPOLLIN | MTCP_EPOLLOUT;
    ev.data.sockid = sockid;
    mtcp_epoll_ctl(ctx->mctx, ctx->ep, MTCP_EPOLL_CTL_MOD, sockid, &ev);

    SendUntilAvailable(ctx, sockid, sv);
  1. Additional question: Can mTCP be used with C++?
ajamshed commented 4 years ago

@agdomacena2,

I went through the code quickly. I don't think it has to do with the code changes. It's more related to your environment settings. Since you are using only 1 flow, it is possible that the client request lands in CPU 0 in the server side. Please note that, with mTCP, all instructions starting from packet reception all the way up to HTTP service request will be done on CPU 0. With the Linux version, the server will be able to use all the cores in the system. Can you retry the experiment (Linux version) with only 1 CPU online (using /proc/ or /sys/ fs)?

The stack is completely written in C. You can try using g++ to compile the stack. I expect that you may face compile-time warnings (mTCP is compiled with -Werror CFLAGS/CXXFLAGS) which you may need to fix.

agdomacena2 commented 4 years ago

I got 10.85 seconds in the Linux version when only 1 CPU core is online. Thanks.

Did you also disable your CPU cores using /proc/ or /sys/ fs when you tested the performance of the short TCP connections with respect to the number of CPU cores in your paper?

ajamshed commented 4 years ago

Yes. In order to maintain fairness, whenever we would conduct experiments with, say 8 CPUS, we would only keep 8 cores online for both mTCP and Linux based experiments.