[ccache] [patch] Massive performance degradation with direct mode due to bypassing filesystem cache with mmap (Mac/PPC)

Mike Frysinger vapier.adi at gmail.com
Wed Aug 25 14:29:41 MDT 2010


On Wed, Aug 25, 2010 at 16:24, Joel Rosdahl wrote:
> On 2010-08-23 13:35, Christian Lohmaier wrote:
>> [...] Using mmap [on Mac/PPC] to load all the include files bypasses
>> the filesystem cache [...]
>
> Ouch. That surprises me. Thanks for telling!
>
> The reason I chose mmap() instead of read() was mainly that the C
> "parser" (that basically knows about C/C++ comments and string literals)
> was easier to write under the assumption that it has access to the whole
> file as a string and I figured that it would be better to mmap() than to
> read the whole file into memory (or at least not worse). I didn't
> perform any benchmarks to back up that choice, though. Now I've done
> some tests, and it seems that on my 64-bit Linux system, mmap() is
> slightly faster for (very) large files, but for smaller files, I can't
> measure any real difference consistently. I assume that reading the
> whole file into memory instead of using mmap() isn't considerably slower
> on other systems too, so I'll make ccache do that.

perhaps abstract the file i/o away so people can switch between mmap
and stdio at build time.  as you say, i imagine mmap makes coding
easier to work with, which means the resulting code is simpler.  but
for OS's where mmap blows because their filesystem stack blows,
default to stdio.
-mike


More information about the ccache mailing list