virtual memory - Which (OS X) dtrace probe fires when a page is faulted in from disk? -


I am writing a document about page defect and trying to work with some solid numbers, So I wrote a simple program that reads 12 * 1024 * 1024 bytes of data:

  int main () {FILE * = in fopen ("data.bin", "rb") ; Int i; Integer = 0; For (i = 0; i <1024 * 1024 * 12; i ++) total + = fgetc (in); Printf ("% d \ n", total); }  

So yes, it reads completely and reads the whole file issue is that I need a fire detriment probe of 1536 times during this process (12M / 8k) . Even if I count all FBT: mach_kernel: vm_fault *: probes and all vminfo ::: checks, then I do not have 500 hits, so I know I have not found the correct check.

Does anybody know that I can find a detrace probe when I get a page from Discovery? Update:

The problem is that the issue was that some were intelligent after proceeding to the Stdio functions, I tried the following:

 < Code> int main () {int = open ("data.bin", O_RDONLY | O_NONBLOCK); Int i; Integer = 0; Four buff [128]; For (i = 0; i & lt; 1024 * 1024 * 12; i ++) {read (in, buff, 1); Total + = Buff [0]; } Printf ("% d \ n", total); }  

This version takes a lot of time to run (42 real time, 10 of which was a user and the rest of the system was time-guessing, I'm guessing) But still produces in the fifth form. I hope many mistakes.

For curiosity, the increase in time is not due to loop overhead and casting (four integer) code version which only works. Takes 0.7 seconds.

There is no direct answer, but it seems that you are coordinating disk reads and page faults Are there. They are not necessarily the same in your code, you are reading data from a file in a small user memory chuck, so the I / O system can read the file in buffer / VM cache in any way and it looks fit. is. I can be wrong here, I do not know how Darwin does this.

I think the more reliable test will be mmap (2) in the process memory and then touch each page, that's the place.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -