classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] FYI: Implemented an ObjectPool


From: Mark Wielaard
Subject: Re: [cp-patches] FYI: Implemented an ObjectPool
Date: Fri, 01 Jul 2005 14:57:02 +0200

Hi Roman,

On Fri, 2005-07-01 at 12:52 +0200, Roman Kennke wrote:
> I implemented and added an ObjectPool class. This should help improve
> performance in Swing (and other areas). In Swing we make heavy use of
> Point Dimension and Rectangle. Usually these objects are created to wrap
> some integer values and are discarded quickly. This would create
> overload for creating and garbage collecting these instances which is
> not necessary if these objects are cached.

Please measure! Don't assume that this will lead to better performance.
I do follow your reasoning. But ultimately this is the job of the
allocator/garbage collector. This cache is kind of a hint that the
objects created are small and short lived. And that is nice. But if the
garbage collector already noticed that anyway we are doing double work.

Please make it really easy to turn on/off caching so people can do real
measurements of the performance impact. And only introduce it when it is
a clear win. Since as you said it has some drawback because you have to
manually track usage patterns now.

What seems to happen a lot in larger projects is that someone introduces
some pooling/caching of certain constructs and when some implementation
detail somewhere else in the stack changes the pooling/caching isn't
revised/remeasured to see if it still makes sense (or that it actually
decreases performance given the new circumstances!).
Don't let that happen in this case.

Cheers,

Mark

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]