more GC musing : wondering abt registry extension?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

more GC musing : wondering abt registry extension?

OpenMacNews-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

hi all,

as i create/use local singleton objs across my ZF-implemented site, i'm
keeping track of them in a _SESSION queue for eventual garbage
collection ( i'm missing JAVA's gc heap collection thread already ... )

as i leave local context for a given (set of) objects, i unset them in
the appropriate parent's destructor.

while doing so, i'm nagged a bit by the use/utility of zend::registry
for this.

i could, obviously, register each object in the registry -- make it more
generally useful that way too -- BUT, since, according to registry doc:

        "an object can never be removed from the registry"

i'd end up -- eventually -- with a bloated registry, and no way to clean
it up.

also, iiuc, there's no flagged-partitioning of the registry ... i.e.,
there's ONE registry, and it's of global context.

if i want to address a subset of the registry relevant to objects in a
*specific* context -- and, e.g., eventually gc them -- the only way i
can see is to either:

- -- play string concat games with reistry entry names

        e.g.  $item = zend::register('blah'.$section, $object)
&/or

        keep track of a context's objects by name, and do an arraymatch()
against a zend::registry('') return of the registry contents ... but
then why not DIY.


so, after this blather, i find myself thinking:

(1) it would be nice to have a ZF 'wrapper' around this
(2) why *not* allow removal from the registry?
(3) an additional/optional param for partitioning would be useful, ala:
        zend::register($name, $object (, $flag))

interested in thoughts/wisdom others might share.

especially as to whether i'm trying to "put lipstick on a pig" ...

cheers,

richard

- --

/"\
\ /  ASCII Ribbon Campaign
 X   against HTML email, vCards
/ \  & micro$oft attachments

[GPG] OpenMacNews at gmail dot com
fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iEYEAREDAAYFAkRtFGwACgkQlffdvTZxCMY0iwCgolaj/cmQiIiEkkRtNMjUlJec
ksoAoKXc99bULFv/6NAP2m7lpJDHjNmG
=5ELF
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: more GC musing : wondering abt registry extension?

Simon Mundy
Out of interest, why do you need to store these in a session in the  
first place?

I can see from a design point of view that the registry only lives as  
long as the calling script anyway, so all objects are destroyed at  
scripts end and therefore no need to perform garbage collection.

But if you're specifically using a session to manage certain objects,  
why not use the new proposed Zend_Session and use the transitory  
method? Under what circumstances do you want these objects to expire?

> as i create/use local singleton objs across my ZF-implemented site,  
> i'm
> keeping track of them in a _SESSION queue for eventual garbage
> collection ( i'm missing JAVA's gc heap collection thread  
> already ... )

--

Simon Mundy | Director | PEPTOLAB

""" " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "
202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654  
4124
http://www.peptolab.com


Reply | Threaded
Open this post in threaded view
|

Re: more GC musing : wondering abt registry extension?

OpenMacNews-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

hi simon,

On 5/18/06 Simon Mundy wrote:
> Out of interest, why do you need to store these in a session in the first place?

well, first, generally, at this stage with ZF, "why" is an apprpriate
question for anything/everything i'm doing ...

that said, i'm storing the queue of object identities in _SESSION simply
cuz its easy to get at it from everywhere else.  in effect, using
_SESSION as a regsitry in-and-of-itself.

just came to mind first ... not ideal.  hence -- my continued 'musing'

> I can see from a design point of view that the registry only lives as long as the
> calling script anyway, so all objects are destroyed at scripts end and therefore no
> need to perform garbage collection.
>
> But if you're specifically using a session to manage certain objects, why not use
> the new proposed Zend_Session

simply cuz (a) it's not in release tree, (b) it's not in incubator, and
(c) per docs, "Session support is not currently implemented in the Zend
Framework. "

no better reason at this point ...

well, other than DIY is forcing me to think abt design ...

> and use the transitory method?


> Under what circumstances
> do you want these objects to expire?

this particualar "excercise" started with the need to destroy tangible
resources (think files on disk) that are created & used only within a
particular set of objects' context.  once that context is departed,
those resources need to go away -- physically deleted -- as well.

for me, in this case, the "GC" is not just mgmt of an object's memory
allocation. i *do* understand that gc is automatic (well, mostly) for
objects alone ...

but, rather, it's "GC" of all associated resources ...

in JAVA it's straigthforward (well, in princple anyway, at least until
thread collisions begin ...).  since the jvm's heap is auto-GC'd,
triggered when last pending reference (global &/or local) to an object
disappears, and it's in an addressible process thread, i can 'grab' that
trigger, pull the queue of associated tangible resources from a stack,
and execute the deletes in the jvm's destructor.

as i 'muse' here, i find myself attempting much the same here.  i'm just
stopping to the think of more than just the "can" and consider the
"should" ...

cheers,

richard

- --

/"\
\ /  ASCII Ribbon Campaign
 X   against HTML email, vCards
/ \  & micro$oft attachments

[GPG] OpenMacNews at gmail dot com
fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iEYEAREDAAYFAkRtHvwACgkQlffdvTZxCMamyACcDNkHAjxmiQhFLsvBwEMKAEgP
W8AAoIR2iSTwhBVXzO0ofVdpg/n2/3L9
=RXY/
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: more GC musing : wondering abt registry extension?

Simon Mundy
Yeah, I know the Zend_Session isn't supported yet, but I figured that  
since you were using ZF already (and not production quality in an  
official sense) that you wouldn't mind using proposed modules to see  
if they fit your project. I'm using it in a couple of my WIPs and  
it's working a treat.

It's kind of hard for me to provide more concrete examples of how you  
should get rid of those objects, as I'm obviously not familiar with  
the relationships between the resources and their contexts, but I  
would imagine that inheritance and the __destruct methods would be  
the ideal choice.

If you had:-

class Widget
{
        protected $_resource;

        public function init()
        {
                $this->_resource = new OpenMacResourceFile();
        }

        function __destruct()
        {
                $this->_resource->cleanup();
        }
}

...then you'd store this object in a session, and as it would persist  
in the session as long as you needed it, the resource would too. When  
you go to unset it from the session, it simply tells its resource to  
clean up after itself and you're done.

Is this what you're wanting to achieve, or have I misunderstood you?

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: RIPEMD160
>
> hi simon,
>
> On 5/18/06 Simon Mundy wrote:
>> Out of interest, why do you need to store these in a session in  
>> the first place?
>
> well, first, generally, at this stage with ZF, "why" is an apprpriate
> question for anything/everything i'm doing ...
>
> that said, i'm storing the queue of object identities in _SESSION  
> simply
> cuz its easy to get at it from everywhere else.  in effect, using
> _SESSION as a regsitry in-and-of-itself.
>
> just came to mind first ... not ideal.  hence -- my continued 'musing'
>
>> I can see from a design point of view that the registry only lives  
>> as long as the
>> calling script anyway, so all objects are destroyed at scripts end  
>> and therefore no
>> need to perform garbage collection.
>>
>> But if you're specifically using a session to manage certain  
>> objects, why not use
>> the new proposed Zend_Session
>
> simply cuz (a) it's not in release tree, (b) it's not in incubator,  
> and
> (c) per docs, "Session support is not currently implemented in the  
> Zend
> Framework. "
>
> no better reason at this point ...
>
> well, other than DIY is forcing me to think abt design ...
>
>> and use the transitory method?
>
>
>> Under what circumstances
>> do you want these objects to expire?
>
> this particualar "excercise" started with the need to destroy tangible
> resources (think files on disk) that are created & used only within a
> particular set of objects' context.  once that context is departed,
> those resources need to go away -- physically deleted -- as well.
>
> for me, in this case, the "GC" is not just mgmt of an object's memory
> allocation. i *do* understand that gc is automatic (well, mostly) for
> objects alone ...
>
> but, rather, it's "GC" of all associated resources ...
>
> in JAVA it's straigthforward (well, in princple anyway, at least until
> thread collisions begin ...).  since the jvm's heap is auto-GC'd,
> triggered when last pending reference (global &/or local) to an object
> disappears, and it's in an addressible process thread, i can 'grab'  
> that
> trigger, pull the queue of associated tangible resources from a stack,
> and execute the deletes in the jvm's destructor.
>
> as i 'muse' here, i find myself attempting much the same here.  i'm  
> just
> stopping to the think of more than just the "can" and consider the
> "should" ...
>
> cheers,
>
> richard
>
> - --
>
> /"\
> \ /  ASCII Ribbon Campaign
>  X   against HTML email, vCards
> / \  & micro$oft attachments
>
> [GPG] OpenMacNews at gmail dot com
> fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (Darwin)
>
> iEYEAREDAAYFAkRtHvwACgkQlffdvTZxCMamyACcDNkHAjxmiQhFLsvBwEMKAEgP
> W8AAoIR2iSTwhBVXzO0ofVdpg/n2/3L9
> =RXY/
> -----END PGP SIGNATURE-----
>


--

Simon Mundy | Director | PEPTOLAB

""" " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "
202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654  
4124
http://www.peptolab.com


Reply | Threaded
Open this post in threaded view
|

Re: more GC musing : wondering abt registry extension?

OpenMacNews-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Simon Mundy wrote, On 5/18/06 6:54 PM:
> Yeah, I know the Zend_Session isn't supported yet, but I figured that
> since you were using ZF already (and not production quality in an
> official sense) that you wouldn't mind using proposed modules to see if
> they fit your project.

sure, just want to avoid burning the candle at *three* ends at once ;-)
 i'll get there ...

> I'm using it in a couple of my WIPs and it's
> working a treat.

here's hoping WIP == "work in progress", not some weird Oz-thing :-p


> Is this what you're wanting to achieve, or have I misunderstood you?

not at all.  that's exactly what i'm DIY-ing.

the musing, again, is abt a 'wrapper' that 'behaves' with ZF (yes, i'll
take a look at Zend_Session ... once I can figure out where it's hiding
8-} ), and abt collectively tracking the objects -- in either global
&/or local contexts.

also, the nicety of having the obj auto-GC'd by a separate thread that's
watching the reference states is something i miss, but, honestly have no
clue whether that a "limitation" or "feature" of php ... or even where
that would arguably be taken care of (in/by the Zend2 engine?).

just unclear ...

thx! for your comments!

cheers,

richard


- --

/"\
\ /  ASCII Ribbon Campaign
 X   against HTML email, vCards
/ \  & micro$oft attachments

[GPG] OpenMacNews at gmail dot com
fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iEYEAREDAAYFAkRtOq8ACgkQlffdvTZxCMao2ACgigjILRidGeuMz2UFwXiMxrCA
SgUAnjFhENo5iZPLrQ+/mUcIBswIj6Me
=cd2W
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: more GC musing : wondering abt registry extension?

Ralph Schindler
OpenMacNews wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: RIPEMD160
>


> the musing, again, is abt a 'wrapper' that 'behaves' with ZF (yes, i'll
> take a look at Zend_Session ... once I can figure out where it's hiding
> 8-} ), and abt collectively tracking the objects -- in either global
> &/or local contexts.
>

Zend_Session is hiding here ;)

http://www.ralphschindler.com/Zend_Framework_Modules/Zend_Session/Zend_Session-proposal3.txt
http://www.ralphschindler.com/Zend_Framework_Modules/Zend_Session/Zend_Session_Module-0.3.zip




I hear what you are saying about things not being removed from the
registry, the only problem I have encountered is trying to get a
destructor to run on a singleton that has an instance still in registry,
I am having to wait till script end to get a destructor to run, or call
a function to do the destructors work... But, by design of a decent and
creative API, I've gotten around those limitations.

-ralph
Reply | Threaded
Open this post in threaded view
|

Re: more GC musing : wondering abt registry extension?

OpenMacNews-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

hi ralph,

> Zend_Session is hiding here ;)
>
> http://www.ralphschindler.com/Zend_Framework_Modules/Zend_Session/Zend_Session-proposal3.txt
> http://www.ralphschindler.com/Zend_Framework_Modules/Zend_Session/Zend_Session_Module-0.3.zip

found em. i've just been reading them ... thanks! :-)

> I hear what you are saying about things not being removed from the
> registry, the only problem I have encountered is trying to get a
> destructor to run on a singleton that has an instance still in registry,
> I am having to wait till script end to get a destructor to run, or call
> a function to do the destructors work... But, by design of a decent and
> creative API, I've gotten around those limitations.

synchronous event timing in GC is often a challenge ... i'm interested
to see how you've done it.  thx again!

in general, re: ZF-proposed items, i'll look forward to:

(a) seeing formally-proposed-but-not-yet-accepted items on the ZF site
sometime soon, and

(b) a user wiki where folks can start playing with & sharing
experiences, examples, etc.

cheers,

richard
- --

/"\
\ /  ASCII Ribbon Campaign
 X   against HTML email, vCards
/ \  & micro$oft attachments

[GPG] OpenMacNews at gmail dot com
fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iEYEAREDAAYFAkRtQ6sACgkQlffdvTZxCMZ6egCfZKYg3gfv/jyb7luAK9PZ/pm/
1xIAnRtMGk2JyGR3ufY3hlSBN5unRhBr
=0zvM
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: more GC musing : wondering abt registry extension?

OpenMacNews-2
In reply to this post by OpenMacNews-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

hi rob,

> if I'm telling you to suck eggs!

heh. get in line! ;-)

> Unless you are using extremely large amounts of memory,

in a couple of instances i will be ... but, to be fair, not as the basis
 for my current examples/thinking ...

> in general
> within PHP, it's easier to let the script discard everything at the end
> of the page request.

yup.

> Essentially, PHP uses a share-nothing, setup/teardown every request type
> model. I suspect that if you are storing lots of objects in the session
> between requests, then you are "thinking Java" more than "thinking PHP"?

that may be the case.  sitting down with a copy of "PHP 5 Objects,
Patterns & Practice" this weekend to set (reset?) myself straight! :-)

>> as i leave local context for a given (set of) objects, i unset them in
>> the appropriate parent's destructor.
>>
>
> Why bother?

in general, for the same reason that i declare variables ... it's good
practice (or so i'll think until the pending 'reset' ...)

> It'll be emptied at the end of the page request which is in about 350ms
> time with any luck!
>
> Of course, it all depends what you are doing with the script, I suppose.
> But for a website, generally, not enough memory is used that you have to
> worry about garbage collection is unlikely.
>
> I'll shut up now in case I've completely misunderstood!

assuming that i was clear in the first place, not so much mis-understood
as just mis-sed.  for me this has *also* been about destroying tangible,
temporary resources (files on disk) associated with the object at the
time of object destruction ...

as i'd mentioned ( to steven, perhaps? i forget ...) if "just" objects
are involved, i agree.

cheers,

richard

- --

/"\
\ /  ASCII Ribbon Campaign
 X   against HTML email, vCards
/ \  & micro$oft attachments

[GPG] OpenMacNews at gmail dot com
fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iEYEAREDAAYFAkRt4ZoACgkQlffdvTZxCMY7mwCgu9X/muNE2QqjjLDPAZ3fVJon
x6kAoMQSpXP46f9H0jF2Av1fBnztPRUT
=x8sk
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: more GC musing : wondering abt registry extension?

Jayson Minard (ZF)
In reply to this post by OpenMacNews-2
Richard,

We are close to having the "laboratory" repository ready for proposed ideas
and are looking at ways to make proposal management easier.  Since we want
to review all open proposals and get them moving, it is a big issue to
resolve quickly.

I'll send updates as we sort it out.

--j


On 5/18/06 9:03 PM, "OpenMacNews" <[hidden email]> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: RIPEMD160
>
> hi ralph,
>
>> Zend_Session is hiding here ;)
>>
>> http://www.ralphschindler.com/Zend_Framework_Modules/Zend_Session/Zend_Sessio
>> n-proposal3.txt
>> http://www.ralphschindler.com/Zend_Framework_Modules/Zend_Session/Zend_Sessio
>> n_Module-0.3.zip
>
> found em. i've just been reading them ... thanks! :-)
>
>> I hear what you are saying about things not being removed from the
>> registry, the only problem I have encountered is trying to get a
>> destructor to run on a singleton that has an instance still in registry,
>> I am having to wait till script end to get a destructor to run, or call
>> a function to do the destructors work... But, by design of a decent and
>> creative API, I've gotten around those limitations.
>
> synchronous event timing in GC is often a challenge ... i'm interested
> to see how you've done it.  thx again!
>
> in general, re: ZF-proposed items, i'll look forward to:
>
> (a) seeing formally-proposed-but-not-yet-accepted items on the ZF site
> sometime soon, and
>
> (b) a user wiki where folks can start playing with & sharing
> experiences, examples, etc.
>
> cheers,
>
> richard
> - --
>
> /"\
> \ /  ASCII Ribbon Campaign
>  X   against HTML email, vCards
> / \  & micro$oft attachments
>
> [GPG] OpenMacNews at gmail dot com
> fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (Darwin)
>
> iEYEAREDAAYFAkRtQ6sACgkQlffdvTZxCMZ6egCfZKYg3gfv/jyb7luAK9PZ/pm/
> 1xIAnRtMGk2JyGR3ufY3hlSBN5unRhBr
> =0zvM
> -----END PGP SIGNATURE-----
>


Reply | Threaded
Open this post in threaded view
|

Re: more GC musing : wondering abt registry extension?

Ralph Schindler
Jayson Minard wrote:

> and are looking at ways to make proposal management easier.  Since we want
> to review all open proposals and get them moving, it is a big issue to
> resolve quickly.

It would also be great if somewhere in that repository could be the
feedback notes of the discussion from the powers that be so we can have
a more detailed summary of how decisions were made on these proposals,
accepted or otherwise...

my 2cents,
-ralph
Reply | Threaded
Open this post in threaded view
|

Re: more GC musing : wondering abt registry extension?

OpenMacNews-2
In reply to this post by Jayson Minard (ZF)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

jayson,

On 5/19/06 Jayson Minard wrote:
> We are close to having the "laboratory" repository ready for proposed ideas
> and are looking at ways to make proposal management easier.  Since we want
> to review all open proposals and get them moving, it is a big issue to
> resolve quickly.
>
> I'll send updates as we sort it out.

great to hear ... er ... be reminded of. :-)

thx!

richard

- --

/"\
\ /  ASCII Ribbon Campaign
 X   against HTML email, vCards
/ \  & micro$oft attachments

[GPG] OpenMacNews at gmail dot com
fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iEYEAREDAAYFAkRt9hgACgkQlffdvTZxCMYIVACfYg3aH5nUdB+W4fGheGaoPHom
kPsAnihJ4Np8A+IT3qIoFemg3QoSPxmG
=8jXE
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: more GC musing : wondering abt registry extension?

Jayson Minard (ZF)
In reply to this post by Ralph Schindler
Looking at options for that as well.  We are considering the question
currently of what goes in the repository versus an actual web page or
wrapper around each of these proposals.

--j


On 5/19/06 9:47 AM, "Ralph Schindler" <[hidden email]> wrote:

> Jayson Minard wrote:
>
>> and are looking at ways to make proposal management easier.  Since we want
>> to review all open proposals and get them moving, it is a big issue to
>> resolve quickly.
>
> It would also be great if somewhere in that repository could be the
> feedback notes of the discussion from the powers that be so we can have
> a more detailed summary of how decisions were made on these proposals,
> accepted or otherwise...
>
> my 2cents,
> -ralph
>