Re: mmap to read an entire file
- From: James Antill <james-netnews@xxxxxxx>
- Date: Thu, 09 Mar 2006 12:42:35 -0500
On Fri, 03 Mar 2006 15:38:30 -0500, Henry Townsend wrote:
Thomas Maier-Komor wrote:
You might be able to even
improve performance by using posix_madvise and giving a hint to the
memory subsystem how you are going to access the file.
Thanks, good idea. Looks like POSIX_MADV_SEQUENTIAL is just the ticket.
And according to the Solaris man page this is how both cat(1) and cp(1)
work, which clearly indicates the system architects thought
mmap+sequential is faster than read() in a loop.
Note that you can use posix_fadvise() with read(), and GNU utils
still use read() with an 8k buffer for cat/cp like operations (because
it's faster -- even faster than sendfile() last I heard).
Also remember that you are open to DOS attacks if anyone can truncate
files you are mmap()'ing.
--
James Antill -- james@xxxxxxx
http://www.and.org/and-httpd
.
- References:
- mmap to read an entire file
- From: Henry Townsend
- Re: mmap to read an entire file
- From: Thomas Maier-Komor
- Re: mmap to read an entire file
- From: Henry Townsend
- mmap to read an entire file
- Prev by Date: Automate ftp from BSD to MVS system problem
- Next by Date: Re: Malloc & sbrk
- Previous by thread: Re: mmap to read an entire file
- Next by thread: Re: mmap to read an entire file
- Index(es):
Relevant Pages
|