Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Performing read operation on fd after mmap: (3 Items)
   
Performing read operation on fd after mmap  
Hi,

I am trying to find the performance difference between 
1.) using the pointer returned by mmap() of shm_open() retruned fd
2.) shm_open(), call mmap(), ignore the pinter returned and just use the fd

for data read/write operations.

Does the both operation gives same performance results ? wehther the both does only memory operation instead of one 
memory and the other as file operation ?
RE: Performing read operation on fd after mmap  
Using the fd directly will perform a file operation, and not modify the mmap memory buffers.  When the memory buffers 
are unmapped, their contents will overwrite whatever changes you made to the file.  For this reason, you should only 
access the file via the mmap memory buffers OR through the fd, do not mix them.

Your application will know better than the kernel when you are finished with a specific piece of buffer, so you 
application can make better decisions about when to flush the changes to disk.  Other than this, I don't know if there 
is any performance penalty for using mmap versus reading the file directly.  I would suggest though, if you are looking 
for performance, make sure you do NOT use fopen()/fread()/fwrite(), and do your file access in the largest possible 
buffer (32k or 64k read and write sizes offer good performance).

David

-----Original Message-----
From: Balaaji Tirouvengadam [mailto:community-noreply@qnx.com] 
Sent: Thursday, March 07, 2013 1:59 PM
To: general-filesystems
Subject: Performing read operation on fd after mmap

Hi,

I am trying to find the performance difference between 
1.) using the pointer returned by mmap() of shm_open() retruned fd
2.) shm_open(), call mmap(), ignore the pinter returned and just use the fd

for data read/write operations.

Does the both operation gives same performance results ? wehther the both does only memory operation instead of one 
memory and the other as file operation ?




_______________________________________________

General
http://community.qnx.com/sf/go/post99738
To cancel your subscription to this discussion, please e-mail general-filesystems-unsubscribe@community.qnx.com
Re: RE: Performing read operation on fd after mmap  
Hi David,

thanks for the input, so do you mean after mmap on a shm file and using the file fd directly or using the pointer 
returned by mmap doesnot give any performance benefit.

Then why do we need to have mmap ? can the shm file fd be directly used for transfer without using mmap ?