RE: [PHP-DEV] Performance of buffer based functionality (JSON, AES, serialize())
| From: | Jonathan Bond-Caron | Date: | Sun, 28 Nov 2010 16:15:16 +0000 |
| Subject: | RE: [PHP-DEV] Performance of buffer based functionality (JSON, AES, serialize()) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-50666@lists.php.net to get a copy of this message | ||
On Thu Nov 25 12:47 PM, Andi Gutmans wrote:
>
> I know there have been some high-end apps that have benefited from
> some custom serializers, etc... (typically platform dependent).
> I wonder if people here think improvements in these areas would move
> the needle for the majority of mainstream apps or not.
>
Like people have mentioned, improving (un)serialize speed would be a huge
benefit, especially for caching data sets or large objects.
From experience, it would seem valuable to have:
1) serialize_text($var)
The existing serialize() minus the NULL bytes on private properties. It has
been a source problems for developers serializing an object with private
properties and storing it in a database (the string may get cutoff).
I'm not sure why there's a NULL byte in 'zend_mangle_property_name', instead
the char "_" could be used to mark a private property in the serialized
text.
The unserialize could be BC compatible accepting both NULL and "_" around a
private property.
2) serialize_binary($var)
An efficient and compact serialization using techniques from igbinary.
A potential problem with igbinary I've noticed is it packs a double as a 64
bit integer.
That could be a problem if you serialize on a platform that has an IEEE 754
binary representation and unserialize on a non-IEEE platform but I don't
know if php compiles on architectures that are non-IEEE.
It could also be interesting to pack integers as varints:
http://code.google.com/apis/protocolbuffers/docs/encoding.html#varints
http://protobuf-c.googlecode.com/svn/trunk/src/google/protobuf-c/protobuf-c.
c
That's most likely slower though then what igbinary does with integers