# GenericForwardComposer slow

xmedeko
1021 1 16
http://xmedeko.blogspot.c...

Hi, I have started using GenericForwardComposer with ZK Calendar (<calendars>) component and I have experienced a recognizable delay, when I have access the page with the ZK Calendar first time. I suspect, the auto-wiring in not very fast. Measured times on my Dual Core @2.5GHZ:

doAfterCompose: first time (just after server starts): 391ms, next time (next time the page is accessed and the controller is cerated) 188ms
between doAfterCompose and onCreate: first time: 359ms, next time 156ms

total slow down: first time: 750ms, next time: 344ms

Moreover, the "nexttime" total processing time shown by the Firebug is about 490ms, so 344/490 = 70% of the processing time taken by the auto-wiring.

I think these times are too high. The auto-wiring (and addForwards, too) should be optimized.

delete retag edit

## 17 Replies

SimonPai
1696 1

Hi xmedeko,

I think we need to do some research on this issue. Can you provide information about your environment so we can reproduce and test?

Regards,
Simon

xmedeko
1021 1 16
http://xmedeko.blogspot.c...

Hi Simon,
environment: ZK 3.6.4, JBoss 5.1, Sun JDK 1.6u18, Win XP. I am using GenericForwardComposer extensively, and only one pages takes so long, I'll try to discover, where exactly is the problem.

ashishd
1972 6

Hi xmedeko,
Do you happen to use any DelegatingVariableResolver(s) on that page? There was a similar bug wrt ZK Spring and it was fixed. Please take a look if it has something in your case.

Thanks
- Ashish

xmedeko
1021 1 16
http://xmedeko.blogspot.c...

@ashishd: Nope, I do not use spring.

@SimonPai: All the time is spent in Wire.wireOthers method. I have looked into the code of the Components class and it is not well regarding to the performance. The code should avoid any unnecessary casting, instanceof operators, string and collections operations, etc. I have tried to remove ZScriptVariables lookup from containsVariable, and it has lead to some speedup. (I do not need this feature and I guess most of the folks do not need it, too.) My version of this method:

		private boolean containsVariable(Object x, String fdname) {
//#feature 2770471 GenericAutowireComposer shall support wiring ZScript varible
if (x instanceof Page) {
final Page pg = (Page) x;
return //pg.getZScriptVariable(fdname) != null ||
pg.containsVariable(fdname);
} else {
final Component cmp = (Component) x;
//final Page page = getPage(cmp);
return //(page != null && page.getZScriptVariable(cmp, fdname) != null) ||
cmp.containsVariable(fdname, false);
}
}


Now, the auto-wiring takes approx. 140ms instead of 390. It is interesting, that the first call of the wireOthers is approx. 20ms, while the second call is 120ms. The first call is made by doAfterCompose method, while the second one by BeforeCreateWireListener hook.

xmedeko
1021 1 16
http://xmedeko.blogspot.c...

Well, I have removed the ZScriptVariables lookup from getVariable, and the wireOthers time has dropped to 0 (yeah!). My version is:

		private Object getVariable(Object x, String fdname) {
//#feature 2770471 GenericAutowireComposer shall support wiring ZScript varible
if (x instanceof Page) {
final Page pg = (Page) x;
//Object arg = pg.getZScriptVariable(fdname);
//if (arg == null) {
Object arg = pg.getVariable(fdname);
//}
return arg;
} else {
final Component cmp = (Component) x;
//final Page page = getPage(cmp);
//Object arg = page != null ? page.getZScriptVariable(cmp, fdname): null;
//if (arg == null) {
Object arg = cmp.getVariable(fdname, false);
//}
return arg;
}
}

SimonPai
1696 1

xmedeko, thanks a lot for your code and statistics contribution. :-)

Simon

xmedeko
1021 1 16
http://xmedeko.blogspot.c...

Simon, I hope some solution how to disable ZScriptVariables lookup will appear in the next release of ZK.

robertpic71
1275 1

>> Simon, I hope some solution how to disable ZScriptVariables lookup will appear in the next release of ZK.

+1

/Robert

9393 3 7 16
http://www.oxitec.de/

I would be happy too, 'cause i don't need ZScript vars.

PeterKuo
481 2

I added it to feature request.
https://sourceforge.net/tracker/?group_id=152762&atid=785194

[hide preview]