Ondrej Ivanič wrote: > Al Baker wrote: > >> An embedded opcode cache I think is also essential and the surrounding >> $_MEMORY sounds perfect to me. All Java guys (yeah I know PHP != Java) >> say PHP isn't ready for the enterprise because it can't share >> information between processes other than arcane sessions. Having PHP >> become even faster also buys us not only play in the enterprise but >> scalability since it takes less to do what we do today. > > > At now, data sharing is possible in two ways: > > 1) Shared Memory Functions > 2) apache_note() function > > Second method is simple and you need only some king of data > serialization/deserialization, but is available only with Apache web > server. > > First method is good for read-only data. Write to shmem segment is some > times difficult (shmem segment have fixed size). Data > serialization/deserialization is also required. > > It will be nice to have a simple method...
pecl/apc has apc_store/apc_fetch: http://livedocs.phpdoc.info/index.php?l=en&q=function.apc-store The problem with having a real shared memory based global is that on every single access you need to lock. And if you make references to it you have to track the fact that the allocator for that one piece is completely different. It would be a pretty drastic change that would complicate a lot of things. It makes more sense to me to take an approach like apc_fetch() does where the value is copied into your address space for the duration of the request. If you need to change it, you apc_store() a new value. The lock only happens once on the read and once on the write. Of course, you can't really implement a counter this way, for example, since there is no lock that spans the read and the write. That could be gotten around with some specialty functions like apc_increment and apc_append perhaps. The target for apc_store/fetch really was read-heavy things. It wasn't intended to be a heavy-duty read-write IPC mechanism between processes. -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php