Readonly Protection

Readonly Protection is a mechanism used in XCache to make it more stable. It is implemented by mmap'ing twice on same memory, 1 for read/write(rw) and the other for readonly(ro). XCache stores data into rw cache, and fix the pointers up to ro cache, so all access is read from the ro memory.

The cache can be corrupted by accident, e.g., if some pointer isn't handled when copying from cache, some php/extension may write to the cache with this pointer, corrupting the cache. The cache with readonly permission won't allow this happen.

Does it ever help? Yes, it helped when I was developing XCache, figuring out bugs between XCache and php core.

You can grant performance by shadow-copying some data, i.e.: some of the data can be accessed by the php executor in cache directly, without copying them to emalloc'ed memory, but only when these requirements are met:

  • the executor read the data, but never write it
  • the executor never efree() the pointer already, or you can trick it so.

This is true, however, with readonly protection disabled only.

Last modified 11 years ago Last modified on 2006-11-20T03:41:44Z