xiaodududu / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Optimize InjectorBuilder.build() and getJustInTimeBinding() for child injectors. #529

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Sam Pullara provided the attached trace. The total response time is 16ms, so 
we're pretty fast already, but we may be able to go faster.

We should be able to create child injectors with high frequency and concurrency.

Original issue reported on code.google.com by crazybob...@gmail.com on 30 Jul 2010 at 5:30

Attachments:

GoogleCodeExporter commented 9 years ago
If this is because the app is using AssistedInject, update to the latest SVN 
revision and the performance hit will completely go away.  The latest SVN 
AssistedInject is faster than even the initial implementation of it (and crazy 
faster than the second revision of it).

Original comment by sberlin on 30 Jul 2010 at 6:45

GoogleCodeExporter commented 9 years ago
16ms is too slow. We can make this much faster.

Original comment by limpbizkit on 30 Jul 2010 at 6:46

GoogleCodeExporter commented 9 years ago

Original comment by sberlin on 23 Nov 2010 at 1:30

GoogleCodeExporter commented 9 years ago
would love to see this get into 3.1/4.0

Original comment by m...@niskala.org on 10 Jan 2014 at 8:25

GoogleCodeExporter commented 9 years ago
While InjectorBuilder.build() is still slow, child injectors as a whole were 
massively optimized back before the v3 release.  It's insanely fast now so long 
as you aren't injecting a Provider of an assisted arg or an Injector into your 
assisted class.

Original comment by sberlin on 10 Jan 2014 at 8:31

GoogleCodeExporter commented 9 years ago
(and by 'child injectors were optimized', I actually meant "assisted inject was 
optimized", which was the #1 use-case for child injectors in apps.)

Original comment by sberlin on 10 Jan 2014 at 8:32

GoogleCodeExporter commented 9 years ago
Cool.  I'm hoping to use child injectors for separate activities in android, 
which sounds like it isn't covered by those existing optimizations

Original comment by m...@niskala.org on 10 Jan 2014 at 8:35

GoogleCodeExporter commented 9 years ago
Interesting.  Have you looked at Dagger?  It's usually a better choice for 
Android.

Original comment by sberlin on 10 Jan 2014 at 8:48

GoogleCodeExporter commented 9 years ago
Yes, I'm aware of dagger.  Dagger is okay but it's not as powerful as 
RoboGuice.  With phones getting faster and faster (many are now faster than the 
original macbook air), the flexibility of runtime dependency injection wins out 
over compile-time solutions, IMO.  As long as we keep optimizing :)

Original comment by m...@niskala.org on 10 Jan 2014 at 8:52

GoogleCodeExporter commented 9 years ago
Fair enough.  FWIW, there's not a whole lot left here to optimize that I've 
found.  Patches are very, very welcome. :-)

Original comment by sberlin on 10 Jan 2014 at 9:09

GoogleCodeExporter commented 9 years ago
will take a look :)

Original comment by m...@niskala.org on 10 Jan 2014 at 9:35