• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

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 ?
0
zizi21
Asked:
zizi21
  • 3
  • 3
1 Solution
 
SuperdaveCommented:
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).
 
0
 
zizi21Author Commented:
How do i calculate the fseeks then ? Is there a way to calculate the fseek ?
0
 
SuperdaveCommented:
What do you mean by "fseeks"?  Using the fseek call instead of mmap? or how often mmap page-faults?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
zizi21Author Commented:
How often does the page does not exist and you need to go to disk to get it ? Thanks a lot.
0
 
SuperdaveCommented:
I don't know of a way for the program to be given that information, but I'm not positive about that.  One way might be to make an experimental version that looks at the clock time before and after accessing the memory to see if there's a delay.

There might be a way of figuring this out using system tools, such as running "top" or poking around in the /proc filesystem.  I don't know how but if I have time this weekend I'll look into it because that kind of thing interests me too.

But note that the number of seeks isn't a property of your program, it's a property of the whole system at the time.  If you have a lot of free memory when you're executing the program, the pages will stay in memory once they're paged in.  If memory is tight, it will drop the mmaped pages to reclaim memory and then they'll be read in again when you access them.
0
 
zizi21Author Commented:
Thanks a lot.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now