Anonymous Page Cache: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 5: Line 5:


== Implementation ==
== Implementation ==
APC maintains a map to anonymous pages, which is a subset of the virtual memory map, by intercepting calls to the mmap() family. When triggered, it temporarily marks those pages read-only before swapping out to prevent the memory from altered. When the pages are written while being swapped out, the SIGSEGV handler is invoked to cancel the job and reset the memory block which is being swapped out.
APC maintains a map to anonymous pages, which is a subset of the virtual memory map, by intercepting calls to the mmap() family. When triggered, it temporarily marks those pages read-only before swapping out to prevent the memory from altered. When the pages in question are written by other threads, the SIGSEGV handler is invoked to cancel the job and reset the memory block which is being swapped out.


== References ==
== References ==
* https://bugzilla.mozilla.org/show_bug.cgi?id=899493
* https://bugzilla.mozilla.org/show_bug.cgi?id=899493
* https://groups.google.com/forum/#!topic/mozilla.dev.b2g/QNLuHylCOlU
* https://groups.google.com/forum/#!topic/mozilla.dev.b2g/QNLuHylCOlU

Revision as of 08:57, 15 August 2013

Anonymous Page Cache gives backstores to anonymous pages. For those dynamically generated but rarely used/modified data structures, it tries to save them on disk and load them on demand. The idea is similar to a swap file except:

  • It's in userland and requires no special privilege.
  • The timing and scope to save/swap out is determined by programmer, rather than OS.

Implementation

APC maintains a map to anonymous pages, which is a subset of the virtual memory map, by intercepting calls to the mmap() family. When triggered, it temporarily marks those pages read-only before swapping out to prevent the memory from altered. When the pages in question are written by other threads, the SIGSEGV handler is invoked to cancel the job and reset the memory block which is being swapped out.

References