0

ZK 5 auto-wiring, after-compose running slow and slower, bug/memory leakage?

asked 2010-04-26 08:14:45 +0800

juwian gravatar image juwian
96 1 3

ZK 5.01 (in a spring 3 environment) seems very slow, as well as have some major issues (result of some kind of memory leakage?) when utilizing controllers that extend Window and implement AfterCompose in order to make use of auto-wiring of variables and events for components in a underlying zul-page in which annotated data-bindings are used extensively.

In an abstract controller that implements AfterCompose (and extends Window) I've got:

@Override
public void afterCompose() {
  Components.wireVariables(this, this);
  Components.addForwards(this, this);
}


For every request for any ZUL-page (that is using a controller extending the abstract controller mentioned above) this very method "afterCompose" takes more and more time to execute. The question is why.

I've done some TPTP profiling and the application service layer is not a bottle-neck, but rather "afterCompose()" as well as bsh (beanshell - seems to consume huge amounts of time for parsing and interpreting) and EHCache (DiskStore.throwableSafeFlushSpoolIfRequired())

I monitored afterCompose for a series of requests for a ZUL page and the execution-time for "afterCompose" seems to double for every request for the ZUL-page!

Something is seriously wrong here.. Memory leakage? Thread syncronizations? Is beanshell involved, something there which is messed up? And why is the auto-wiring in ZK 5 so slow even initially?

The ZUL-pages are all pretty simple, some with only one listbox and some buttons, others with 10-20 fields, it's not reasonable that wiring any of these pages should cost 3-4 seconds at best, and 15-50 seconds at worst! (i.e., it takes longer and longer time to load any ZUL page for every request made, and it is not the application service that is getting slower..but ZK..beanshell..afterCompose)

Any ideas?

delete flag offensive retag edit

40 Replies

Sort by ยป oldest newest

answered 2011-09-02 04:37:10 +0800

ashishd gravatar image ashishd flag of Taiwan
1972 6

Hi pschenke,
which ZK Spring version are you using? Please try with latest ZK Spring freshly and see if this problem is still occuring. Thanks.

link publish delete flag offensive edit

answered 2011-09-02 04:08:49 +0800

pschenke gravatar image pschenke
12

updated 2011-09-02 04:09:21 +0800

i seem to be running into this problem with zk 5.0.7 now.
any progress or means to avoid it?

most "bean not found"-messages here concern _ignoreXel and zkBindingComposer.

PS: using macro-components seems to make it even worse.

link publish delete flag offensive edit

answered 2010-11-11 09:26:52 +0800

aruggiero gravatar image aruggiero
21

Thanx ashishd it's working wonderful after i migrate to these release ;)

link publish delete flag offensive edit

answered 2010-05-20 11:49:40 +0800

ryanwong00 gravatar image ryanwong00
63 1

Hi Ashish,

Thanks a lot.

Ryan

link publish delete flag offensive edit

answered 2010-05-20 11:08:31 +0800

ashishd gravatar image ashishd flag of Taiwan
1972 6

updated 2010-05-20 11:09:43 +0800

Hi ryanwong00,
Thanks for the above test case. The root cause of why it happens is what Henri already mentioned in the previous response. If VariableResolver implementation does not have a proper hashcode() and equals() method this will cause PageImpl to see them as different instances and they will get added to test.zul PageImpl instance. I have refactored ZK Spring 1.2.0RC and ZK Spring 3.0RC variable resolver mechanism to improve performance and guard against possible memory leak. Please download latest freshly release of it here. Also this necessitated updates to all VariableResolver implementations in zkplus such as Spring DelegatingVariableResolver and JndiVariableResolver etc classes. So you probably want to use the the latest ZK Freshly containing those changes(not uploaded yet). I will notify everyone here once it is uploaded on sf.net

Thanks
- Ashish

link publish delete flag offensive edit

answered 2010-05-17 06:08:39 +0800

ryanwong00 gravatar image ryanwong00
63 1

updated 2010-05-17 06:20:48 +0800

Hi Ashish,

Please find followings for reproducing the case.

1. Assuming that all zul will be placed under /test. Then prepare a window with a button. (i.e. test.zul)

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="new page title" border="normal" id="mainwin">
	<button label="Open page A" onClick='Executions.createComponents("/test/pageA.zul", mainwin, null);'></button>
</window>
</zk>

2. Prepare a zul page (i.e. pageA.zul) with variable-resolver tag and this page will be loaded when the button of step 1 is clicked

<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<window title="PageA" border="normal" closable="true" mode="overlapped">
Page A
</window>

3. Load the test.zul and click the button several times. You will notice that the no. of "No bean named .." messages increased in every click.

For other variable resolver, since they are not like Spring that will provide trace messages, I believe that the no. of variable-resolver will still be increased every time a variable-resolver tagged page is loaded. For ease of tracking, you may consider including following code

System.out.println(this + ":" + this.hashCode() +  ":" + _resolvers.size() + ":" + _resolvers);

into PageImpl.addVariableResolver to observe the number of variable-resolvers attached to Page when variable-resolver tagged page is loaded.

Thanks
Ryan :-)

link publish delete flag offensive edit

answered 2010-05-16 22:16:33 +0800

ashishd gravatar image ashishd flag of Taiwan
1972 6

@juwian
>>However looking into the log at TRACE level I still se that ZK seems to attempt to wire Spring-managed controller(?)
fields that are not annotated for Spring Dependency Injection using @Autowired or @Resource, for example:
>>The number of DI attempts don't increase as before but there are still a basic set there.. Is this correct behavior?
Seems a bit odd to me, why attempt DI on obviously private fields that aren't annotated for Spring DI?

This is expected because Components.wireVariables(); is not Spring specific and by spec it will try to wire controller fields by name. At the moment it is not done the way you said above. Unfortunately you will have to write your custom wiring mechanism for your Spring specific needs for now. I'll appreciate if you come up with some implementation for this or throw in some ideas spec wise.
>>When however introducing the same new "zkspring-core.jar" in another real web application project of mine many things appear to fail
Appreciate if you could be more specific about failed cases/msgs. Was that working with the zkspring-security.jar that had memory leak issue?

@ryanwong00
as juwian mentioned I don't see increased number of "No bean named". Can you provide some sample code to reproduce your case?

Thanks
- Ashish

link publish delete flag offensive edit

answered 2010-05-15 03:53:28 +0800

ryanwong00 gravatar image ryanwong00
63 1

updated 2010-05-15 10:31:04 +0800

Hi Ashish/Henri,

Thanks for the updated jar. However, there are still minor issues.

All zul pages with <?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?> defined will trigger the "No bean named ..." messages, which I think is expected.
However, the "No bean named ..." messages will be cumulative within the same desktop.
Assuming I've got zul pages A, B with the above variable-resolver tag defined. When I load page A, I may get, let say, 10 messages. When I then load page B, I will get 10 + 10 messages. When I reload page B again, I will get 10 + 10 + 10,... so on and so forth. The only way to reset the increasing number of messages is to reload the whole desktop.

I think the problem is probably relating to point 2 of my previous investigation. That is, everytime a zul page with that variable-resolver tag is loaded, it will instantiate a new VariableResolver. The instance will be attached to the PageImpl of the desktop. Thus, the list of VariableResolvers will keep growing until user reload the desktop.
The degradation shall still happen but in a much slower pace and smaller scope when comparing to the previous issue.

One more thing, this cumulative variable-resolver behavior does not limit to org.zkoss.zkplus.spring.DelegatingVariableResolver. I tried <?variable-resolver class="org.zkoss.zkplus.jndi.JndiVariableResolver"?> and the JndiVariableResolver also got this behavior too.

Thanks.

Ryan :-)

link publish delete flag offensive edit

answered 2010-05-14 07:13:11 +0800

juwian gravatar image juwian
96 1 3

(I'll publish again - don't know if I'm the only one experiencing this - but the previous entry seems to float out from the frame rendering some parts unreadable..)


Especial thanks to you Ashish, raevel2 and ryanwong00 for your constributions. I'm still experiencing some issues, even though one is gone.

I downloaded "zk-spring-core-bin-3.0RC-FL-2010-05-14.zip" and had "zkspring-core.jar" replaced with new one in the earlier published project "leak".
The earlier mentioned issues with ever increasing load and execution times for the ZUL pages seems to be gone, they're more constant.

However looking into the log at TRACE level I still se that ZK seems to attempt to wire Spring-managed controller(?)
fields that are not annotated for Spring Dependency Injection using @Autowired or @Resource, for example:

[see above]

The number of DI attempts don't increase as before but there are still a basic set there.. Is this correct behavior?
Seems a bit odd to me, why attempt DI on obviously private fields that aren't annotated for Spring DI?

When however introducing the same new "zkspring-core.jar" in another real web application project of mine many things appear to fail.
Some ZUL-pages used for setting up some test entitites and then forwarding user to a another page (using Executions)
render completely white and blank, nothing in the log.

So unfortunately I cannot use the new jar solving the main issue with increating load times as
things earlier working perfect now don't.

As a side note I've tried adding the latest "zkspring-security.jar" from zk-spring-security-bin-3.0RC-FL-2010-05-14.zip",
as well as the latest relase of ZK 5.02, things seem to work fine until the new
mentioned zkspring-core.jar is added (replacing the old) - then some pages render blank.

Any ideas?

Thankful for all input!

link publish delete flag offensive edit

answered 2010-05-14 07:10:09 +0800

juwian gravatar image juwian
96 1 3

Especial thanks to you Ashish, raevel2 and ryanwong00 for your constributions. I'm still experiencing some issues, even though one is gone.

I downloaded "zk-spring-core-bin-3.0RC-FL-2010-05-14.zip" and had "zkspring-core.jar" replaced with new one in the earlier published project "leak".
The earlier mentioned issues with ever increasing load and execution times for the ZUL pages seems to be gone, they're more constant.

However looking into the log at TRACE level I still se that ZK seems to attempt to wire Spring-managed controller(?) fields that are not annotated for Spring Dependency Injection using @Autowired or @Resource, for example:

No bean named 'applicationScope' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@6d65fd: defining beans [afterComposeController,exampleController,genericForwardComposerController,springController,exampleService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor]; root of factory hierarchy
No bean named 'requestScope' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@6d65fd: defining beans [afterComposeController,exampleController,genericForwardComposerController,springController,exampleService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor]; root of factory hierarchy
No bean named 'execution' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@6d65fd: defining beans [afterComposeController,exampleController,genericForwardComposerController,springController,exampleService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor]; root of factory hierarchy
No bean named 'arg' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@6d65fd: defining beans [afterComposeController,exampleController,genericForwardComposerController,springController,exampleService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor]; root of factory hierarchy
No bean named 'param' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@6d65fd: defining beans [afterComposeController,exampleController,genericForwardComposerController,springController,exampleService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor]; root of factory hierarchy
No bean named '_separator' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@6d65fd: defining beans [afterComposeController,exampleController,genericForwardComposerController,springController,exampleService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor]; root of factory hierarchy

The number of DI attempts don't increase as before but there are still a basic set there.. Is this correct behavior? Seems a bit odd to me, why attempt DI on obviously private fields that aren't annotated for Spring DI?

When however introducing the same new "zkspring-core.jar" in another real web application project of mine many things appear to fail. Some ZUL-pages used for setting up some test entitites and then forwarding user to a another page (using Executions) render completely white and blank, nothing in the log.

So unfortunately I cannot use the new jar solving the main issue with increating load times as things earlier working perfect now don't.

As a side note I've tried adding the latest "zkspring-security.jar" from zk-spring-security-bin-3.0RC-FL-2010-05-14.zip", as well as the latest relase of ZK 5.02, things seem to work fine until the new mentioned zkspring-core.jar is added (replacing the old) - then some pages render blank.

Any ideas?

Thankful for all input!

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-04-26 08:14:45 +0800

Seen: 3,347 times

Last updated: Sep 02 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More