Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1469

Java isset space optimization

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.8
    • 0.9
    • Java - Compiler
    • Patch Available

    Description

      Attached is a small patch and unit tests for Java to optimize the heapspace
      footprint of (for example):

      struct OptIntPair {
      1: i32 a
      2: i32 b
      }

      Each instance will have an __isset_bit_vector which points to a BitSet,
      which points to a long[], adding around 50 bytes of overhead to this object.

      The patch changes this by storing a raw byte and doing direct bitfield operations, like:
      byte __isset_bitfield;

      public void unsetB()

      { __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __B_ISSET_ID); }

      A little nasty, but a big space win: on my machine, this brings down the total
      size of an OptIntPair from 85 bytes to 25 bytes. A BitSet gets used as a fallback
      when more than 64 __isset entries are needed.

      Attachments

        1. thrift-java-isset.patch
          17 kB
          Brian Bloniarz

        Activity

          People

            brianbloniarz Brian Bloniarz
            brianbloniarz Brian Bloniarz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: