Expiring cached data?

Conal Elliott conal at conal.net
Mon Nov 3 09:43:25 EST 2003


Hi Andrew.  This situation is what weak pointers [1] are for.  You keep
weak rather than regular pointers to your cache data.  The garbage
collector clears out the weak pointers and reclaims cache data when
necessary.  However, I don't think there is any policy to make
discriminating choices about *which* cache data gets discarded, for
instance least recently (or frequently) used.  Doing so would seem to be
an interesting and useful extension.  Regards,

     - Conal

[1] Stretching the storage manager: weak pointers and stable names in
Haskell, Simon Peyton Jones, Simon Marlow, and Conal Elliott. Proc
Workshop on Implementing Functional Languages, 1999.
http://research.microsoft.com/~simonpj/Papers/weak.htm 

-----Original Message-----
From: haskell-bounces at haskell.org [mailto:haskell-bounces at haskell.org]
On Behalf Of andrew cooke
Sent: Sunday, November 02, 2003 5:59 PM
To: haskell at haskell.org
Subject: Expiring cached data?



I have a Haskell program that caches data in a tree.  Unfortunately, the
tree grows to exceed the available memory over time.  In a different
language, where I might be handling the caching myself, rather than
relying on laziness within the language, I might work round this by
keeping track of which leaves in the tree were more recently used, and,
when memory run slow, deleting those that have not been used for some
time
(by the nature of the problem, access to particular caches tend to be
grouped, so a long-unused cache can be deleted without much performance
penalty).

What options do I have in Haskell?  I'm interested both in general
solutions (maybe some compilers do this anyway?) and in approaches to
structuring the program so that I can control caching in more detail.

Thanks,
Andrew

-- 
http://www.acooke.org/andrew
_______________________________________________
Haskell mailing list
Haskell at haskell.org
http://www.haskell.org/mailman/listinfo/haskell



More information about the Haskell mailing list