Cache Introspection Sepcification

1 view
Skip to first unread message

Mark Mandel

unread,
Jul 11, 2008, 2:35:18 AM7/11/08
to transf...@googlegroups.com
Just wanted to run past you guys how I planned on doing the cache
introspection, for 1.1

Ticket #to19
http://tracker.transfer-orm.com/issue.cfm?p=89977683-A728-9CD3-ABD9545A91734422&i=B4813689-093F-09BD-BF2D45742F18D1AE

transfer.com.Transfer will have a new method:
transfer.getCacheMonitor() : CacheMonitor

Which will return a CFC that allows access to introspect the cache.

Cache Monitor will have the following methods on it:

CacheMonitor
-------------------------
getCachedClasses() : array
An array of all the classes currently stored in the cache

getCacheSetting(class) : struct
Returns a struct that outlines what scope, maxtimeouts etc that
particular class is configured with.
Question: Is it okay to use a struct here? or do you want me to pass
back a CFC? Internally, this is all stored on Java objects, so it
seemed to make sense to expose this via a struct.

getHits(class) : numeric
The number of cache hits, for a particular class

getMisses(class) : numeric
The number of cache misses, for a particular class

getEstimatedSize(class) : numeric
This is a fast look at how many items in the cache, simply by checking
its size. It doesn't check to see if any of the softReferences have
been cleared.

getCalculatedSize(class) : numerica
This is a slow look at how many items are in cache, where it will take
a copy of the cache, and loop through, testing to see if any of the
softReferences have been cleared or not.

getTotalHits() : numeric
A loop around to get a total number of hits for all classes in the cache.

getTotalMisses() : numeric
A loop around to get the total number of misses across all classes in the cache.

getTotalEstimatedSize() : numeric
A loop around to get the total Estimated size.

getTotalCalculatedSize() : numeric
A loop around to get the total Calculated size.

I think that covers most things.. can anyone think of anything else
they would like to add / change / comment on?

Mark

--
E: mark....@gmail.com
W: www.compoundtheory.com

Bob Silverberg

unread,
Jul 11, 2008, 6:45:12 AM7/11/08
to transf...@googlegroups.com
Sounds cool Mark. Forgive my ignorance, as this may be a ridiculous
request, but is there any way to report back how much memory is being
used (e.g, for a specific class)? I'm assuming that size reports
number of objects.

Cheers,
Bob

--
Bob Silverberg
www.silverwareconsulting.com

Luis Majano

unread,
Jul 11, 2008, 7:46:54 PM7/11/08
to transfer-dev
> getCacheSetting(class) : struct
Seems enough for me, instead of a cfc/bean simulating it. Its mostly
for reporting purposes anyways.
However, if you want to get funky, why not have a bean that can be
passed in at runtime, to change the behavior of the cache settings at
runtime?? Maybe due to traffic considerations or flux?

Here are some funky ideas for you:

- How many objects have been evicted by reaps
- How many objects have been garbage collected by the jvm via the soft
references
- hit vs miss ratio: getCacheRatio()
- How about an array of class map reports that can show a class'
performance: hits, misses, evictions, gc, class set timeout, class
storage scope and calculate an efficiency for it. This can give good
data as to how to tweak the cache on certain classes to modify their
timeouts if necessary.




On Jul 11, 3:45 am, "Bob Silverberg" <bob.silverb...@gmail.com> wrote:
> Sounds cool Mark.  Forgive my ignorance, as this may be a ridiculous
> request, but is there any way to report back how much memory is being
> used (e.g, for a specific class)?  I'm assuming that size reports
> number of objects.
>
> Cheers,
> Bob
>
>
>
> On Fri, Jul 11, 2008 at 2:35 AM, Mark Mandel <mark.man...@gmail.com> wrote:
>
> > Just wanted to run past you guys how I planned on doing the cache
> > introspection, for 1.1
>
> > Ticket #to19
> >http://tracker.transfer-orm.com/issue.cfm?p=89977683-A728-9CD3-ABD954...
> > E: mark.man...@gmail.com
> > W:www.compoundtheory.com
>
> --
> Bob Silverbergwww.silverwareconsulting.com

Mark Mandel

unread,
Jul 11, 2008, 10:12:28 PM7/11/08
to transf...@googlegroups.com
Bob,

Java doesn't give you a way to determine object memory size, so there
is really no way to determine what the size of objects are, byte wise.

Really, you are looking at Java Profiling tools to be able to do that.

Mark

Mark Mandel

unread,
Jul 11, 2008, 10:18:26 PM7/11/08
to transf...@googlegroups.com
>
>> getCacheSetting(class) : struct
> Seems enough for me, instead of a cfc/bean simulating it. Its mostly
> for reporting purposes anyways.
> However, if you want to get funky, why not have a bean that can be
> passed in at runtime, to change the behavior of the cache settings at
> runtime?? Maybe due to traffic considerations or flux?

Maybe... ;) how much would people want to be able to change their
cache settings at runtime tho'?

>
> Here are some funky ideas for you:
>
> - How many objects have been evicted by reaps
> - How many objects have been garbage collected by the jvm via the soft
> references

This may be a bit tricky to work out, as Transfer just clears the
softReference and enqueues it when discarding from timeouts... I'll
have to look into it. It should be possible to calculate reaps, but
maybe not GC'd objects.

> - hit vs miss ratio: getCacheRatio()

So -

getHitMissRatio(class) : numeric
getTotalHitMissRatio() : numeric

> - How about an array of class map reports that can show a class'
> performance: hits, misses, evictions, gc, class set timeout, class
> storage scope and calculate an efficiency for it. This can give good
> data as to how to tweak the cache on certain classes to modify their
> timeouts if necessary.

Well, if you have all the data we're talking about.. you only have to
loop around the getCachedClasses() array, and work it out... or you
want me to do that for you, is what you're saying?

Brian G

unread,
Jul 16, 2008, 1:23:16 AM7/16/08
to transfer-dev
> getHitMissRatio(class) : numeric
> getTotalHitMissRatio() : numeric

I think this spec is looking great - this will be very valuable Mark.
I'm particularly excited because I'm sure someone will build a very
nice tool that will take and log this information for historical
graphing to help understand an application's usage and how to tune the
cache.

For me, I just need enough data to properly tune the cache on a per-
object or per-application basis. So long as numbers are easy to pull
out that will help me determine timeouts or cache sizes as my
application gets to its steady state, then we have a winner!


Brian

Mark Mandel

unread,
Jul 25, 2008, 2:01:22 AM7/25/08
to transf...@googlegroups.com
Just to this note -

I can't distinguish between SoftReference GC'd clearing and Transfer
cache explicitley clearing the soft references, so I'm amending the
API to just have a

getEvictions(class)
getTotalEvictions(class)

Which will include both GC'd and Settings based cache evictions.

Mark

--
E: mark....@gmail.com
W: www.compoundtheory.com

Reply all
Reply to author
Forward
0 new messages