[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] FYI: Implemented an ObjectPool
From: |
Roman Kennke |
Subject: |
Re: [cp-patches] FYI: Implemented an ObjectPool |
Date: |
Fri, 01 Jul 2005 15:14:04 +0200 |
Hi,
> > I implemented and added an ObjectPool class.
>
> 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.
I completely agree with you that ideally this should be done in the GC.
This is why I hestitate to actually introduce some 'optimizations'. I
don't know about the current situation in free VMs Garbage Collectors
and how the impact would be. It would be helpful if some VM hackers
could comment on the issue.
> Please make it really easy to turn on/off caching so people can do real
> measurements of the performance impact.
I have added a flag in the ObjectPool that can turn off the cache. As
well as some counters that count how many objects are
requested/returned/created/pooled. This is not a very clever benchmark,
since it does not actually measure performance (time-wise).
> And only introduce it when it is
> a clear win.
Seeing that it is quite difficult to find the right spots where objects
should actually be returned into the pool, I strongly hesitate now to
introduce anything.
> 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.
I won't. It would be nice if some folks would play a little and comment
on this issue. Note that the pool isn't actually in use in Classpath, it
only sits around now for testing. I committed the following changes that
could help benchmarking:
2005-07-01 Roman Kennke <address@hidden>
* gnu/classpath/ObjectPool.java:
Introduced flag for turning on/off caching.
(getInstance): Synchronized access to this method.
(borrowObject): Synchronized access to the pool.
Added some benchmarking statements.
(returnObject): Synchronized access to the pool.
Added some benchmarking statements.
(createObject): Synchronized access to the pool.
Added some benchmarking statements.
(printStats): New method. Prints out some stats about the pool
usage.
/Roman
ObjectPool3.diff
Description: Text Data