Skip to content
Perl XS/C version of Thrift MemoryBuffer and BinaryProtocol
C Perl
Find file
Latest commit 6656a7b Jul 11, 2011 @andygrundman Release 1.04
Failed to load latest commit information.
hints MemoryBuffer and BinaryProtocol Feb 21, 2011
lib Fixed errors if you only loaded ::BinaryProtocol instead of ::XS Jul 11, 2011
src 32-bit fixes for I64. Turns out Perl's own pvf/printf functions can't… May 5, 2011
t Fixed bug in writeString that would encode certain binary data into U… Jul 11, 2011
BinaryProtocol.xs Fixed bug in writeString that would encode certain binary data into U… Jul 11, 2011
Changes Release 1.04 Jul 11, 2011
CompactProtocol.xs Fixed bug in writeString that would encode certain binary data into U… Jul 11, 2011
MANIFEST Release 1.02 May 6, 2011
MemoryBuffer.xs Added missing getTransport method, some memory-related fixes Feb 27, 2011
xs_object_magic.h MemoryBuffer and BinaryProtocol Feb 22, 2011


    Thrift::XS - Faster Thrift binary protocol encoding and decoding

        use Thrift;
        use Thrift::Socket;
        use Thrift::FramedTransport;
        use Thrift::XS::BinaryProtocol;
        use MyThriftInterface;
        my $socket    = Thrift::Socket->new( $host, $port );
        my $transport = Thrift::FramedTransport->new($socket);
        my $protocol  = Thrift::XS::BinaryProtocol->new($transport);
        my $client    = MyThriftInterface->new($protocol);
        $client->api_call( @args );

    Thrift::XS provides faster versions of Thrift::BinaryProtocol and

    Thrift compact protocol support is also available, just replace
    Thrift::XS::BinaryProtocol with Thrift::XS::CompactProtocol.

    To use, simply replace your Thrift initialization code with the
    appropriate Thrift::XS version.

    For the best performance, you need to use a custom socket layer and both
    Thrift::XS::MemoryBuffer and one of Thrift::XS::BinaryProtocol or
    Thrift::XS::CompactProtocol. If using the standard BufferedTransport,
    FramedTransport, or HttpClient modules, performance will not be as good
    as it could be. In particular, HttpClient is incredibly bad, making a
    lot of very small (1-4 byte) sysread() and print() calls. A future
    version of this module will probably provide XS implementations of these
    other modules to help with this problem.

    Here is a breakdown of the performance improvements of the various
    low-level methods. A given Thrift API call will make many write and read
    method calls, so your results will be some average of these numbers. For
    detailed numbers and to run your own benchmarks, see the bench/

        XS::MemoryBuffer write + read: 6x faster
            writeMessageBegin + readMessageBegin: 12.0x
            complex struct/field write+read:       6.6x
            writeMapBegin + readMapBegin:         24.0x
            writeListBegin + readListBegin:       20.0x
            writeSetBegin + readSetBegin:         21.0x
            writeBool + readBool:                 13.5x
            writeByte + readByte:                 13.9x
            writeI16 + readI16:                   14.4x
            writeI32 + readI32:                   12.9x
            writeI64 + readI64:                   29.4x
            writeDouble + readDouble:             13.5x
            writeString + readString:              7.5x
            writeMessageBegin + readMessageBegin: 11.6x
            complex struct/field write+read:       6.2x
            writeMapBegin + readMapBegin:         18.7x
            writeListBegin + readListBegin:       14.1x
            writeSetBegin + readSetBegin:         13.3x
            writeBool + readBool:                 13.2x
            writeByte + readByte:                 13.9x
            writeI16 + readI16:                    9.0x
            writeI32 + readI32:                    7.5x
            writeI64 + readI64:                   10.0x
            writeDouble + readDouble:             13.5x
            writeString + readString:              7.4x

    Thrift Home <>

    Thrift Perl code

    AnyEvent::Cassandra, example usage of this module. This module is not
    yet on CPAN, but will be available soon.

    Andy Grundman, <>

    Copyright 2011 Logitech, Inc.

    Licensed under the Apache License, Version 2.0 (the "License"); you may
    not use this file except in compliance with the License. You may obtain
    a copy of the License at

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

Something went wrong with that request. Please try again.