Sunday, November 29, 2009

Very quick look at zero-copy bpf in FreeBSD 8.0

So it appears as if they have finally integrated Zero-Copy bpf support into FreeBSD 8.0. I have not had any time to do any real performance tests but I thought I would just throw a few little notes up about it. Zero-Copy BPF is not enabled by default, to enable it you must do the following.

sysctl net.bpf.zerocopy_enable=1

Once you set this option you can fire up any libpcap based application and it should use the zero-copy functionality. It appears as if there was a patch to netstat that wasn't integrated for the 8.0 release but can be found here. A few little fixes namely converting the %lu printfs to %llu instead will give you a netstat that will produce stats about zero-copy operations.

without zero-copy sysctl option set to zero...
./netstat -s -B
tcpdump: pid 3402 on ed0:
376 packets received
376 packets matched receive filter
0 packets dropped
0 current hold buffer size
1146 current store buffer size
0 packets written
0 packets matched write filter
0 packet writes failed
0 zero copy operations

with zero-copy sysctl option set to 1

FreeBSD-32-bit# ./netstat -s -B
tcpdump: pid 3424 on ed0:
745 packets received
745 packets matched receive filter
0 packets dropped
0 current hold buffer size
830 current store buffer size
0 packets written
0 packets matched write filter
0 packet writes failed
1490 zero copy operations

0 comments: