Is Guice 4 faster ?

259 views
Skip to first unread message

steff....@gmail.com

unread,
Oct 14, 2014, 9:40:10 AM10/14/14
to google...@googlegroups.com
Hi Guice team,

we have done some little experiments on our side and it seems Guice 4 is slighlty faster than Guice 3. But you don't have much data about this.
Unfortunately, there is no release changes between Guice 3 and the upcoming Guice 4 yet.

Does anyone have any measurements of performance comparison between Guice 3 & 4 ? 
We would be interested by both the startup times and injection times.

Thanks in advance,
 Stéphane

Sam Berlin

unread,
Oct 14, 2014, 9:52:48 AM10/14/14
to google...@googlegroups.com
I don't think we have any exact measurements, but there were a number of changes designed to improve memory & performance (that I believe were individually measured).  These are the ones I can spot by looking over the commit history:

 sam

--
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 http://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/15f0ad6d-22af-42fa-8066-c906f0fd22e5%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Stéphane NICOLAS

unread,
Oct 14, 2014, 10:05:19 AM10/14/14
to google...@googlegroups.com
Thx for this answer Sam.

I believe we will soon come back to guice-dev list with a suggestion of optimization for Guice. This week probably.

Stéphane

Sam Berlin

unread,
Oct 14, 2014, 10:06:29 AM10/14/14
to google...@googlegroups.com
The user list is perfectly fine, the dev list isn't really actively used.  It's more just a place where commit messages go to.

sam

Kevin Burton

unread,
Oct 14, 2014, 1:59:49 PM10/14/14
to google...@googlegroups.com
OK.. silly question, why would this matter? 

The performance of Guice didn't seem pathologically broken.  

What I do is just create all my bindings at startup and then I'm done.  Any complex initialization is done via providers... 

So maybe I'm missing something and there are some use cases that people are calling getInstance() in a more production or tight loop situation?

Is this an anti-pattern or actually valuable?

Sam Berlin

unread,
Oct 14, 2014, 2:06:07 PM10/14/14
to google...@googlegroups.com
Perf improvements for Guice tend to fall in two categories:  Speed up startup, and speed up runtime.  Speeding up the startup makes the development lifecycle better -- devs can start/stop/restart their servers faster.  Speeding up runtime has more obvious improvements: you can do more things with fewer resources.  In aggregate, a faster runtime can make a huge difference to how fast a machine can handle requests.

In general, we haven't found anything pathologically slow for a long time.  The last real terrible case (that I can recall) was AssistedInject, and that's been fixed for a long time.  There's probably a lot of little internal things that could be cleaned up or optimized, though, and so long as there's benchmarks proving the changes really are optimizing stuff, there's no harm in doing it (if it doesn't complicate the code too much).

sam

--
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 http://groups.google.com/group/google-guice.

Brian Pontarelli

unread,
Oct 14, 2014, 2:16:21 PM10/14/14
to google...@googlegroups.com
Prime MVC calls getInstance every request. This is great because all controllers are non-singletons and state doesn't get polluted. Though Guice is rarely the bottleneck for most apps. 

-- Brian

Sent from my iPhone 
--

Stephan Classen

unread,
Oct 14, 2014, 2:44:05 PM10/14/14
to google...@googlegroups.com
We used Guice3.0 in an library which analyzes SQLs sent to the DB. The first version showed a heavy impact on execution time (queries were up to 4 times slower).
We replaced almost all assisted inject with hand written factories and could remove about half of the overhead.

My finding is, that for a normal application Guice is fast enough. But for time critical parts of the code which get executed often (+50 times per request) there is a notable impact on speed.

Christian Gruber

unread,
Oct 14, 2014, 2:50:06 PM10/14/14
to google...@googlegroups.com
Worth pointing out that in a cloud-universe where instances are killed and restarted, improving startup time is actually money on the table, since work performed by guice at startup costs CPU time which most cloud vendors charge for. Perhaps a trickle, but still a "good thing" to fix where Guice (or any software) is doing unnecessary work. 

Brian Pontarelli

unread,
Oct 14, 2014, 3:22:10 PM10/14/14
to google...@googlegroups.com
We remove assisted inject and multi bindings and noticed improvements as well.


-- Brian

Sent from my iPhone 
Reply all
Reply to author
Forward
0 new messages