From owner-freebsd-questions@FreeBSD.ORG Sat Feb 21 19:46:45 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C72C106564A for ; Sat, 21 Feb 2009 19:46:45 +0000 (UTC) (envelope-from junsukshin@gmail.com) Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.30]) by mx1.freebsd.org (Postfix) with ESMTP id 28DED8FC08 for ; Sat, 21 Feb 2009 19:46:45 +0000 (UTC) (envelope-from junsukshin@gmail.com) Received: by yx-out-2324.google.com with SMTP id 31so526805yxl.13 for ; Sat, 21 Feb 2009 11:46:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=FtVXyiPpnttj/TeR4Cfu0rgjuujrYmGcDhht/cj6zpg=; b=ejLGbcTVEz0k+iiXcwwpsIf/qJTF7JfqEZ0sjwWnrHnwQSM6GdZCcKbvB0Sx1xMP/h id63CAd0lkdXxQxBbh48PQ6WEKVSBrw4j+gbtXEhOVTQTeGIE5uLzfI4hrAcHtL8K1Zj B3B9poYrH5mC8eb6mnXleheanBZ4LDr6AcXq0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=Vmgx22ts2s4dpvGLbm/uZ7KecnAdG5BHsPS0yquKf7Bu78Yclupon98ILow6tQArGH 4oq25QGvbuVSYF1PDaAdo3X2k9bCqr3IZkVYMSOg8KaLZVp258rW0z4DWEaHvuKZlz8M HG5H0G7A8uQ01lMdSyq3r01r2ejO/Ni2l7eeU= MIME-Version: 1.0 Received: by 10.231.10.68 with SMTP id o4mr3129011ibo.33.1235245604165; Sat, 21 Feb 2009 11:46:44 -0800 (PST) Date: Sat, 21 Feb 2009 14:46:44 -0500 Message-ID: <7873ac110902211146k6a8ee7d0pd67edc559ed14b15@mail.gmail.com> From: Junsuk Shin To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: read two files simultaneously X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Feb 2009 19:46:45 -0000 Hello, I need to read two files simultaneously, and simply read(2) is interleaved to do this. The problem is the performance varies dramatically depending on the file size. I'm wondering what is the problem in this case. The test application does following: open 2 files - the size of two file is same - since I read only once, bypass cache with O_DIRECT read 16Kbytes of file1, then read 16K of file2, and so on simplified code is like this: fd1 = open(file1, O_RDONLY | O_DIRECT); fd2 = open(file2, O_RDONLY | O_DIRECT); for(...) { /* read 16K of file1 */ while(...) { count = read(fd1,...); .... } /* read 16K of file2 */ while(...) { count = read(fd2,...); .... } } When I tested with two 100M files, it takes 3.17 seconds (about 31MB/s per file, 62MB/s in total) However, if I test with two 700M files, it takes 162 seconds (about 4.5MB/s per file, 9MB/s in total) I'm just guessing inode structure, the physical file location on HDD might be related to this. But, if I read only one file, the size doesn't matter. Reading file (10M, 100M, 700M) gives constantly about 70MB/s, and the weird thing happens when I read 2 files of big size. The seek time might be related to this, but it looks like too huge difference. What is going on this? Thanks. -- Junsuk