Commit Graph

6 Commits

Author SHA1 Message Date
Tyson Andre
7504cf189b
Improve performance of WeakReference/WeakMap. Avoid hash collisions on pointers. (#7690)
Shift pointers by ZEND_MM_ALIGNMENT_LOG2
to avoid the noticeable performance degradation caused by hash table collisions.
in `EG(weakrefs)` and zend_weakmap->ht

On 64-bit platforms, pointers are usually aligned to at least 8 bytes,
so only one in 8 hash buckets were actually getting used.
(With the metadata needed to track allocations,
alignment might be at least 16 bytes in practice)

Address review comments, add optimization

Make it public for any extensions that need to work with EG(weakrefs)
for instrumentation, debugging, etc. (e.g. zend_test)

PHP 8.1 and previous releases would use the raw pointer value as a hash key instead.
2021-11-27 19:52:30 -05:00
Bob Weinand
471102edcd Add ZEND_API for weakmap functionality via zend_weakrefs_hash_add/del
Closes GH-7600.
2021-10-21 13:34:22 +02:00
twosee
6e92487f66 Fix warnings of strict-prototypes
Closes GH-5887.
2020-07-23 00:59:00 +08:00
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
Peter Kokot
50a6a0d819
Fix duplicate symbols _zend_ce_weakrefs
The zend_ce_weakref need to be external...
2019-03-13 11:38:21 +01:00
Joe Watkins
6529d7acd9
zend_weakrefs 2019-03-12 00:35:35 +01:00