On 3/14/13 12:28 PM, Bob Weinand wrote:
Am 14.3.2013 um 18:14 schrieb Rasmus Lerdorf <ras...@lerdorf.com>:

On 03/14/2013 09:13 AM, Bob Weinand wrote:
And there is no possibility to store the zval as raw binary data like in memory 
(deep copy?)
So that you only have to copy from ram? And replace the pointers to the place 
in the string?
This must be possible I think. And should be faster.

shmop has to be opened on every request and only supports strings.
APC, memcache,... can only save under serialized form which is slow.

APC doesn't serialize most types. Only actual objects need to be
serialized because it is the easiest way to fully save and restore
objects. eg. calling their __sleep()/__wakeup() magic methods, etc.
Arrays are not serialized.

-Rasmus

Thanks, ..., okay, didn't know that.

But even now I am in favor of a new keyword as it will be easier to have a 
reference to the
shared memory (written in and reread from memory when modified) than every time 
refetching it
when the shared memory block may have changed in an other program (what could 
really reduce
race-conditions implicitly as as a developer you may forget to refetch the 
variable from shared
memory). Yes, refetching always is already possible with an userland 
getter/setter, but I don't think
it's best practice to do so in PHP...

Bob Weinand

Sharing active memory between processes goes against the "shared nothing" design of PHP. The lack of the feature you're describing is itself a feature. :-)

If you had real shared memory, then you're now writing a multi-threaded app. Even if you aren't using threads per se it's the same level of potential for spooky action at a distance. If your problem space really requires that (and there certainly are those that do), Java or NodeJs will suit you better because those are built specifically for a persistent-server model, rather than PHP's shared-nothing design. However, in practice most PHP/web applications don't need that, because HTTP is a stateless request/response system. Shared-nothing more closely models what the actual environment is doing, and can still be very performant as long as you don't do anything naive.

If you're doing something stateful like Web Sockets, then you can run PHP as a cli application that is its own persistent server rather than as an Apache add-on. For that, look at Ratchet: http://socketo.me/

--Larry Garfield


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to