-
Notifications
You must be signed in to change notification settings - Fork 3
/
README
102 lines (81 loc) · 4.09 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
NAME
Thrift::XS - Faster Thrift binary protocol encoding and decoding
SYNOPSIS
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);
$transport->open;
$client->api_call( @args );
DESCRIPTION
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.
SPEED
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/bench.pl
script.
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
SEE ALSO
Thrift Home <http://thrift.apache.org/>
Thrift Perl code
<http://svn.apache.org/repos/asf/thrift/trunk/lib/perl/>
AnyEvent::Cassandra, example usage of this module. This module is not
yet on CPAN, but will be available soon.
AUTHOR
Andy Grundman, <[email protected]>
COPYRIGHT AND LICENSE
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
http://www.apache.org/licenses/LICENSE-2.0
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.