cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylv...@apache.org>
Subject Re: VERY odd exceptions...
Date Tue, 25 May 2004 12:15:58 GMT
Gianugo Rabellino wrote:

>
> On May 25, 2004, at 1:30 PM, Pier Fumagalli wrote:
>
>> On 25 May 2004, at 11:22, Ugo Cei wrote:
>>
>>> Pier Fumagalli wrote:
>>>
>>>>
>>>> I seriously think (I can't see it but can definitely smell it) that 
>>>> it  happens because one of those handlers (somehow) gets recycled, 
>>>> and it's  reused before it's actually fully disposed...
>>>> So, I _seriously_ think that by fixing the problem adding the  
>>>> appropriate synchronizations, we'll not solve a deeper bug 
>>>> somewhere in  the pools...
>>>
>>>
>>> I am more and more inclined to think that pooling is harmful more 
>>> than it is useful. Components shouldn't be pooled by default, only 
>>> on special occasions and after careful consideration. Apparently, 
>>> doing a bug-free pool is harder than it seems.
>>
>>
>> Oh, well... I totally agree with you on this... Especially since the 
>> JVMs got quite a lot faster in the last few years... Pooling JDBC 
>> connections is one thing, pooling random objects another.
>
>
> But, again, you should consider that in quite a few occasions you're 
> pooling coonfigured & initialized objects. It's not just creation 
> overhead: at times configuration can be a complex beast to manage, 
> leading to heavy processing times.


That's a very bad side effect of Avalon, which pratically requires most 
non thread-safe objects to be poolable because of the object setup 
overhead. And this setup phase is exactly the same for each created 
instance, which is nothing but waste of CPU.

You can read "Alternatives to Poolable" [1] where I discussed this and 
proposed "component fields", which I admit to be rather a workaround 
than a real solution. The real solution is certainly to avoid 
non-treadsafe components as much as possible by using factory patterns 
like JAXP's Template/Transformer as outlined by Pier.

When designing components, it should be fairly easy to identify stateful 
services and then provide the actual service through instances created 
by a factory. Notice also that nothing prevents the factory to actually 
use an internal pool if needed. But only _if_ needed.

[1] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=107640905422462&w=2

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Mime
View raw message