On 11/3/2017 7:46 AM, Bishop Bettini wrote:
On Fri, Nov 3, 2017 at 9:51 AM, Thomas Hruska <thru...@cubiclesoft.com>
wrote:

http://nikic.github.io/2014/12/22/PHPs-new-hashtable-implementation.html

Ah. Very clever and cool. That memory layout does indeed pose a problem with random order insertions of string keys. Detachable nodes are more useful to me in C++ for a general-purpose data structure but I can see the benefits of doing this for PHP 7, which takes advantage of the most common array usage patterns (i.e. an array).

After reading that post, I was inspired to implement PackedOrderedHash:

https://github.com/cubiclesoft/cross-platform-cpp

I can definitely see why PHP 7 adopted the structure. My own benchmarks of PackedOrderedHash show significant performance improvements.

You'll note that in PackedOrderedHash I excluded inserting just anywhere - likely for the same reason that PHP doesn't offer such a feature. I still think PHP could natively offer string key-based insertions even though it'll require moving elements of an array around. That's likely to be faster than rebuilding the whole array.

Thanks for the long writeup and Nikic for the blog post.

--
Thomas Hruska
CubicleSoft President

I've got great, time saving software that you will find useful.

http://cubiclesoft.com/

And once you find my software useful:

http://cubiclesoft.com/donate/

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

Reply via email to