Tuesday, March 8, 2016

ZeroCopy sshttp

This time we trick sshttp into utilizing the
splice(2) syscall to achieve zero-copy of the
network data thats muxed across the sockets.

If you want to give it a try, pull sshttp git 
and checkout the splice branch. Everything else
goes the same.

Using splice() instead of read()/write() inside
the core loop has a performance benefit. In the ideal
case (SPLICE_F_MOVE is honored by kernel), instead
of copying megabytes of data, the PTE's inside the kernel
are just set up to point to the internal pipe buffers.

sshttp may still run at 100% CPU (which is perfectly OK
when downloading huge files) but has more throughput at the
same time. Below is a screenshot of a parallel download
of a 5MB file (per 30 http clients) and a strace showing
the splicing thats happening inside, which is basically
a poll/splice loop.

No comments: