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 ?
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 ?
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot.
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).