Link to home
Start Free TrialLog in
Avatar of zizi21
zizi21

asked on

how does mmap make seeks (Page_Size)

Hi there,

This is what I did to get the Page_Size when using mmaps..
(int)sysconf(_SC_PAGESIZE);


I am trying to counts the seeks that is made..LEts say the page is 4096 bytes..If the size of the file is 100000 bytes. The number of seeks that is done is 100000 bytes/ 4096 bytes which gives you a number . Can i assume that number is the number of seeks ?
Avatar of Superdave
Superdave
Flag of United States of America image

No.
Depends on the operating system and file system, so you can't assume anything, but the system tries to keep files contiguous and do some amount of read-ahead, so it shouldn't require very many seeks.
The filesystem block size could also be smaller than the virtual memory page size, so in theory a really fragmented file could do even more seeks than you calculated, because it might take (for example) four seeks of 1K blocks to fill a VM page.  That would be unlikely though.  Also there could be some seeks of filesystem metadata (lists of which blocks are allocated to that file).
 
Avatar of zizi21
zizi21

ASKER

How do i calculate the fseeks then ? Is there a way to calculate the fseek ?
What do you mean by "fseeks"?  Using the fseek call instead of mmap? or how often mmap page-faults?
Avatar of zizi21

ASKER

How often does the page does not exist and you need to go to disk to get it ? Thanks a lot.
ASKER CERTIFIED SOLUTION
Avatar of Superdave
Superdave
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zizi21

ASKER

Thanks a lot.