Profiling Modules

85 views
Skip to first unread message

Max Aller

unread,
Jun 30, 2017, 5:53:01 PM6/30/17
to google-guice
We're trying to improve performance of our Guice Modules, and to do that we'd like to figure out how long Guice is taking calling our @Provides methods. `bindListener` *almost* lets us do that, but it only works for objects instantiated with Guice, not Guice modules themselves, of course, and even if that worked, it doesn't surface any timing information. Does anyone have a clever AOP way figuring out how fast or slow code in user-specified Modules is taking?

Thanks,
Max

Stephan Classen

unread,
Jul 1, 2017, 2:32:48 AM7/1/17
to google...@googlegroups.com
While Guice AOP is a nice and cool feature and I love to use it for certain use cases I also found that it becomes a performance issue if used to heavely.
Because of this and the limitations you mention in your question I recommend using a classic profiler to investigate performance issues. For a list of populare ones see https://zeroturnaround.com/rebellabs/top-5-java-profilers-revealed-real-world-data-with-visualvm-jprofiler-java-mission-control-yourkit-and-custom-tooling/

Also let me add the following advice:
- keep your modules dumb. Having little to none logic in your guice modules is the way to go. This increases performanc and also helps to reason about what is happening when in your application.
- singeltons are by far the fastest objects to inject. Try to make your dependencies state less and immutable. Then you can turn them into singeltons making them fast to inject.

Good luck. Performance issues can be very hard to track down. But sometimes if you found the bottleneck a small change can make a big difference.

Luke Sandberg

unread,
Jul 2, 2017, 1:50:12 PM7/2/17
to google...@googlegroups.com
ProvisionListeners should be sufficient for this, though as Stephan says I would start with abnormal profiler.

--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/EDB9F815-1DDD-4B47-9ACF-71E5048AD102%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.

Bob Lee

unread,
Jul 4, 2017, 3:45:10 PM7/4/17
to Guice Mailing List
As others have mentioned, use a profiler. Also, in your log config, try setting com.google.inject.level=FINE (Guice logs some performance metrics).

Bob

--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice+unsubscribe@googlegroups.com.

To post to this group, send email to google...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
Reply all
Reply to author
Forward
0 new messages