durusmail: durus-users: Re: RELEASED: Durus-3.5
RELEASED: Durus-3.5
2006-08-16
2006-09-21
multithread and implicit cache management (was: Re: [Durus-users] RELEASED: Durus-3.5)
2006-09-21
Re: multithread and implicit cache management
2006-09-21
2006-09-22
2006-09-22
2006-09-22
2006-09-26
2006-09-21
2006-09-21
2006-09-22
2006-09-22
Re: RELEASED: Durus-3.5
2006-09-21
Re: RELEASED: Durus-3.5
Jesus Cea
2006-09-21
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Neil Schemenauer wrote:
> It good that you realized this problem but I don't think it was
> introduced by 3.5.  AFAIK, the Durus cache has always used weak
> references.

As far as I remember, previous Durus versions keept strong references,
only doing the "strong -> weak -> strong" magic when doing the cache
shrink. If an object was garbage, it was still in the cache until the
"strong->weak->strong" step. In fact the code was explicitelly looking
for vanishing references in the strong->weak conversion.

Current code assumes that the cache is being purged in "background"
using the weakref callbacks, and that the cache is "stable" when
entering the shrink code. The fact is that in "legal" multithread code,
the cache is not stable in "shrink". At least not without heroic efforts
or rigid code-style (por example, decorators keeping the lock
acquire/release pattern "shelling" the actual code).

My patch tries to restore that invariant, taking note of vanished
references, but keeping them around until we know that is safe to
actually dispose them.

Thinking about that, a more optimized patch could mutate the
"weak._remove" callback between two versiones: one executing is all the
code, and the other activated when we are inside "shrink". Complexity
paid to the efficient gods.

Or, maybe (not familiar with that code yet), update shrink code to be
aware that cache content can change under its feet.

- --
Jesus Cea Avion                         _/_/      _/_/_/        _/_/_/
jcea@argo.es http://www.argo.es/~jcea/ _/_/    _/_/  _/_/    _/_/  _/_/
jabber / xmpp:jcea@jabber.org         _/_/    _/_/          _/_/_/_/_/
                               _/_/  _/_/    _/_/          _/_/  _/_/
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBRRMlxZlgi5GaxT1NAQL2WAQAjlWhXs5K/vqiXt7Y5unTDaG9oVS8x21v
bIxgecuhIjIOobpWZaOEWQuyyOXFccC/pqKU0uHG6KosclF+Lcx+KJEpxTa1MCS4
UJMHyT/DH2BWwQ2CEileWB5gQ8gABA44v/5CLqIeSb85MFqtfM15P2ap6DoXaaz4
eAEN2MYbzVo=
=uF3m
-----END PGP SIGNATURE-----
reply