On Fri, 2004-11-12 at 13:22 -0800, Ben Tilly wrote:
> On Fri, 12 Nov 2004 10:05:27 -0500, Uri Guttman <[EMAIL PROTECTED]> wrote:
> > >>>>> "GS" == Gyepi SAM <[EMAIL PROTECTED]> writes:
> [...]
> > this talk about mmap makes little sense to me. it may save some i/o and
> > even some buffering but you still need the ram and mmap still causes
> > disk accesses.

Just to throw in my own two cents before I critique the reply: "some
disk buffering" can mean  a factor of 10-1000 performance improvement in
real world applications. This is my personal experience with real-world
programs. Of course, if all you want is linear access to a file once,
then mmap doesn't help. But, if you want random access to a file,
nothing beats mmap because people spend their LIVES tuning paging
strategies, and such code has knowlege of the hardware that you cannot
otherwise take advantage of in a general purpose IO layer.

> Um, mmap does not (well should not - Windows may vary) use any
> RAM

You are confusing two issues. "using RAM" is not the same as "allocating
process address space". Allocating process address space is, of course,
required for mmap (same way you allocate address space when you load a
shared library, which is also mmap-based under Unix and Unix-like
systems). All systems have to limit address space at some point. Linux
does this at 3GB up to 2.6.x where it becomes more configurable and can
be as large as 3.5, I think.

To be clear, though, if you had 10MB of RAM, you could still mmap a 3GB
file, assuming you allowed for over-committed allocation in the kernel
(assuming Linux... filthy habit, I know).

> mmap should not cause any more or less disk accesses than
> reading from the file in the same pattern should have.  It just lets
> you do things like use Perl's RE engine directly on the file
> contents.

Actually, no it doesn't as far as I know (unless the copy-on-write code
got MUCH better recently).

Like I said, you probably won't get the win out of mmap in Perl that you
would expect. In Parrot you would, but that's another story.


_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to