User level network stack is becoming more and more important as number of connection is expected to rise exponentially with recent IoT trend. mTCP has attracted companies and researchers as it supports developer-friendly socket API, but it has been shown that performance falls behind run-to-completion stacks. We uncover the reasons behind the performance drop of mTCP and show that the overhead does not come from supporting socket API. Overhead comes from synchrozing two kernel level threads, inefficinet cache utilization while processing batch of packets and strict copying application payload. Based on the analysis, we derive three optimization techniques for mTCP: user-level threading, simulated zero-copy ring buffer and packet sorting with header prefetch. Microbenchmark result shows that mTCP's performance is on par with IX when redoing the same experiment conducted in IX paper and macrobenchmark performed with L7 load balancer implementation shows that optimized mTCP performs 20% faster than vanilla mTCP.
이 논문에서는 Epoll 기반 소켓 API를 지원하는 유저 레벨 네트워크 스택의 성능을 분석하고 최적화하는 방법을 제안한다. 커널의 VFS 오버헤드, 커널/유저간 문맥교환 오버헤드, 최근의 KPTI 패치 등 다양한 성능 저하 요인으로 인하여 유저 레벨에서 네트워크 스택을 구현하려는 다양한 시도가 있다. 이 중 Epoll 기반의 mTCP는 응용 프로그램을 이식하기에는 용이하나 최근의 run-to-completion 스택 대비 성능이 낮은 문제가 있었다. mTCP의 성능 병목을 분석한 결과, 소켓 API를 지원하기 위한 코드가 성능 저하의 원인이 아니고 스택의 캐시 활용 문제, 커널 스레드를 사용하면서 발생하는 오버헤드 등 디자인과 구현의 문제임을 밝혔다. 이를 해결하기 위하 유저 수준 스레드, 메모리 복사를 줄일 수 있는 수신 버퍼 설계, 패킷 정렬 및 패킷 헤더 prefetch를 mTCP에 도입하여 구현하였다. 실혐결과, IX와 최적화된 mTCP가 기존에 1.9배 이상 성능이 저하되던 실험에서 비슷한 성능을 보이는 것과 L7 부하 분산기 구현에서 최적화를 적용한 mTCP가 기존 mTCP에 비하여 최대 20%의 성능 향상을 보임을 확인하였다.