Re: [JBoss-dev] loading 10 EBs takes 5s 1st time called (2 bugs in org.jboss.proxy.Proxies.Impl)

2001-11-29 Thread Peter Levart

On Wednesday 28 November 2001 17:10, Peter Levart wrote:
> On Wednesday 28 November 2001 12:49, Dain Sundstrom wrote:
> > >
> > > My use of the proxy generator is obviously broken.  I'll look
> > > at it after
> > > some sleep.
>
> Good morning!
>
> It might be that your use of the proxy generator is not broken at all but
> the generator itself is.

I checked the corrected proxy generator with your old code (before you 
applied your patch) and it works correctly. Your use of proxy generator 
is/was not broken. It might be a small performance gain to cache the 
constructor for the beans but a very small one.

Peter

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



Re: [JBoss-dev] loading 10 EBs takes 5s 1st time called (2 bugs in org.jboss.proxy.Proxies.Impl)

2001-11-28 Thread Peter Levart

On Wednesday 28 November 2001 12:49, Dain Sundstrom wrote:
> I fixed this one.
>
> In the startup code I generate one bean the old way
> (Proxy.newProxyInstance), and then I steal the constructor from the
> generated object.  Then when a new bean instance is requested, I just use
> the constructor.
>

> > >
> > > It appears that each instance of the Bean is created with a
> > > different Class
> > > instance using different instance of the ClassLoader. Is this
> > > on purpose?
> > > Wouldn't it be better to use the same Class?
> >
> > You would think so.
> >
> > My use of the proxy generator is obviously broken.  I'll look
> > at it after
> > some sleep.

Good morning!

It might be that your use of the proxy generator is not broken at all but the 
generator itself is. There's a method in the inner static class 
org.jboss.proxy.Proxies.Impl that claims this:

  // do the arrays have the same elements?
  // (duplication and reordering are ignored)
  static boolean sameTypes(Class tt1[], Class tt2[])

...but in fact some tests of this method reveal quite the opposite:

[Object, Serializable] == [Serializable, Object]: false
[Object, Serializable, Object] == [Object, Serializable, Object]: false
[Object] == [Object]: false
[Object] == [Object, Serializable]: true
[Object] == []: Exception in thread "main" 
java.lang.ArrayIndexOutOfBoundsException

There are two bugs in this method. Can you spot them?
:
:... the answer is below...
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
... the first line of the method is:

if (tt1.length == 1 && tt2.length == 0)

... but should be:

if (tt1.length == 1 && tt2.length == 1)

... the last line of the method is:

return totalSeen2 != tt2.length;

... but should be:

return totalSeen2 == tt2.length;


With corrections applied, the tests return:

[Object, Serializable] == [Serializable, Object]: true
[Object, Serializable, Object] == [Object, Serializable, Object]: true
[Object] == [Object]: true
[Object] == [Object, Serializable]: false
[Object] == []: false


I think that some other parts of the JBoss would benefit from this patch :-)


Regards, Peter

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



RE: [JBoss-dev] loading 10 EBs takes 5s 1st time called

2001-11-28 Thread Dain Sundstrom

I fixed this one.

In the startup code I generate one bean the old way
(Proxy.newProxyInstance), and then I steal the constructor from the
generated object.  Then when a new bean instance is requested, I just use
the constructor.

I ran two sets of test cases and here is what I got: 

Relation test [4 runs in sec]
old: 28 21 20 20 21
new: 22 14 12 11 11

Commerce test [4 runs in sec]
old: 22 12 10 10  9
new: 15  9  7  7  6

Tell me what you see.  Run the profiler again.

Warning: I have made a lot of changes, so I may have broken something else. 

If none of this makes sense, I apologize.  I need to sleep now.

-dain

> -Original Message-
> From: Dain Sundstrom [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, November 28, 2001 3:46 AM
> To: 'Peter Levart'; Dain Sundstrom; 
> [EMAIL PROTECTED]
> Subject: RE: [JBoss-dev] loading 10 EBs takes 5s 1st time called
> 
> 
> > 
> > On Tuesday 13 November 2001 16:49, Dain Sundstrom wrote:
> > > >
> > > > The first time I reference let's say 10 Entity Beans after a
> > > > JBoss restart it
> > > > takes approx. 5 seconds to retrieve data from them. The
> > > > second and subsequent
> > > > requests to return data from the same 10 EBs take ~20ms. 
> > >
> > > I was curious also, so I re-ran my test.  The second run 
> > always takes
> > > slightly less time ~1-2 sec.  The only thing I can think 
> of that is
> > > different in the first execution is the bytecode generator. 
> >  On my machine,
> > > a 1.4 athalon, it doesn't take anywhere 1/2 second per 
> > bean.  I really
> > > haven't been focusing on this type of optimization, but I 
> > can easily add a
> > > line to the init or start method that creates an instance 
> > of the bean. 
> > > Then it will only happen during setup.  I look at it after 
> > the example code
> > > done (later today).
> > >
> > 
> > JProbe is really a nice tool. 
> > 
> > It appears that most of the time is spent by my bean calling 
> > Introspector.getBeanInfo(getClass()). I'm using introspection 
> > to collect the 
> > data from the EB. A single call to getBeanInfo() produces 
> > around 500 calls 
> > for ClassLoader.findClass() that in turn scan the filesystem 
> > for class files. 
> > Why is that so I don't know. Introspection is known to be 
> > slow but I didn't 
> > know that it can be of such a varying speed. getBeanInfo() on 
> > a simple Object 
> > subclass is quite fast. Not so on a JBoss generated subclass 
> > (proxy) of an EB 
> > class.
> > 
> > The other thing that was shown is that getBeanInfo() is fast 
> > the second time 
> > called on a particular Class, so this overhead should only be 
> > visible the 
> > first time called for a particular Entity type, but it is 
> > visible the first 
> > time called for a particular Bean instance regardless of 
> > Entity type. The 
> > only conclusion is therefore that each Bean instance (even 
> > though of the same 
> > type) is of different Class despite your claims that it is not.
> > 
> > The proof: This happens when accessing 3 instances of the 
> > same type using 
> > Introspector.getBeanInfo(getClass()) in the Bean's method:
> > 
> > Obtaining BeanInfo for class: class 
> > com.select.zaznamki.ejb.CustomerBean$Proxy, class.hashCode: 
> 7674526, 
> > classLoader: org.jboss.proxy.ProxyCompiler$Runtime@651e95, 
> > classLoader.hashCode: 6626965
> > Obtaining BeanInfo took 985 milliseconds.
> > 
> > Obtaining BeanInfo for class: class 
> > com.select.zaznamki.ejb.CustomerBean$Proxy, class.hashCode: 
> 3724384, 
> > classLoader: org.jboss.proxy.ProxyCompiler$Runtime@42fcc, 
> > classLoader.hashCode: 274380
> > Obtaining BeanInfo took 311 milliseconds.
> > 
> > Obtaining BeanInfo for class: class 
> > com.select.zaznamki.ejb.CustomerBean$Proxy, class.hashCode: 
> 6004549, 
> > classLoader: org.jboss.proxy.ProxyCompiler$Runtime@6c5356, 
> > classLoader.hashCode: 7099222
> > Obtaining BeanInfo took 305 milliseconds.
> > 
> > 
> > It appears that each instance of the Bean is created with a 
> > different Class 
> > instance using different instance of the ClassLoader. Is this 
> > on purpose? 
> > Wouldn't it be better to use the same Class?
> 
> You would think so.  
> 
> My use of the proxy generator is obviously broken.  I'll look 
> at it after
> some sleep.
> 
> -dain
> 
> ___
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development
> 

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



RE: [JBoss-dev] loading 10 EBs takes 5s 1st time called

2001-11-28 Thread Dain Sundstrom

> 
> On Tuesday 13 November 2001 16:49, Dain Sundstrom wrote:
> > >
> > > The first time I reference let's say 10 Entity Beans after a
> > > JBoss restart it
> > > takes approx. 5 seconds to retrieve data from them. The
> > > second and subsequent
> > > requests to return data from the same 10 EBs take ~20ms. 
> >
> > I was curious also, so I re-ran my test.  The second run 
> always takes
> > slightly less time ~1-2 sec.  The only thing I can think of that is
> > different in the first execution is the bytecode generator. 
>  On my machine,
> > a 1.4 athalon, it doesn't take anywhere 1/2 second per 
> bean.  I really
> > haven't been focusing on this type of optimization, but I 
> can easily add a
> > line to the init or start method that creates an instance 
> of the bean. 
> > Then it will only happen during setup.  I look at it after 
> the example code
> > done (later today).
> >
> 
> JProbe is really a nice tool. 
> 
> It appears that most of the time is spent by my bean calling 
> Introspector.getBeanInfo(getClass()). I'm using introspection 
> to collect the 
> data from the EB. A single call to getBeanInfo() produces 
> around 500 calls 
> for ClassLoader.findClass() that in turn scan the filesystem 
> for class files. 
> Why is that so I don't know. Introspection is known to be 
> slow but I didn't 
> know that it can be of such a varying speed. getBeanInfo() on 
> a simple Object 
> subclass is quite fast. Not so on a JBoss generated subclass 
> (proxy) of an EB 
> class.
> 
> The other thing that was shown is that getBeanInfo() is fast 
> the second time 
> called on a particular Class, so this overhead should only be 
> visible the 
> first time called for a particular Entity type, but it is 
> visible the first 
> time called for a particular Bean instance regardless of 
> Entity type. The 
> only conclusion is therefore that each Bean instance (even 
> though of the same 
> type) is of different Class despite your claims that it is not.
> 
> The proof: This happens when accessing 3 instances of the 
> same type using 
> Introspector.getBeanInfo(getClass()) in the Bean's method:
> 
> Obtaining BeanInfo for class: class 
> com.select.zaznamki.ejb.CustomerBean$Proxy, class.hashCode: 7674526, 
> classLoader: org.jboss.proxy.ProxyCompiler$Runtime@651e95, 
> classLoader.hashCode: 6626965
> Obtaining BeanInfo took 985 milliseconds.
> 
> Obtaining BeanInfo for class: class 
> com.select.zaznamki.ejb.CustomerBean$Proxy, class.hashCode: 3724384, 
> classLoader: org.jboss.proxy.ProxyCompiler$Runtime@42fcc, 
> classLoader.hashCode: 274380
> Obtaining BeanInfo took 311 milliseconds.
> 
> Obtaining BeanInfo for class: class 
> com.select.zaznamki.ejb.CustomerBean$Proxy, class.hashCode: 6004549, 
> classLoader: org.jboss.proxy.ProxyCompiler$Runtime@6c5356, 
> classLoader.hashCode: 7099222
> Obtaining BeanInfo took 305 milliseconds.
> 
> 
> It appears that each instance of the Bean is created with a 
> different Class 
> instance using different instance of the ClassLoader. Is this 
> on purpose? 
> Wouldn't it be better to use the same Class?

You would think so.  

My use of the proxy generator is obviously broken.  I'll look at it after
some sleep.

-dain

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



Re: [JBoss-dev] loading 10 EBs takes 5s 1st time called

2001-11-28 Thread Peter Levart

On Tuesday 13 November 2001 16:49, Dain Sundstrom wrote:
> >
> > The first time I reference let's say 10 Entity Beans after a
> > JBoss restart it
> > takes approx. 5 seconds to retrieve data from them. The
> > second and subsequent
> > requests to return data from the same 10 EBs take ~20ms. 
>
> I was curious also, so I re-ran my test.  The second run always takes
> slightly less time ~1-2 sec.  The only thing I can think of that is
> different in the first execution is the bytecode generator.  On my machine,
> a 1.4 athalon, it doesn't take anywhere 1/2 second per bean.  I really
> haven't been focusing on this type of optimization, but I can easily add a
> line to the init or start method that creates an instance of the bean. 
> Then it will only happen during setup.  I look at it after the example code
> done (later today).
>

JProbe is really a nice tool. 

It appears that most of the time is spent by my bean calling 
Introspector.getBeanInfo(getClass()). I'm using introspection to collect the 
data from the EB. A single call to getBeanInfo() produces around 500 calls 
for ClassLoader.findClass() that in turn scan the filesystem for class files. 
Why is that so I don't know. Introspection is known to be slow but I didn't 
know that it can be of such a varying speed. getBeanInfo() on a simple Object 
subclass is quite fast. Not so on a JBoss generated subclass (proxy) of an EB 
class.

The other thing that was shown is that getBeanInfo() is fast the second time 
called on a particular Class, so this overhead should only be visible the 
first time called for a particular Entity type, but it is visible the first 
time called for a particular Bean instance regardless of Entity type. The 
only conclusion is therefore that each Bean instance (even though of the same 
type) is of different Class despite your claims that it is not.

The proof: This happens when accessing 3 instances of the same type using 
Introspector.getBeanInfo(getClass()) in the Bean's method:

Obtaining BeanInfo for class: class 
com.select.zaznamki.ejb.CustomerBean$Proxy, class.hashCode: 7674526, 
classLoader: org.jboss.proxy.ProxyCompiler$Runtime@651e95, 
classLoader.hashCode: 6626965
Obtaining BeanInfo took 985 milliseconds.

Obtaining BeanInfo for class: class 
com.select.zaznamki.ejb.CustomerBean$Proxy, class.hashCode: 3724384, 
classLoader: org.jboss.proxy.ProxyCompiler$Runtime@42fcc, 
classLoader.hashCode: 274380
Obtaining BeanInfo took 311 milliseconds.

Obtaining BeanInfo for class: class 
com.select.zaznamki.ejb.CustomerBean$Proxy, class.hashCode: 6004549, 
classLoader: org.jboss.proxy.ProxyCompiler$Runtime@6c5356, 
classLoader.hashCode: 7099222
Obtaining BeanInfo took 305 milliseconds.


It appears that each instance of the Bean is created with a different Class 
instance using different instance of the ClassLoader. Is this on purpose? 
Wouldn't it be better to use the same Class?


Peter

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



RE: [JBoss-dev] loading 10 EBs takes 5s 1st time called

2001-11-13 Thread Dain Sundstrom

Well, I'm not focusing on this kind of optimization currently, and it takes
approximately 1s to access  20 beans on my machine.  Down the road, I'll
profile the code.

-dain

> -Original Message-
> From: Tim Fox [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 13, 2001 10:27 AM
> To: Dain Sundstrom; 'Peter Levart'; 
> [EMAIL PROTECTED]
> Subject: RE: [JBoss-dev] loading 10 EBs takes 5s 1st time called
> 
> 
> Have you thought of profiling the code to determine what's 
> taking so long?
> 
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf
> > Of Dain Sundstrom
> > Sent: 13 November 2001 15:49
> > To: 'Peter Levart'; [EMAIL PROTECTED]
> > Subject: RE: [JBoss-dev] loading 10 EBs takes 5s 1st time called
> >
> >
> > > Hello!
> > >
> > > I just wanted to know if somebody has a straight answer. I'm
> > > using JBoss 3.0
> > > alpha with CMP 2.0.
> > >
> > > The first time I reference let's say 10 Entity Beans after a
> > > JBoss restart it
> > > takes approx. 5 seconds to retrieve data from them. The
> > > second and subsequent
> > > requests to return data from the same 10 EBs take ~20ms. If I
> > > later request
> > > data from some other 10 EBs for the first time it takes
> > > another 5 seconds.
> > > I'm using commit option B. I watched the SQL that gets sent
> > > to database
> > > (using Sybase's "ribo") and it is the same SQL sequence for
> > > the 1st time as
> > > for the 2nd and subsequent requests, so this overhead is 
> not from the
> > > database.
> > >
> > > I'm just curious what takes it so long (1/2 second for an EB)
> > > the first time
> > > the EB's data is referenced. Is this the time it takes to
> > > create new instance
> > > in the pool of EBs? Will this overhead go away after some
> > > time of running
> > > when the number of instances reaches the pool's limit?
> > >
> > > What I wanted to know is what is happening behind the scenes
> > > (I read from
> > > time to time on this list about dynamic bytecode generation
> > > and similar but I
> > > thought this was only used to create Proxies...).
> > >
> >
> > I was curious also, so I re-ran my test.  The second run 
> always takes
> > slightly less time ~1-2 sec.  The only thing I can think of that is
> > different in the first execution is the bytecode generator.  On
> > my machine,
> > a 1.4 athalon, it doesn't take anywhere 1/2 second per 
> bean.  I really
> > haven't been focusing on this type of optimization, but I 
> can easily add a
> > line to the init or start method that creates an instance of the
> > bean.  Then
> > it will only happen during setup.  I look at it after the example
> > code done
> > (later today).
> >
> > -dain
> >
> > ___
> > Jboss-development mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jboss-development
> >
> 
> 
> ___
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development
> 

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



RE: [JBoss-dev] loading 10 EBs takes 5s 1st time called

2001-11-13 Thread Tim Fox

Have you thought of profiling the code to determine what's taking so long?

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf
> Of Dain Sundstrom
> Sent: 13 November 2001 15:49
> To: 'Peter Levart'; [EMAIL PROTECTED]
> Subject: RE: [JBoss-dev] loading 10 EBs takes 5s 1st time called
>
>
> > Hello!
> >
> > I just wanted to know if somebody has a straight answer. I'm
> > using JBoss 3.0
> > alpha with CMP 2.0.
> >
> > The first time I reference let's say 10 Entity Beans after a
> > JBoss restart it
> > takes approx. 5 seconds to retrieve data from them. The
> > second and subsequent
> > requests to return data from the same 10 EBs take ~20ms. If I
> > later request
> > data from some other 10 EBs for the first time it takes
> > another 5 seconds.
> > I'm using commit option B. I watched the SQL that gets sent
> > to database
> > (using Sybase's "ribo") and it is the same SQL sequence for
> > the 1st time as
> > for the 2nd and subsequent requests, so this overhead is not from the
> > database.
> >
> > I'm just curious what takes it so long (1/2 second for an EB)
> > the first time
> > the EB's data is referenced. Is this the time it takes to
> > create new instance
> > in the pool of EBs? Will this overhead go away after some
> > time of running
> > when the number of instances reaches the pool's limit?
> >
> > What I wanted to know is what is happening behind the scenes
> > (I read from
> > time to time on this list about dynamic bytecode generation
> > and similar but I
> > thought this was only used to create Proxies...).
> >
>
> I was curious also, so I re-ran my test.  The second run always takes
> slightly less time ~1-2 sec.  The only thing I can think of that is
> different in the first execution is the bytecode generator.  On
> my machine,
> a 1.4 athalon, it doesn't take anywhere 1/2 second per bean.  I really
> haven't been focusing on this type of optimization, but I can easily add a
> line to the init or start method that creates an instance of the
> bean.  Then
> it will only happen during setup.  I look at it after the example
> code done
> (later today).
>
> -dain
>
> ___
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development
>


___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



RE: [JBoss-dev] loading 10 EBs takes 5s 1st time called

2001-11-13 Thread Dain Sundstrom

> Hello!
> 
> I just wanted to know if somebody has a straight answer. I'm 
> using JBoss 3.0 
> alpha with CMP 2.0.
> 
> The first time I reference let's say 10 Entity Beans after a 
> JBoss restart it 
> takes approx. 5 seconds to retrieve data from them. The 
> second and subsequent 
> requests to return data from the same 10 EBs take ~20ms. If I 
> later request 
> data from some other 10 EBs for the first time it takes 
> another 5 seconds. 
> I'm using commit option B. I watched the SQL that gets sent 
> to database 
> (using Sybase's "ribo") and it is the same SQL sequence for 
> the 1st time as 
> for the 2nd and subsequent requests, so this overhead is not from the 
> database.
> 
> I'm just curious what takes it so long (1/2 second for an EB) 
> the first time 
> the EB's data is referenced. Is this the time it takes to 
> create new instance 
> in the pool of EBs? Will this overhead go away after some 
> time of running 
> when the number of instances reaches the pool's limit?
> 
> What I wanted to know is what is happening behind the scenes 
> (I read from 
> time to time on this list about dynamic bytecode generation 
> and similar but I 
> thought this was only used to create Proxies...).
> 

I was curious also, so I re-ran my test.  The second run always takes
slightly less time ~1-2 sec.  The only thing I can think of that is
different in the first execution is the bytecode generator.  On my machine,
a 1.4 athalon, it doesn't take anywhere 1/2 second per bean.  I really
haven't been focusing on this type of optimization, but I can easily add a
line to the init or start method that creates an instance of the bean.  Then
it will only happen during setup.  I look at it after the example code done
(later today).

-dain

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development