# Reference cycle collector patch

- Thread: https://externals.io/message/32697
- Original archive: https://news-web.php.net/php.internals/32697
- Started by David Wang on 2007-10-08T07:12:31+00:00
- Messages: 5
- 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

---

## #32697 — David Wang — 2007-10-08T07:12:31+00:00

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

Hey all,

Now that macros for manipulating refcount and is_ref have been implemented, I’m ready to submit patches for the GC. I know you all have been waiting for this for a long time ☺.

I have made two sets of patches, one for HEAD and one for PHP_5_3 (note that I had to rearrange the order of definitions and #includes in zend.h to get around a recursive dependency problem):

http://zoo.cs.yale.edu/~yw226/gc/gc6.diff.txt
http://zoo.cs.yale.edu/~yw226/gc/gc5_3.diff.txt

After applying those, these two files should be placed in the Zend subdirectory:

http://zoo.cs.yale.edu/~yw226/gc/zend_gc.c
http://zoo.cs.yale.edu/~yw226/gc/zend_gc.h

For those who were following the progress of the GC through the incubator SVN, the GC implemented with these patches is DIFFERENT than the one currently in the SVN tree. They are from an “experimental” branch that I believed was more tolerant of the zval juggling PHP and its extensions sometimes like to do. It turned out to be very successful, but I hadn’t bothered remerging it.

I highly recommend these two patches in addition (but they are optional for GC functioning):

http://zoo.cs.yale.edu/~yw226/gc/alwaysinline6.diff.txt
http://zoo.cs.yale.edu/~yw226/gc/alwaysinline5_3.diff.txt

These are meant to be applied after the previous patches. These simply change all the inline functions in the Zend engine to “always_inline”. Zend object files can become seriously oversized and this makes the compiler silently ignore the inline keyword. Changing this to always_inline (defined in zend.h) forces the compiler to inline the function or at least give a warning if it cannot.

The reason I bring up the issue here is that my patch is known to sometimes push object files that were just under the internal compiler limit over the edge and make the compiler refuse to inline. This has the effect of making the whole Zend engine disproportionately slower.

Anyway, please try these out and tell me how it goes!


David

P.S. This patch has the GC enabled by default.

---

## #32698 — Cristian Rodriguez — 2007-10-08T08:34:34+00:00

URL: https://externals.io/message/32697#32698 · In reply to: #32697

2007/10/8, David Wang <planetbeing@gmail.com>:
> Hey all,
>
> Now that macros for manipulating refcount and is_ref have been implemented, I'm ready to submit patches for the GC. I know you all have been waiting for this for a long time ☺.

Good, I will test you patches as soon I have time to.

>
> P.S. This patch has the GC enabled by default.

cool, otherwise does not make sense to have it, there are enough magic
switches already ;-)



-- 
http://www.kissofjudas.net/

---

## #32702 — Andi Gutmans — 2007-10-08T16:00:30+00:00

URL: https://externals.io/message/32697#32702 · In reply to: #32697

Thanks David.
We'll start testing the patch in our labs right after we're done with the Zend/PHP conference (early next week).

Andi


> -----Original Message-----
> From: David Wang [mailto:planetbeing@gmail.com]
> Sent: Monday, October 08, 2007 12:13 AM
> To: internals@lists.php.net
> Subject: [PHP-DEV] Reference cycle collector patch
> 
> Hey all,
> 
> Now that macros for manipulating refcount and is_ref have been
> implemented, I’m ready to submit patches for the GC. I know you all
> have been waiting for this for a long time ☺.
> 
> I have made two sets of patches, one for HEAD and one for PHP_5_3 (note
> that I had to rearrange the order of definitions and #includes in
> zend.h to get around a recursive dependency problem):
> 
> http://zoo.cs.yale.edu/~yw226/gc/gc6.diff.txt
> http://zoo.cs.yale.edu/~yw226/gc/gc5_3.diff.txt
> 
> After applying those, these two files should be placed in the Zend
> subdirectory:
> 
> http://zoo.cs.yale.edu/~yw226/gc/zend_gc.c
> http://zoo.cs.yale.edu/~yw226/gc/zend_gc.h
> 
> For those who were following the progress of the GC through the
> incubator SVN, the GC implemented with these patches is DIFFERENT than
> the one currently in the SVN tree. They are from an “experimental”
> branch that I believed was more tolerant of the zval juggling PHP and
> its extensions sometimes like to do. It turned out to be very
> successful, but I hadn’t bothered remerging it.
> 
> I highly recommend these two patches in addition (but they are optional
> for GC functioning):
> 
> http://zoo.cs.yale.edu/~yw226/gc/alwaysinline6.diff.txt
> http://zoo.cs.yale.edu/~yw226/gc/alwaysinline5_3.diff.txt
> 
> These are meant to be applied after the previous patches. These simply
> change all the inline functions in the Zend engine to “always_inline”.
> Zend object files can become seriously oversized and this makes the
> compiler silently ignore the inline keyword. Changing this to
> always_inline (defined in zend.h) forces the compiler to inline the
> function or at least give a warning if it cannot.
> 
> The reason I bring up the issue here is that my patch is known to
> sometimes push object files that were just under the internal compiler
> limit over the edge and make the compiler refuse to inline. This has
> the effect of making the whole Zend engine disproportionately slower.
> 
> Anyway, please try these out and tell me how it goes!
> 
> 
> David
> 
> P.S. This patch has the GC enabled by default.

---

## #33423 — johannes@php.net — 2007-11-25T15:18:47+00:00

URL: https://externals.io/message/32697#33423 · In reply to: #32702

Hi Andi,


> Thanks David.
> We'll start testing the patch in our labs right after we're done with the Zend/PHP conference (early next week).

Are there any results of these benchmarks, yet?

johannes

> Andi
> 
> 
> > […]

---

## #33429 — Derick Rethans — 2007-11-25T22:53:21+00:00

URL: https://externals.io/message/32697#33429

> Johannes Schlüter schrieb:
> > […]
> 
>  Why not just commit the new garbage collector to PHP_5_3 now and disable
>  it by default? This would make testing/benchmarking it so much easier
>  for everyone interested.

That's the plan.

Derick
