From owner-freebsd-fs@FreeBSD.ORG Wed Jan 11 00:01:47 2012 Return-Path: Delivered-To: fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B24D5106566B for ; Wed, 11 Jan 2012 00:01:47 +0000 (UTC) (envelope-from bfriesen@simple.dallas.tx.us) Received: from blade.simplesystems.org (blade.simplesystems.org [65.66.246.74]) by mx1.freebsd.org (Postfix) with ESMTP id 64A5F8FC0A for ; Wed, 11 Jan 2012 00:01:47 +0000 (UTC) Received: from freddy.simplesystems.org (freddy.simplesystems.org [65.66.246.65]) by blade.simplesystems.org (8.14.4+Sun/8.14.4) with ESMTP id q0ANn1gO022128; Tue, 10 Jan 2012 17:49:01 -0600 (CST) Date: Tue, 10 Jan 2012 17:49:01 -0600 (CST) From: Bob Friesenhahn X-X-Sender: bfriesen@freddy.simplesystems.org To: "Mikhail T." In-Reply-To: <4F0CBB79.7010704@aldan.algebra.com> Message-ID: References: <4F0CBB79.7010704@aldan.algebra.com> User-Agent: Alpine 2.01 (GSO 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.2 (blade.simplesystems.org [65.66.246.90]); Tue, 10 Jan 2012 17:49:01 -0600 (CST) Cc: fs@freebsd.org Subject: Re: How to best send files over network? X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 00:01:47 -0000 On Tue, 10 Jan 2012, Mikhail T. wrote: > 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? Don't use mmap on zfs since doing so wastes memory (zfs ARC is not coherent with mmap page cache). Instead do normal file I/O (e.g. write, fwrite) using the filesystem blocksize (e.g. 128K) or a small multiple thereof. Of course if you are doing this over the network then you will need a program on the receiving end to write the data, and a program on the sending end to send it. It is useful to cache several blocks on the receiving end and use a thread to receive data from the network in case zfs temporarily stalls during write (which it periodically does). > 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? Use it to obtain the filesystem block size. > Thank you very much. Yours, Good to hear from you! Bob -- Bob Friesenhahn bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer, http://www.GraphicsMagick.org/