# zend_fast_hash

- Thread: https://externals.io/message/1853
- Original archive: https://news-web.php.net/php.internals/1853
- Started by Sterling Hughes on 2003-05-21T13:33:39+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #1853 — Sterling Hughes — 2003-05-21T13:33:39+00:00

URL: https://externals.io/message/1853#1853

Hi,

I've implemented a very lightweight, efficient hash table for zend
engine 2.  This is a table that's appropriate for usage in many of the
areas where then Zend hash table implementation is unnecessarily complex
(which is pretty much everywhere except for PHP arrays themselves.)  

I've attached the implementation, and a patch which integrates the new
hashtable implementation with Zend, including a "case-study," where I've
converted over EG(included_files) to use the new hashtable
implementation.  Right now the hash table code is very simple, as its
just there for initial perusal, it can of course be improved upon.

So, when can I integrate it? ;-)

-Sterling

-- 
"A business that makes nothing but money is a poor kind of business." 
    - Henry Ford

---

## #1858 — Zeev Suraski — 2003-05-21T15:49:47+00:00

URL: https://externals.io/message/1853#1858 · In reply to: #1853

Can you explain how it is simpler? :)  Writing a lightweight hash has been 
on our mind for quite some time, but the reason it never happened is that 
it appears that most of the places that use hashes actually do take 
advantage of the non-bare-bones features.  The biggest difference I can 
spot is that there's no linked list that links all of the elements.  But if 
we end up adding apply, and clean (which are actually used a lot outside 
the scope of symbol tables), and soon enough we'd also need merge, copy and 
unnamed elements - I'm not sure it's worth the trouble of having two 
different APIs.  Feel free to convince us :)

Zeev

At 16:33 21.05.2003, Sterling Hughes wrote:
>Hi,
>
>I've implemented a very lightweight, efficient hash table for zend
>engine 2.  This is a table that's appropriate for usage in many of the
>areas where then Zend hash table implementation is unnecessarily complex
>(which is pretty much everywhere except for PHP arrays themselves.)
>
>I've attached the implementation, and a patch which integrates the new
>hashtable implementation with Zend, including a "case-study," where I've
>converted over EG(included_files) to use the new hashtable
>implementation.  Right now the hash table code is very simple, as its
>just there for initial perusal, it can of course be improved upon.
>
>So, when can I integrate it? ;-)
>
>-Sterling
>
>--
>"A business that makes nothing but money is a poor kind of business."
>     - Henry Ford

---

## #1867 — Andi Gutmans — 2003-05-21T20:42:51+00:00

URL: https://externals.io/message/1853#1867 · In reply to: #1853

I'll try and take a look at it more closely in the next couple of days.
I've been wanting to make a fast hash for a while for the parts of PHP 
which don't need the goodies in the existing one.
A few things which I saw right away:
a) You can allocate the key as part of the hash element. This will save you 
an emalloc() per insertion and an efree() per deletion (we do this in 
zend_hash.*).
b) Instead of using modulo (%) you can use bit arithmetic like in 
zend_hash.*. The hash function is supposed to be good enough.

Wanna write up a new patch?

Thans,
Andi

At 09:33 AM 5/21/2003 -0400, Sterling Hughes wrote:
>Hi,
>
>I've implemented a very lightweight, efficient hash table for zend
>engine 2.  This is a table that's appropriate for usage in many of the
>areas where then Zend hash table implementation is unnecessarily complex
>(which is pretty much everywhere except for PHP arrays themselves.)
>
>I've attached the implementation, and a patch which integrates the new
>hashtable implementation with Zend, including a "case-study," where I've
>converted over EG(included_files) to use the new hashtable
>implementation.  Right now the hash table code is very simple, as its
>just there for initial perusal, it can of course be improved upon.
>
>So, when can I integrate it? ;-)
>
>-Sterling
>
>--
>"A business that makes nothing but money is a poor kind of business."
>     - Henry Ford
