Well, if you are pooling fine grained objects you should not
use java.util.LinkedList to implement the pool. Whenever you
add an element to a LinkedList you are creating an auxiliary
Entry object, with fields `element', `next', and `previous'.
To do pooling of fine grained objects you should add a `next'
field to the objects you are pooling and use your own linked
list implementation. Otherwise you are trading the creation of
pooled objects by the creation of Entry objects plus the
sychronization cost. Not a good deal.
Some time ago I had to optimize critical-path code and a pool
of fine-grained objects (linked together by a `next' field within
each object) was very useful.
Cheers,
Francisco
On Wed, 11 Sep 2002, David Jencks wrote:
> Pooling is mostly useful if the object holds an expensive resource such as
> a database connection. For just plain data I think the synchronization
> costs of pooling things tend to outweigh the construction costs of making
> new ones pretty quickly. Ole recently removed the (pooled) TxCapsule in
> favor of new-each-time TransactionImpl for this reason.
>
> Your results are fun to contemplate, though.
>
> david jencks
>
> On 2002.09.10 23:59:40 -0400 Bill Burke wrote:
> > I was looking into pooling Invocation objects so I thought I'd test to
> > see
> > if it is actually better. With this test case, its about 4% faster to
> > pool
> > on JDK 1.3.1 Win2k.
> >
> > With JDK 1.4.0 on Win2k, Non-pooling is actually 7% faster!!!!!
> >
> > import java.util.*;
> >
> >
> > public class testpool
> > {
> > HashMap trans;
> > HashMap as;
> > HashMap pay;
> >
> > public testpool()
> > {
> > trans = new HashMap();
> > as = new HashMap();
> > pay = new HashMap();
> > }
> > public void clear()
> > {
> > trans.clear();
> > as.clear();
> > pay.clear();
> > }
> >
> > public void addStuff()
> > {
> > for (int i = 0; i < 5; i++)
> > {
> > trans.put(new Integer(i), new Integer(i));
> > as.put(new Integer(i), new Integer(i));
> > pay.put(new Integer(i), new Integer(i));
> > }
> > }
> >
> > public static LinkedList pool = new LinkedList();
> >
> > public static void main(String[] args)
> > {
> > long start;
> > long end;
> >
> > System.out.println("testing non pool");
> > start = System.currentTimeMillis();
> > for (int i = 0; i < 1000000; i++)
> > {
> > testpool p = new testpool();
> > p.addStuff();
> > }
> > end = System.currentTimeMillis() - start;
> > System.out.println("time: " + end);
> >
> > System.out.println("testing pool");
> > start = System.currentTimeMillis();
> > for (int i = 0; i < 1000000; i++)
> > {
> > testpool p = null;
> > if (pool.isEmpty()) p = new testpool();
> > else
> > {
> > synchronized(pool)
> > {
> > p = (testpool)pool.removeFirst();
> > }
> > }
> > if (p == null) p = new testpool();
> >
> > p.addStuff();
> > p.clear();
> > synchronized(pool)
> > {
> > pool.add(p);
> > }
> > }
> > end = System.currentTimeMillis() - start;
> > System.out.println("time: " + end);
> > }
> > }}
> >
> >
> >
> > -------------------------------------------------------
> > In remembrance
> > www.osdn.com/911/
> > _______________________________________________
> > Jboss-development mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jboss-development
> >
> >
>
>
> -------------------------------------------------------
> In remembrance
> www.osdn.com/911/
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development
>
-------------------------------------------------------
In remembrance
www.osdn.com/911/
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development