Re: sparse file performance (was Re: Is there a "make hole" (truncate in middle) syscall?)

From: Andy Isaacson (adi_at_hexapodia.org)
Date: 12/08/03

  • Next message: William Lee Irwin III: "Re: 2.6.0-test9 - poor swap performance on low end machines"
    Date:	Mon, 8 Dec 2003 14:43:32 -0600
    To: Linus Torvalds <torvalds@osdl.org>
    
    

    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/


  • Next message: William Lee Irwin III: "Re: 2.6.0-test9 - poor swap performance on low end machines"

    Relevant Pages

    • Re: Request: I/O request recording
      ... > file, ready for optimized reading. ... Linux caches disk data on a per-file basis. ... we don't go looking for the same disk blocks in the cache of /dev/hda1. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: clearing filesystem cache for I/O benchmarks
      ... I'm reading via gmane and my newsreader doesn't make it ... clears kernel page cache and not controller/disk cache. ... based on your advice, I'll instead just create a 2x "dummy" file, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: clearing filesystem cache for I/O benchmarks
      ... > suggested this, but going on the title, have you considered running ... think reading the same data twice could lead to unwanted cache hits. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: USB2.0 throughput
      ... Both my setups are reading a file from the USB HDD device. ... reading speed cannot be speed-up by a cache. ... It seems that the wince system is not fully loading the USB ...
      (microsoft.public.windowsce.embedded)
    • Re: Easy - if you know how.
      ... actually writing to disks. ... No read cache, slow write. ... Could I make my system faster by updating all files to 1 second ... This means write access to the hard drive when reading files. ...
      (alt.os.linux.suse)