binary serializer/unserializer and session.serialize_handler

php.internals

Bernd Römer

22 years ago
hi... i implemented and shortly benchmarked a binary serializer (which means serializing and unserializing php-variables into a binary representation). At the moment it is written as an extension, but perhaps it is interesting to let it become a standard-extension or part of ext/standard (var.c) and ext/session (to avoid registering the serialize_handler at runtime). Here is the url to the extension: http://fum.no-ip.com/php/fbinary/ There are some additional informations about it and also the benchmarks. Hopefully it is interesting for anybody... Bernd Roemer

Marcus Börger

22 years ago
Hello Bernd, just commit it to pecl after applying for pecl. If it turns out to be helpful the RM might want to symlink it as a default extension into next release. regards marcus Sunday, July 18, 2004, 6:16:42 PM, you wrote:
> hi...
> i implemented and shortly benchmarked a binary serializer (which means > serializing and unserializing php-variables into a binary > representation). At the moment it is written as an extension, but > perhaps it is interesting to let it become a standard-extension or part > of ext/standard (var.c) and ext/session (to avoid registering the > serialize_handler at runtime). Here is the url to the extension:
> http://fum.no-ip.com/php/fbinary/
> There are some additional informations about it and also the benchmarks. > Hopefully it is interesting for anybody...
> Bernd Roemer
-- Best regards, Marcus mailto:helly@php.net

Andi Gutmans

22 years ago
Hi Bernd, It seems you are using zend_dynamic_array() which is something I wrote a long time ago and never got to completely testing it. Seems to me that there's a problem there with the erealloc() call. It could relocate the data storage and, therefore, all of your pointers to that storage might end up being wrong. Can you explain exactly what kind of data structure you require? I am planning on working on a static allocator (not stack) soon and I'm just wondering if that would suit your needs or not. Thanks, Andi At 06:16 PM 7/18/2004 +0200, Bernd Römer wrote:

Bernd Römer

22 years ago
hi andi..
> It seems you are using zend_dynamic_array() which is something I wrote a > long time ago and never got to completely testing it. Seems to me that > there's a problem there with the erealloc() call. It could relocate the > data storage and, therefore, all of your pointers to that storage might > end up being wrong.
I haven't seen the problem yet... it worked fine all the time... perhaps by accident :) I will take a look at it after dinner :)
> Can you explain exactly what kind of data structure you require? I am > planning on working on a static allocator (not stack) soon and I'm just > wondering if that would suit your needs or not.
i need a simple dynamic array... with no additional features... normally i use my own dynamic-array functions.. but i wanted that extension as small as possible.. so i used zend_dynamic_array... it looked almost like my own "lib". (but) I miss some functions like destructor and registering a destructor-function for the entries (which i wouldn't use in this case)... and some functions to interact and manage the dynamic arrays (also not used in my case) like merging, sorting, traversing, comparing and so on... thanks... Bernd Roemer

Andi Gutmans

22 years ago
At 07:46 PM 7/18/2004 +0200, Bernd Römer wrote:
>hi andi.. > >>It seems you are using zend_dynamic_array() which is something I wrote a >>long time ago and never got to completely testing it. Seems to me that >>there's a problem there with the erealloc() call. It could relocate the >>data storage and, therefore, all of your pointers to that storage might >>end up being wrong. > >I haven't seen the problem yet... it worked fine all the time... perhaps >by accident :) I will take a look at it after dinner :) > >>Can you explain exactly what kind of data structure you require? I am >>planning on working on a static allocator (not stack) soon and I'm just >>wondering if that would suit your needs or not. > >i need a simple dynamic array... with no additional features... normally i >use my own dynamic-array functions.. but i wanted that extension as small >as possible.. so i used zend_dynamic_array... it looked almost like my own >"lib". (but) I miss some functions like destructor and registering a >destructor-function for the entries (which i wouldn't use in this case)... >and some functions to interact and manage the dynamic arrays (also not >used in my case) like merging, sorting, traversing, comparing and so on...
Well the idea here was to keep it as fast and as simple as possible, that's why it doesn't have all those features you can find in zend_hash. You probably didn't see the problem because either you didn't reach erealloc() or it managed to do reallocation without moving the memory. As as far as my knowledge goes (we might need to do some grepping) no one is using zend_dynamic_array, I don't mind if you come with an alternate suggestion. But it has to be very small and high-performance :) Thanks, Andi