hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stack <st...@duboce.net>
Subject Re: Java sizeof!
Date Thu, 05 Mar 2009 17:33:37 GMT
Good find Ryan.

How about we write a little program to generate a java interface file that
has in it the SIZEOF all the types we are interested in?  Anyone signing up
for the heapSize contract could make use of the defines?  Are sizes very
different when 32vs64bit?  If so, should we generate two interfaces and on
startup toggle which to use sizing?

St.Ack

On Thu, Mar 5, 2009 at 1:55 AM, Ryan Rawson <ryanobjc@gmail.com> wrote:

> Yes such a thing (kind of) exists:
>
>
> http://java.sun.com/javase/6/docs/api/java/lang/instrument/package-summary.html
>
> You merely have to create a java agent jar which then gets access to this
> magical interface.  Here is a sourceforge project:
>
> http://sourceforge.net/projects/sizeof
>
> My measurements on java 1.6 64 bits, OS X:
> - empty object = 16 bytes
> - array of bytes: byte size + 24 bytes
> - ByteBuffer = 56 bytes (storage separately)
> - object, 1 int = 24 bytes
> - object, 2 ints = 24 bytes
> - object, 1 long = 24 bytes
>
> It seems pretty obvious that java -d64 is using dword/qword (32/64 bit)
> alignment.  Objects seem to be 64 bit aligned, but fields are not
> necessairly.  This is from the 1 int vs 2 int = 24 byte test.
>
> This aligns with the results of Erik's HeapSize values.
>
> I dont know how much overhead a java agent has like this, so it might not
> be
> worthwhile to use except as validation/verification of our HeapSize
> assumptions.
>
> With the use of ByteBuffer and 0-copy we can extract good memory
> performance, well, except the ByteBuffer instance itself is not exactly
> super light weight (56 bytes?) for what is essentially a few pointers (plus
> control bytes, plus blah blah).  So keeping the number of extraneous
> ByteBuffer instances low will help.
>
> -ryan
>

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