fmgoncalves / p5-cassandra-simple

Cassandra::Simple Perl Module - Easy to use, Perl oriented client interface to Apache Cassandra.
http://fmgoncalves.github.com/p5-cassandra-simple
9 stars 3 forks source link

wish: Consider use thrift-xs #1

Closed jcbf closed 12 years ago

jcbf commented 12 years ago

Andy Grundman's Thrift-XS is a drop-in replacement for Thrift module.

Thrift::XS provides faster versions of Thrift::BinaryProtocol and Thrift::MemoryBuffer. 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.

Check please http://search.cpan.org/~agrundma/Thrift-XS-1.04/ or https://github.com/andygrundman/thrift-xs Could do something similar with JSON module and allow the developer to specify with backend or load XS and fallback to PurePerl

Benchmarks shows significant improvment

XS::MemoryBuffer write + read: 6x faster

XS::BinaryProtocol
    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

XS::CompactProtocol
    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
fmgoncalves commented 12 years ago

Accepted and commited

https://github.com/fmgoncalves/p5-cassandra-simple/commit/de6f1bfe9949f3f12a846598e964afefa0461593