thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephane <slun...@gmail.com>
Subject Re: Autoboxing in generated java code
Date Thu, 16 Jul 2009 00:59:07 GMT
I came across the autoboxing in the java generated code using my default
Eclipse settings. By default my projects are set to mark autoboxing as an
error. As indicated I did not -yet- do any benchmark. Switching my settings
to warning instead of error, my test project build and works fine. Since
even the Sun docs was mentioning
that autoboxing has some cost, I was curious to see if it was
something that was done by design in Thrift or not.

St├ęphane


On Wed, Jul 15, 2009 at 5:22 PM, Joel Meyer <joel.meyer@gmail.com> wrote:

> On Wed, Jul 15, 2009 at 5:09 PM, Ted Dunning <ted.dunning@gmail.com>
> wrote:
>
> > That last answer in the comment chain just asserts that this is the cost
> of
> > autoboxing.  It doesn't actually describe any measurements.
> >
> > I think that is a made-up number.  I find it very hard to imagine that it
> > costs hundreds of microseconds to box or unbox an integer (0.5 s / 2000).
>
>
> I would imagine that the cost of boxing a primitive value is roughly
> equivalent to the time it takes to allocate and initialize its Object
> equivalent. The cost of unboxing should be roughly equal to the time of a
> method invocation (myObject.getPrimitiveValue()).
>
> I don't see why manually allocating the object yourself (instead of having
> the JVM do it) would be any faster (especially if the JVM caches frequently
> boxed values), but maybe I'm missing something?
>
>
> >
> >
> > On Wed, Jul 15, 2009 at 4:51 PM, Bryan Duxbury <bryan@rapleaf.com>
> wrote:
> >
> > > there is some cost for sure but I did not do a real benchmark. When I
> did
> > >> search for it, I came across :
> > >> http://stackoverflow.com/questions/423704/java-int-or-integer/423856
> > >>
> > >> the last answer indicate that auboxing 2000 Integer add 0.5 ms... yes
> > it's
> > >> not much but if you are doing a lot of such operation it starts to
> adds
> > up
> > >> especially on a server side web apps/web services.
> > >>
> > >
> > > Interesting. Would love to see if that measured up the same way in
> > Thrift.
> >
> >
> >
> >
> > --
> > Ted Dunning, CTO
> > DeepDyve
> >
> > 111 West Evelyn Ave. Ste. 202
> > Sunnyvale, CA 94086
> > http://www.deepdyve.com
> > 858-414-0013 (m)
> > 408-773-0220 (fax)
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message