You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by Marshall Schor <ms...@schor.com> on 2008/06/27 15:52:12 UTC

JCAS_CACHE_ENABLED documentation question

The documentation for this says:

"The JCas cache ... incurs a steep memory overhead".  I think the actual 
number is ~1.5 * size-of-a-java-reference (4 bytes on a 32 bit java), 
per JCas object, plus the overhead of holding on to the actual JCas 
cover instances longer than needed.  This latter item I think dominates 
the storage usage.

I plan to change this documentation to a more in depth discussion along 
the lines above, and also document how to clear the cache when it's no 
longer needed, unless there are objections :-)

-Marshall

Re: JCAS_CACHE_ENABLED documentation question

Posted by Marshall Schor <ms...@schor.com>.
Michael Baessler wrote:
> Marshall Schor wrote:
>   
>> Michael Baessler wrote:
>>     
>>> Marshall Schor wrote:
>>>  
>>>       
>>>> The documentation for this says:
>>>>
>>>> "The JCas cache ... incurs a steep memory overhead".  I think the actual
>>>> number is ~1.5 * size-of-a-java-reference (4 bytes on a 32 bit java),
>>>> per JCas object, plus the overhead of holding on to the actual JCas
>>>> cover instances longer than needed.  This latter item I think dominates
>>>> the storage usage.
>>>>
>>>> I plan to change this documentation to a more in depth discussion along
>>>> the lines above, and also document how to clear the cache when it's no
>>>> longer needed, unless there are objections :-)
>>>>
>>>> -Marshall
>>>>     
>>>>         
>>> Is there a way to just clear the JCas cache? I'm trying to retrieve
>>> the size of the cache for a test
>>> case and I wasn't able to.
>>>   
>>>       
>> There is a public static method, part of the JCasImpl, (not currently in
>> the JCas Interface), called clearData(CAS cas).
>>
>> You pass it a reference to a CAS object, and it clears JCas caches
>> associated with that CAS (for pipelines having Pear descriptors,where
>> class loaders are being switched, it clears *all* the caches - there is
>> a separate cache for each class loader, since each one has a different
>> JCas cover object class).
>>
>> If nothing else in the application is referencing the individual JCas
>> class instances, they will then be eligible for garbage collection.
>>
>> There isn't currently an API to retrieve the sizes of the caches.  You
>> can see some commented-out code in JCasImpl source in the clearData
>> method which prints the sizes to system.out, though.
>>
>> -Marshall
>>     
>
> Thanks for the details, I saw this method, but I also saw "(Internal Use only)".
> So I think we should remove this comment if we expose this method to be used to clear the cache.
>   
+1 -Marshall

Re: JCAS_CACHE_ENABLED documentation question

Posted by Michael Baessler <mb...@michael-baessler.de>.
Marshall Schor wrote:
> Michael Baessler wrote:
>> Marshall Schor wrote:
>>  
>>> The documentation for this says:
>>>
>>> "The JCas cache ... incurs a steep memory overhead".  I think the actual
>>> number is ~1.5 * size-of-a-java-reference (4 bytes on a 32 bit java),
>>> per JCas object, plus the overhead of holding on to the actual JCas
>>> cover instances longer than needed.  This latter item I think dominates
>>> the storage usage.
>>>
>>> I plan to change this documentation to a more in depth discussion along
>>> the lines above, and also document how to clear the cache when it's no
>>> longer needed, unless there are objections :-)
>>>
>>> -Marshall
>>>     
>>
>> Is there a way to just clear the JCas cache? I'm trying to retrieve
>> the size of the cache for a test
>> case and I wasn't able to.
>>   
> There is a public static method, part of the JCasImpl, (not currently in
> the JCas Interface), called clearData(CAS cas).
> 
> You pass it a reference to a CAS object, and it clears JCas caches
> associated with that CAS (for pipelines having Pear descriptors,where
> class loaders are being switched, it clears *all* the caches - there is
> a separate cache for each class loader, since each one has a different
> JCas cover object class).
> 
> If nothing else in the application is referencing the individual JCas
> class instances, they will then be eligible for garbage collection.
> 
> There isn't currently an API to retrieve the sizes of the caches.  You
> can see some commented-out code in JCasImpl source in the clearData
> method which prints the sizes to system.out, though.
> 
> -Marshall

Thanks for the details, I saw this method, but I also saw "(Internal Use only)".
So I think we should remove this comment if we expose this method to be used to clear the cache.

-- Michael

Re: JCAS_CACHE_ENABLED documentation question

Posted by Marshall Schor <ms...@schor.com>.
Michael Baessler wrote:
> Marshall Schor wrote:
>   
>> The documentation for this says:
>>
>> "The JCas cache ... incurs a steep memory overhead".  I think the actual
>> number is ~1.5 * size-of-a-java-reference (4 bytes on a 32 bit java),
>> per JCas object, plus the overhead of holding on to the actual JCas
>> cover instances longer than needed.  This latter item I think dominates
>> the storage usage.
>>
>> I plan to change this documentation to a more in depth discussion along
>> the lines above, and also document how to clear the cache when it's no
>> longer needed, unless there are objections :-)
>>
>> -Marshall
>>     
>
> Is there a way to just clear the JCas cache? I'm trying to retrieve the size of the cache for a test
> case and I wasn't able to.
>   
There is a public static method, part of the JCasImpl, (not currently in 
the JCas Interface), called clearData(CAS cas).

You pass it a reference to a CAS object, and it clears JCas caches 
associated with that CAS (for pipelines having Pear descriptors,where 
class loaders are being switched, it clears *all* the caches - there is 
a separate cache for each class loader, since each one has a different 
JCas cover object class).

If nothing else in the application is referencing the individual JCas 
class instances, they will then be eligible for garbage collection.

There isn't currently an API to retrieve the sizes of the caches.  You 
can see some commented-out code in JCasImpl source in the clearData 
method which prints the sizes to system.out, though.

-Marshall

Re: JCAS_CACHE_ENABLED documentation question

Posted by Michael Baessler <mb...@michael-baessler.de>.
Marshall Schor wrote:
> The documentation for this says:
> 
> "The JCas cache ... incurs a steep memory overhead".  I think the actual
> number is ~1.5 * size-of-a-java-reference (4 bytes on a 32 bit java),
> per JCas object, plus the overhead of holding on to the actual JCas
> cover instances longer than needed.  This latter item I think dominates
> the storage usage.
> 
> I plan to change this documentation to a more in depth discussion along
> the lines above, and also document how to clear the cache when it's no
> longer needed, unless there are objections :-)
> 
> -Marshall

Is there a way to just clear the JCas cache? I'm trying to retrieve the size of the cache for a test
case and I wasn't able to.

-- Michael

Re: JCAS_CACHE_ENABLED documentation question

Posted by Thilo Goetz <tw...@gmx.de>.
Marshall Schor wrote:
> Thilo Goetz wrote:
>> Marshall Schor wrote:
>>> The documentation for this says:
>>>
>>> "The JCas cache ... incurs a steep memory overhead".  I think the 
>>> actual number is ~1.5 * size-of-a-java-reference (4 bytes on a 32 bit 
>>> java), per JCas object, plus the overhead of holding on to the actual 
>>> JCas cover instances longer than needed.  This latter item I think 
>>> dominates the storage usage.
>>
>> We can replace "steep memory overhead" by "20-40% CAS memory overhead" if
>> you like, because those are the numbers that I have seen in my 
>> benchmarks.
> I think this number depends on whether or not the instantiations are 
> being re-used, and these measurements are the typical range assuming 
> thei instantiations are not being reused; is that correct?

The overhead is independent of whether instances are being
reused.  The JCas cache accumulates all JCas objects, and
from that moment on they're around, needed or not.  Now the
overhead might be acceptable because it improves performance,
but it's still overhead.

>>
>> Which reminds me that I would still be interested to see benchmarks where
>> the JCas cache actually helps.  For if there are none, we should disable
>> it by default.
> It would seem to help only in the case where things put into the CAS 
> were subsequently fetched out of the CAS using iterators, where both 
> were using the JCas.  If you put things into the CAS using the JCas, but 
> iterated them out (how's that for verbing... ;-) without using JCas, 
> then that would be a case for not using the cache.

We know when not to use the cache.  What I want to
know is if there are cases where it makes sense to
use it.  I agree that it might help, but then again,
maybe not.  The only thing that will decide this is
a benchmark that shows that the JCas cache helps in
some instances.

All benchmarks that we ran showed the JCas cache to
be a performance penalty, not an improvement.  At
least one of the tests was on a realistic production
system with significant JCas use.

>>> I plan to change this documentation to a more in depth discussion 
>>> along the lines above, and also document how to clear the cache when 
>>> it's no longer needed, unless there are objections :-)
>>
>> I would like to leave the current paragraph exactly as it is, because it
>> is short and to the point.  It tells people to benchmark their 
>> application
>> to see what's best for themselves.
> I agree with your point of shortness; but don't want to unnecessarily 
> bias people toward this if it not the more common case.  I think in the 
> cases you're thinking about, people have been paying attention to tuning 
> already, and have selected various optimizations to do.

If the more common case is that the cache is a good
thing, then it should be easy to show that with some
numbers.  Until I've seen those, I remain unconvinced.

--Thilo


Re: JCAS_CACHE_ENABLED documentation question

Posted by Marshall Schor <ms...@schor.com>.
Thilo Goetz wrote:
> Marshall Schor wrote:
>> The documentation for this says:
>>
>> "The JCas cache ... incurs a steep memory overhead".  I think the 
>> actual number is ~1.5 * size-of-a-java-reference (4 bytes on a 32 bit 
>> java), per JCas object, plus the overhead of holding on to the actual 
>> JCas cover instances longer than needed.  This latter item I think 
>> dominates the storage usage.
>
> We can replace "steep memory overhead" by "20-40% CAS memory overhead" if
> you like, because those are the numbers that I have seen in my 
> benchmarks.
I think this number depends on whether or not the instantiations are 
being re-used, and these measurements are the typical range assuming 
thei instantiations are not being reused; is that correct?
>
> Which reminds me that I would still be interested to see benchmarks where
> the JCas cache actually helps.  For if there are none, we should disable
> it by default.
It would seem to help only in the case where things put into the CAS 
were subsequently fetched out of the CAS using iterators, where both 
were using the JCas.  If you put things into the CAS using the JCas, but 
iterated them out (how's that for verbing... ;-) without using JCas, 
then that would be a case for not using the cache. 
>
>
>>
>> I plan to change this documentation to a more in depth discussion 
>> along the lines above, and also document how to clear the cache when 
>> it's no longer needed, unless there are objections :-)
>
> I would like to leave the current paragraph exactly as it is, because it
> is short and to the point.  It tells people to benchmark their 
> application
> to see what's best for themselves.
I agree with your point of shortness; but don't want to unnecessarily 
bias people toward this if it not the more common case.  I think in the 
cases you're thinking about, people have been paying attention to tuning 
already, and have selected various optimizations to do.

-Marshall
>
> If you want to add more in-depth discussion, please put it in a footnote
> or some advanced section.  That way we don't swamp 95% of our users with
> information that they will never need.
>
> --Thilo
>
>>
>> -Marshall
>
>
>


Re: JCAS_CACHE_ENABLED documentation question

Posted by Thilo Goetz <tw...@gmx.de>.
Marshall Schor wrote:
> The documentation for this says:
> 
> "The JCas cache ... incurs a steep memory overhead".  I think the actual 
> number is ~1.5 * size-of-a-java-reference (4 bytes on a 32 bit java), 
> per JCas object, plus the overhead of holding on to the actual JCas 
> cover instances longer than needed.  This latter item I think dominates 
> the storage usage.

We can replace "steep memory overhead" by "20-40% CAS memory overhead" if
you like, because those are the numbers that I have seen in my benchmarks.

Which reminds me that I would still be interested to see benchmarks where
the JCas cache actually helps.  For if there are none, we should disable
it by default.

> 
> I plan to change this documentation to a more in depth discussion along 
> the lines above, and also document how to clear the cache when it's no 
> longer needed, unless there are objections :-)

I would like to leave the current paragraph exactly as it is, because it
is short and to the point.  It tells people to benchmark their application
to see what's best for themselves.

If you want to add more in-depth discussion, please put it in a footnote
or some advanced section.  That way we don't swamp 95% of our users with
information that they will never need.

--Thilo

> 
> -Marshall