Version 1 (modified by moo, 14 years ago) (diff)


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 store data into rw cache, and fix the pointers up to ro cache, so all access if read from the ro memory.

The cache can be currupted by accident, e.g., if some pointer isn't handled when copy from cache, some php/extension may write to the cache by this pointer currupting 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 requirement meet:

  • 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.