#105 Entity Instances are never Pooled

v3.0 Rabbit Hole
closed-fixed
Vincent Harcq
9
2001-12-23
2001-12-04
Vincent Harcq
No

I try here as this receives no attention on jboss-dev .
Version : JBoss 2.4.4
The Pool of any entity containers is always empty.
This imply that heavy setEntityContext are run for
Home methods calls.
Whenever I call a home method on an entity bean a new
instance of the entity is created.
I could solve that by pushing back the context to the
pool in EntityInstanceInterceptor.invokeHome.
This requires change to AbstractInstanceCache and
EntityCache.

====================================================

diff -r1.9.6.2 EntityInstancePool.java
15a16
> import org.jboss.logging.Logger;
61a63
> //Logger.debug("Free
instance:"+"#ID="+ctx.getId()
+"#TRANS="+ctx.getTransaction()
+"#RECLAIM="+reclaim+"#CLASS="+getContainer
().getBeanClass());
66c68,69
< if (reclaim) super.free(ctx);
---
> // why ? if (reclaim)
> super.free(ctx);

====================================================

diff -r1.9.6.3 AbstractInstancePool.java
134c134
< //DEBUG Logger.debug("Get
instance "+this);
---
> //Logger.debug("Get
instance "+this+"#"+pool.empty()+"#"+getContainer
().getBeanClass());
166c166
< //DEBUG Logger.debug("Free
instance:"+ctx.getId()+"#"+ctx.getTransaction());
---
> //Logger.debug(maxSize+" Free
instance:"+this+"#"+ctx.getId()+"#"+ctx.getTransaction
()+"#"+reclaim+"#"+getContainer().getBeanClass());
174c174,175
< if (this.reclaim)
---
> if ( this.reclaim
> || (ctx.getId() == null &&
ctx.getTransaction() == null) )

====================================================

This is a performance problem when doing for example
jndi lookup (yes even when caching home interfaces in
a singleton map)
I am quite sure this problem did not exist in previous
version.

As this touch important files, I will not go and
implement that on cvs without further looks from
experts.

Discussion

1 2 > >> (Page 1 of 2)
  • Bill Burke
    Bill Burke
    2001-12-04

    Logged In: YES
    user_id=176497

    Entity pooling was removed on purpose. It was buggy. Some
    work needs to be done before it can be turned back on like
    ensure that nobody has a reference to an EntityContext when
    it gets thrown into the pool. This will not be addressed
    in 2.4, I'm moving this bug to 3.0.

     
  • Bill Burke
    Bill Burke
    2001-12-04

    • milestone: 143726 --> v3.0 Rabbit Hole
     
  • Vincent Harcq
    Vincent Harcq
    2001-12-04

    Logged In: YES
    user_id=125677

    Thanks for your time.
    I understand that a context can not be back to the pool
    when it has an Id associated with it, I even don't see how
    this can be implemented inside the entity interceptorS
    chain, it can only be done at end of transaction.
    But for a Home method (no id) with no transaction, the get
    is synchronized, a pop() is made, the Stack is so emptied
    so I could not see how such a context could be associated
    to 2 clients.
    I don't feel strongly right in what I am saying, ignore me
    then.
    Though I have test that solution (multiple clients doing
    finders in parallel) and it never breaks...

     
  • Vincent Harcq
    Vincent Harcq
    2001-12-04

    Logged In: YES
    user_id=125677

    hum i am not telling you what to do of course, you are the
    boss, just suggesting this. Because it helps me a lot
    maybe it could help somebody else. That's the main reason
    I am posting bugs here.
    In these stress times, I guess this message worth some
    euros :-)

     
  • Vincent Harcq
    Vincent Harcq
    2001-12-04

    Logged In: YES
    user_id=125677

    hum i am not telling you what to do of course, you are the
    boss, just suggesting this. Because it helps me a lot
    maybe it could help somebody else. That's the main reason
    I am posting bugs here.
    In these stress times, I guess this message worth some
    euros :-)

     
  • Bill Burke
    Bill Burke
    2001-12-04

    Logged In: YES
    user_id=176497

    Entity pooling is configurable, but not through xml.

    ((EntityInstancePool)container.getInstancePool
    ()).setReclaim(true);

    The multi-instance interceptors use this.

     
  • Vincent Harcq
    Vincent Harcq
    2001-12-04

    Logged In: YES
    user_id=125677

    ....wait a minute I forgot one file, me stupid idiot :

    diff -r1.30.2.5 EntityInstanceInterceptor.java
    175a176
    > container.getInstancePool().free(ctx);

    It is in invokeHome() just before the return.
    You should better understand where I want to go : have a
    pool for home methods that is reusable for other home
    methods that does not run inside a transaction.
    In summary, I come from the well known fact that 95% of all
    entity accesses are read only on "database", I tried to
    fine tuned that on "entity beans".

     
  • marc fleury
    marc fleury
    2001-12-06

    Logged In: YES
    user_id=174548

    Vincent,

    This is meant this way the pooling of entities is a pain in
    the ass from a design standpoint, we never know what is what
    and what is where and the reuse of the instances was the
    source of so many problems we did away.

    THAT BEING SAID, the creation of big instances can be a
    killer in terms of performance

    THE PROPOSED SOLUTION IS THIS, the reuse is dead, and is not
    going back in, just a killer from design and testing for the
    locking (was the source of too many problems in locking),
    BUT THE WAY TO MAKE THIS WORK is to make sure that the pools
    are always at a minimum size and enforce the minimum value,
    I would also do that in a separate thread.

    Example:

    A thread monitors the "size of the pool" and how many
    instance are in there, if the value is below the minimum,
    still in that thread, double the number, ex: minimum is set
    to 5, we start at 10, we use 5 of them, the thread that
    monitors this picks it up and creates 5 extra ones trying to
    bring it back to 10. Something like that, should be very
    simple to implement.

    Can you do it?

     
  • Vincent Harcq
    Vincent Harcq
    2001-12-06

    Logged In: YES
    user_id=125677

    Clear.
    I will do that.
    I come back right here with results.
    Thank you.

     
  • Vincent Harcq
    Vincent Harcq
    2001-12-08

    Logged In: YES
    user_id=125677

    I have it working on 2.4
    Some remarks though:
    - The goal is 3.0.
    - I need changes in jboss xml : maxsize and minsize need
    to be replaced by size, increment and period.
    - In a longer term I think the pool need to configure
    itself when it sees its parameters are too low (or too big)
    - The mixing of a unique pool for home and instance is
    maybe not a good thing for entity bean.

    - At the same time it is "only" the pool ;) the cache will
    be more tricky for performance now.

    Let's see Jboss 3.0 now...

     
1 2 > >> (Page 1 of 2)