More memory efficient bitset implementation(s)
----------------------------------------------
Key: THRIFT-974
URL: https://issues.apache.org/jira/browse/THRIFT-974
Project: Thrift
Issue Type: Improvement
Components: Java - Compiler, Java - Library
Affects Versions: 0.5, 0.4, 0.3
Reporter: Bryan Duxbury
Some comments on THRIFT-872 got me to thinking about the bitset implementation
we use to handle isset. It seems like the minimum amount of memory we can use
to store isset today is 28 bytes - 8 for the reference to the bitset, 8 for the
reference to the long[] inside, 8 for the long itself, and 4 for the array
size. (This assumes a 64-bit JVM.) For structs with a small number of fields in
isset, we can do better than this in a number of ways.
One option would be to make a new bitset implementation for "small" bitsets
that was backed by one long field rather than a long[1]. This would cut the
cost down to 16 bytes for up to 64 isset fields, which I suspect covers most
people's structs.
If we're willing to break encapsulation a little bit, another option would be
to just keep the long field in the containing struct itself. That would shave
another 8 bytes off. However, it would make the implementation more messy.
In any case, we can hide all this implementation interaction behind the isXSet
methods we already generate and let the generator decide how to optimize and
compile-time.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.