You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Brian Bloniarz (Created) (JIRA)" <ji...@apache.org> on 2011/12/19 21:41:30 UTC

[jira] [Created] (THRIFT-1469) Java isset space optimization

Java isset space optimization
-----------------------------

                 Key: THRIFT-1469
                 URL: https://issues.apache.org/jira/browse/THRIFT-1469
             Project: Thrift
          Issue Type: Improvement
          Components: Java - Compiler
    Affects Versions: 0.8
            Reporter: Brian Bloniarz
            Priority: Minor


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.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (THRIFT-1469) Java isset space optimization

Posted by "Bryan Duxbury (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1469?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury closed THRIFT-1469.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 0.9
         Assignee: Brian Bloniarz

Awesome, I just committed this patch. This is a great improvement! Thanks for the patch.
                
> Java isset space optimization
> -----------------------------
>
>                 Key: THRIFT-1469
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1469
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Java - Compiler
>    Affects Versions: 0.8
>            Reporter: Brian Bloniarz
>            Assignee: Brian Bloniarz
>            Priority: Minor
>              Labels: patch
>             Fix For: 0.9
>
>         Attachments: thrift-java-isset.patch
>
>
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (THRIFT-1469) Java isset space optimization

Posted by "Hudson (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13174368#comment-13174368 ] 

Hudson commented on THRIFT-1469:
--------------------------------

Integrated in Thrift #370 (See [https://builds.apache.org/job/Thrift/370/])
    THRIFT-1469. java: Java isset space optimization

This patch gives the generated code some variable-sized options for the isset bit vector. The compiler will attempt to use byte, short, int and long types before reverting to a BitSet for structs with a LOT of optional fields. This should save a fair amount of memory in a lot of cases.

Patch: Brian Bloniarz

bryanduxbury : http://svn.apache.org/viewvc/?view=rev&rev=1221828
Files : 
* /thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
* /thrift/trunk/lib/java/build.xml
* /thrift/trunk/lib/java/src/org/apache/thrift/EncodingUtils.java
* /thrift/trunk/lib/java/test/org/apache/thrift/TestOptionals.java
* /thrift/trunk/test/ManyOptionals.thrift

                
> Java isset space optimization
> -----------------------------
>
>                 Key: THRIFT-1469
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1469
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Java - Compiler
>    Affects Versions: 0.8
>            Reporter: Brian Bloniarz
>            Assignee: Brian Bloniarz
>            Priority: Minor
>              Labels: patch
>             Fix For: 0.9
>
>         Attachments: thrift-java-isset.patch
>
>
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (THRIFT-1469) Java isset space optimization

Posted by "Brian Bloniarz (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1469?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brian Bloniarz updated THRIFT-1469:
-----------------------------------

    Attachment: thrift-java-isset.patch
    
> Java isset space optimization
> -----------------------------
>
>                 Key: THRIFT-1469
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1469
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Java - Compiler
>    Affects Versions: 0.8
>            Reporter: Brian Bloniarz
>            Priority: Minor
>              Labels: patch
>         Attachments: thrift-java-isset.patch
>
>
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira