Skip to contentSkip to conversation

TCP Zero Copy for mmapped files

DISCUSSION A.D.F. 3 participants 4 messages Jan 3, 2003 – Jan 4, 2003

lore
Share & tools
lore

A.D.F.

author
#0 lore raw

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 ?

Signature · 4 lines
Nick Name:      A.D.F.
E-Mail:         [email protected]
E-Mail-Font:    Courier New (plain text, no html)
--
#1 lore raw
Quoted 11 lines · 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...

Signature · 4 lines
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))
#2 lore raw
Quoted 2 lines · J.A. Magallon

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

author
#3 lore raw
In reply to J.A. Magallon
Quoted 8 lines · J.A. Magallon
Quoted 6 lines · 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.

Quoted 7 lines
Quoted 5 lines

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.

Quoted 1 line

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

Certainly yes (after required bug fixes :-)

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