How to best send files over network?

Mikhail T. mi+thun at aldan.algebra.com
Tue Jan 10 22:56:58 UTC 2012


Hello!

I'm trying to implement a BSD-tuned sending of files. Most of the files are 
fairly large. I thought, sendfile(2) is the way to go, but, it seems, there are 
severe performance problems at the moment for the files located on a ZFS.

mmap-ing the files and then write-ing them is claimed to be a lot faster. Could 
somebody comment on this? Should one always mmap/write, or are there situations, 
when sendfile is advantageous?

If, indeed, sendfile is best for UFS, but mmap/write is better over ZFS, what is 
the best way to determine the underlying FS for each file? statfs(2) is supposed 
to answer that question -- what should I look for in the struct statfs, that it 
will return? Do I check, if f_fsid contains a magic number for ZFS, or look for 
a magic string in f_fstypename? Could someone provide an example?

Thank you very much. Yours,

    -mi



More information about the freebsd-fs mailing list