Usage MMAP??

Usage MMAP??

Post by YoungWha » Tue, 20 May 2003 21:16:43



Recently, I found out to use mmap for handling file easily.
It just use address instead of management of buffer. Right?

1. But, how about the speed?
Is it faster than normal using file descripter?

2. Is it using temporary file? Is it relative with swp file in Linux?

 
 
 

Usage MMAP??

Post by Arnold Hendrik » Tue, 20 May 2003 22:23:30



> Recently, I found out to use mmap for handling file easily.
> It just use address instead of management of buffer. Right?
> 1. But, how about the speed?
> Is it faster than normal using file descripter?

That will depend a lot on how you use the file descriptor. Mmap can sometimes
eliminate extra copies that a read() will do, especially if you're doing
small or non-aligned read, as it allows you to directly read out of the
buffercache. But there will also be some overhead associated with paging in
memory, which might be more than well-optimized read() calls.

In general, mmap is a lot more convenient than using read when you'll be
doing a lot of random access, as you don't have to do any buffer management
yourself. On the other hand, handling I/O errors with mmaped memory is much
harder.

Quote:> 2. Is it using temporary file? Is it relative with swp file in Linux?

An anonymous mapping will use the swap file. A mapping of an existing file
will use that file, at least if it's local. I'm not sure where paged-out
data goes when you're mmap-ing a file over a network.

--

B-Lex Information Technologies, http://www.b-lex.com/

 
 
 

1. mmap usage and tmpfs caching

I have a program that does random reads on a large file (300M) by
using mmap.  If I place the big file in /tmp, will the tmpfs caching
defeat the advantage or complement it?

--
 -------------------------------------------------------------
| Keith R. Michaels   Archival Evangelist                     |
| (425)865-6415       Boeing Archival Service (ufs.boeing.com)|
| Enterprise Servers, Technical Services, SSG.                |
 -------------------------------------------------------------

2. MPlayer status display

3. usage and example of mmap,msync,sbrk....

4. How to Re the the article using tin??

5. mmap with /dev/zero usage ???

6. Can I recover a corrupted partiotion??

7. MMAP with /dev/zero usage ???

8. Can not log in while dail-up connection is active ??? Please Help

9. proper usage of mmap()

10. mmap usage ?

11. proper usage of mmap()

12. mmap: using it to mmap Queue Data structure

13. ALSA + mmap or OSS emulation + mmap producing stutering sound