Adrian Cole created THRIFT-3913:
-----------------------------------

             Summary: Add sizeInBytes(TProtocol oprot) to TSerializable
                 Key: THRIFT-3913
                 URL: https://issues.apache.org/jira/browse/THRIFT-3913
             Project: Thrift
          Issue Type: Brainstorming
          Components: Java - Library
            Reporter: Adrian Cole
            Priority: Minor


In zipkin (tracing system), we use TBinaryProtocol encoding. We have a custom 
library that calculates the size of a Span object up front, which allows us to 
allocate a fixed-size array for serialization.

The result in substantially improved write performance, particularly as spans 
are small and don't benefit as much from tricks like pooled buffers (who tend 
to have larger segment sizes or otherwise don't optimize for small byte 
strings).

To do this in libthrift I'm guessing we'd need to add sizeInBytes(TProtocol 
oprot) to TSerializable, or somewhere else, and then implementing that in the 
compiler. While reasonable enough to do manually in zipkin (which has only 
several fields), this might be tricky to automate. Plus, there are other 
concerns that would need to be made available, like getting encoded length of a 
UTF-8 to UTF-16 string without changing it into a byte array.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to