2003-01-03 22:28:21

by A.D.F.

[permalink] [raw]
Subject: TCP Zero Copy for mmapped files

FreeBSD 5.0 should already have a zero copy for mmapped files and
IMHO it would be worth to have it in Linux 2.6 too.

It would also be very nice to be able to enable zero copy for mmapped files
by a config option.

Many applications use mapped memory to serve lots of small and
medium sized files (4 - 1024 KB) or even a few big files
(think at web servers, i.e. Apache 2, etc.); this is done to better
serve multiple / parallel downloads being done on the same files.

Using or not using mmap() is a userland / application choice that depends
on lots of factors / strategies that are outside kernel scope.

Besides this there seems to be some work in progress to speed up
mmap() calls, thus why not doing all the work right ?

--
Nick Name: A.D.F.
E-Mail: [email protected]
E-Mail-Font: Courier New (plain text, no html)
--


2003-01-04 00:33:25

by J.A. Magallon

[permalink] [raw]
Subject: Re: TCP Zero Copy for mmapped files


On 2003.01.04 A.D.F. wrote:
> FreeBSD 5.0 should already have a zero copy for mmapped files and
> IMHO it would be worth to have it in Linux 2.6 too.
>
> It would also be very nice to be able to enable zero copy for mmapped files
> by a config option.
>
> Many applications use mapped memory to serve lots of small and
> medium sized files (4 - 1024 KB) or even a few big files
> (think at web servers, i.e. Apache 2, etc.); this is done to better
> serve multiple / parallel downloads being done on the same files.
>

Apache2 uses mmap() to open files ??
So then there is a reason to include it in my patchset...

--
J.A. Magallon <[email protected]> \ Software is like sex:
werewolf.able.es \ It's better when it's free
Mandrake Linux release 9.1 (Cooker) for i586
Linux 2.4.21-pre2-jam2 (gcc 3.2.1 (Mandrake Linux 9.1 3.2.1-2mdk))

2003-01-04 01:44:49

by dean gaudet

[permalink] [raw]
Subject: Re: TCP Zero Copy for mmapped files

On Sat, 4 Jan 2003, J.A. Magallon wrote:

> Apache2 uses mmap() to open files ??
> So then there is a reason to include it in my patchset...

apache2.x uses sendfile. see the apr library (where you can find sendfile
code for linux, freebsd, hpux, aix, mvs, solaris, and windoze...). it
might also use mmap in some situations, most likely inherited from 1.x
(which uses only mmap).

-dean

2003-01-04 12:04:07

by A.D.F.

[permalink] [raw]
Subject: Re: TCP Zero Copy for mmapped files

"J.A. Magallon" wrote:
>
> On 2003.01.04 A.D.F. wrote:
> > FreeBSD 5.0 should already have a zero copy for mmapped files and
> > IMHO it would be worth to have it in Linux 2.6 too.
> >
> > It would also be very nice to be able to enable zero copy for mmapped files
> > by a config option.
> >
> > Many applications use mapped memory to serve lots of small and
> > medium sized files (4 - 1024 KB) or even a few big files
> > (think at web servers, i.e. Apache 2, etc.); this is done to better
> > serve multiple / parallel downloads being done on the same files.
> >
>
> Apache2 uses mmap() to open files ??

No, you cannot use mmap() to open files ... :-),
at most mmap() helps caching static file contents in order
to avoid too many open() / close() calls (which maybe slow).

Apache 2 seems to use sendfile (in blocking mode) by default,
it uses mmap() only if you enable it (see also mod_file_cache).

Other web servers (i.e. Zeus) use widely mmap() for specific
file sizes, when it is usually a strong win (specially under *BSD and
Solaris)
in big / busy servers with lots of RAM.

> So then there is a reason to include it in my patchset...

Certainly yes (after required bug fixes :-)

--
Nick Name: A.D.F.
E-Mail: [email protected]
E-Mail-Font: Courier New (plain text, no html)
--