A page fault occurs when a program requests an address on a page that is not in the current set of memory resident pages. What happens when a page fault occurs is that the thread that experienced the page fault is put into a Wait state while the operating system finds the specific page on disk and restores it to physical memory. It is important to distinguish between minor/soft and major/hard page fault;
- Minor - occurs when the page is resident at an alternate location in the memory. It may happen becasue the page is no longer part of the working set but not yet moved to disk or it was resident in memory as result of prefetch operation
- Major - occurs when the page is not located in physical memory or in the memory mapped files created by the process.
Why bother?
- Poor Latency - You may ignore minor faults however, major faults can be detrimental to your application performance in the presence of insufficient physical memory and excessive hard fault and as such needs to be fixed immediately.
- Poor CPU utilization - as a direct result of thrashing
What next?
- Increase physical memory - this might be the easy one to start with, although, if you already own a large real estate chances you need to go back to design room as this might just delay the problem
- Reduce overall memory usage - think right data type, de-duplication, effective (de)serialization
- Improve memory locality - think about your choice of algorithm based on data access pattern to reduce page fault
No comments:
Post a Comment