Re: How deep is copy on write?
| From: | Larry Garfield | Date: | Thu, 20 Jan 2011 02:17:28 +0000 |
| Subject: | Re: How deep is copy on write? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51334@lists.php.net to get a copy of this message | ||
On Wednesday, January 19, 2011 4:45:14 pm Ben Schmidt wrote:
> > Related: What is the overhead of a ZVal? I'm assuming it's a fixed
> > number of bytes.
>
> It seems not, though a zval has a fixed size. What that size is will
> depend on the compiler and architecture of the system being used, or at
> least on the ABI.
Ah, yes, of course. Oh C...
*snip*
> The zvalue_value union will probably be 8 or 12 bytes, depending on the
> architecture. The whole struct will then probably be between 14 and 24
> bytes, depending on the architecture and structure alignment and so on.
*snip*
> You can figure out what you think the overhead is from that. For a
> string, arguably the whole structure is overhead, since the string is
> stored elsewhere via pointer. Likewise for objects. For a double, the
> payload is 8 bytes, and stored in the zval, so there's less overhead. An
> integer, with a payload of 4 bytes, is somewhere in between.
Hm. OK, so if I'm assuming a 64-bit architecture (most servers these days,
I'd think) and just looking for a rough approximation, it sounds like 20 bytes
per zval/variable is a not unreasonable estimation. At least close enough for
determining the memory overhead of a general algorithm.
Thanks again!
--Larry Garfield