lkml.org 
[lkml]   [2003]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: sparse file performance (was Re: Is there a "make hole" (truncate in middle) syscall?)
On Fri, Dec 05, 2003 at 01:12:21PM -0800, Linus Torvalds wrote:
> On Fri, 5 Dec 2003, Andy Isaacson wrote:
> > I got curious enough to run some tests, and was suprised at the results.
> > My machine (Athlon XP 2400+, 2030 MHz, 512 MB, KT400, 2.4.22) can read
> > out of buffer cache at 234 MB/s, and off of its IDE disk at 40 MB/s.
> > I'd assumed that read(2)ing a holey file would go faster than reading
> > out of buffer cache; in theory you could do it completely in L1 cache
> > (with a 4KB buffer, it's just a ton of syscalls, some page table
> > manipulation, and a bunch of memcpy() out of a single zero page). But
> > it turns out that reading a hole is *slower* than reading data from
> > buffer cache, just 195 MB/s.
>
> That's because we actually instantiate the page cache pages even for
> holes. We have to, or we'd have to special-case them no end (and quite
> frankly, "hole read performance" is not something worth special casing,
> since it just isn't done under any real load).
>
> So reading a hole implies creating the page cache entry and _clearing_ it.
> For each page. So while you may read from the L1, you also have to do
> writeback of the _previous_ pages from the L1 into the L2 and eventually
> out to memory.
>
> (And eventually the VM also has to get rid of the pages etc, of course).

Thanks for the explanation, Linus.

I modified my benchmark to use mmap(2) instead of read(2) and the
results are broadly comparable. With a 10MB window, I get 331 MB/s
reading out of buffer cache and 185 MB/s reading a hole. Reading a file
too large to cache is about the same (disk-limited) speed, 43 MB/s.

-andy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:59    [W:0.044 / U:4.724 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site