Lazy initialisation for bindings?

477 views
Skip to first unread message

Hugo Visser

unread,
Jul 24, 2011, 8:08:21 AM7/24/11
to google-guice
Hi,

I'm using Guice in an App Engine app and I'm trying to reduce some of
the start up delays for the initial request.
A fair amount of delay is the byte code generation that Guice does
when resolving the bindings. I was wondering if it 1. would make sense
and 2. would be possible to defer the byte code generation that is
happening in for example ProxyFactory and defer it to the point that
the binding is actually requested/used for injection.

Thanks,

Hugo

Stuart McCulloch

unread,
Jul 24, 2011, 9:21:39 AM7/24/11
to google...@googlegroups.com

Which version of Guice are you using at the moment? Guice 3 and trunk have an option to turn off the circular proxy support which might help:

http://google-guice.googlecode.com/svn/tags/3.0/javadoc/com/google/inject/Binder.html#disableCircularProxies()

and they should also generate fewer proxy classes than earlier releases

Also do you use any AOP in your app? If not then you could try the no-AOP flavour of Guice which doesn't do any CGLIB bytecode enhancement

--
Cheers, Stuart

> Thanks,
>
> Hugo
>
> --
> You received this message because you are subscribed to the Google Groups "google-guice" group.
> To post to this group, send email to google...@googlegroups.com.
> To unsubscribe from this group, send email to google-guice...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
>

Hugo Visser

unread,
Jul 24, 2011, 4:00:28 PM7/24/11
to google...@googlegroups.com
Thanks Stuart, I wasn't aware of that option, I'll check it out.

I'm using 3.0 and I'm using the AOP version. Even without any matchers setup I see that Guice uses FastClass (for optimized reflection I guess). The main issue is that on App Engine reflection and/or class loading appears very slow (~1 sec on my laptop vs ~4 on App Engine for the same Guice init).

I'm not sure if it would even work if Guice allowed me to defer the "binding initialization" as it appears in the log. I'm binding resource classes that are used by Jersey so I guess when Jersey does it init it will also get an instance of the resource through Guice and the same init would occur.

Hugo
Reply all
Reply to author
Forward
0 new messages