Closed
Bug 626633
Opened 15 years ago
Closed 14 years ago
Optimization tip for Python Thrift communication
Categories
(Socorro :: General, task, P3)
Socorro
General
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: dre, Assigned: rhelmer)
Details
(Whiteboard: [qa-])
Attachments
(1 file, 1 obsolete file)
|
9.53 KB,
patch
|
lars
:
review+
|
Details | Diff | Splinter Review |
Original mailing list link shared to us by Stack:
http://permalink.gmane.org/gmane.comp.java.hadoop.hbase.user/14379
Message contents:
Having worked with the other java/thrift based nosql solution we have been
using Thrift Accelerated Protocol and it works great. It is very fast and we
have seen 3-4x performance improvement on some read operations (wide rows).
We have never seen this "advertised" or referrenced with any hbase python
sample code so I thought I would post this to help.
from thrift.protocol.TBinaryProtocol import TBinaryProtocolAccelerated
...
protocol = TBinaryProtocolAccelerated(transport)
...
| Reporter | ||
Comment 1•15 years ago
|
||
Here is a link to the source docs on it:
http://code.google.com/p/socorro/source/browse/trunk/thirdparty/thrift/protocol/TBinaryProtocol.py#235
| Assignee | ||
Comment 2•15 years ago
|
||
Checked this in, will test on staging momentarily:
Committed r2891
| Assignee | ||
Comment 3•15 years ago
|
||
Not checked in yet but tested on staging, appears to work at first blush.
Lars - I am not sure why it uses "self.protocolModule.TBinaryProtocol(self.transport)" before this patch; can you enlighten me? Anything wrong with just doing "TBinaryProtocolAccelerated(self.transport)" here?
I feel like I must be missing something...
Comment 4•15 years ago
|
||
Comment on attachment 505574 [details] [diff] [review]
use accelerated protocol
the new import pulls a class from a module while the previous import pulls a module from a package. So they don't do equivalent actions.
then later, the original code uses self.protocolModule.TBufferedTransport to instantiate a class. Your replacement bypasses the fetch the class from module step. By bypassing that step, we break the unit tests. In the unit tests, we mock the protocol module and then to pull a mocked TBinaryProtocol from it. The unit tests could be changed to work for your code. However, the original code preserves the original authors methods (rightly or wrongly).
Attachment #505574 -
Flags: review?(lars) → review-
| Assignee | ||
Comment 5•15 years ago
|
||
(In reply to comment #4)
> Comment on attachment 505574 [details] [diff] [review]
> use accelerated protocol
>
> the new import pulls a class from a module while the previous import pulls a
> module from a package. So they don't do equivalent actions.
>
> then later, the original code uses self.protocolModule.TBufferedTransport to
> instantiate a class. Your replacement bypasses the fetch the class from module
> step. By bypassing that step, we break the unit tests. In the unit tests, we
> mock the protocol module and then to pull a mocked TBinaryProtocol from it.
> The unit tests could be changed to work for your code. However, the original
> code preserves the original authors methods (rightly or wrongly).
Ah thanks, I see it now.
I backed this out for now, since we decided not to move forward with this today:
Committed r2891
I'll post a new patch later, and fix the unit test too.
| Assignee | ||
Comment 6•15 years ago
|
||
use thrift.protocol.TBinaryProtocol.TBinaryProtocolAccerated class without breaking unit tests (not to be confused with thrift.protocol.TBinaryProtocol.TBinaryProtocol class :).
Tested using hbaseClient.py, but I know that it just fell back from looking at the "implementation" (and very helpful comment) in the thrift-generated python code, we'll need to build the C bindings and make the module available for this to work:
class TBinaryProtocolAccelerated(TBinaryProtocol):
"""C-Accelerated version of TBinaryProtocol.
This class does not override any of TBinaryProtocol's methods,
but the generated code recognizes it directly and will call into
our C module to do the encoding, bypassing this object entirely.
We inherit from TBinaryProtocol so that the normal TBinaryProtocol
encoding can happen if the fastbinary module doesn't work for some
reason. (TODO(dreiss): Make this happen sanely in more cases.)
In order to take advantage of the C module, just use
TBinaryProtocolAccelerated instead of TBinaryProtocol.
NOTE: This code was contributed by an external developer.
The internal Thrift team has reviewed and tested it,
but we cannot guarantee that it is production-ready.
Please feel free to report bugs and/or success stories
to the public mailing list.
"""
pass
I made a small local modification to make sure that this class is being called from HBase, that looks fine at least.
I'll try to get this working in dev, this patch should be safe to take in the meantime since it'll just fall back if the module is not available.
Attachment #505574 -
Attachment is obsolete: true
Attachment #508085 -
Flags: review?(lars)
Comment 7•15 years ago
|
||
Comment on attachment 508085 [details] [diff] [review]
use accelerated protocol
I recall looking at this quite a while ago and thinking it looked fine.
Attachment #508085 -
Flags: review?(lars) → review+
| Reporter | ||
Comment 8•15 years ago
|
||
Note: to get the binary component installed on a different machine, I did the following:
wget http://pypi.python.org/packages/source/t/thrift/Thrift-0.5.0.tar.gz
tar xzvf Thrift-0.5.0.tar.gz
rm Thrift-0.5.0.tar.gz
mv Thrift-0.5.0 src/
cd src/Thrift-0.5.0/
yum install python26-devel
python26 setup.py build
python26 setup.py build
python26 setup.py install
| Assignee | ||
Comment 9•15 years ago
|
||
(In reply to comment #8)
> Note: to get the binary component installed on a different machine, I did the
> following:
>
> wget http://pypi.python.org/packages/source/t/thrift/Thrift-0.5.0.tar.gz
> tar xzvf Thrift-0.5.0.tar.gz
> rm Thrift-0.5.0.tar.gz
> mv Thrift-0.5.0 src/
> cd src/Thrift-0.5.0/
> yum install python26-devel
> python26 setup.py build
> python26 setup.py build
> python26 setup.py install
Oh cool, didn't realize it was on pypi, that makes it a lot easier.
In fact, if I just do "pip install thrift" in my virtualenv, I get the fastbinary.so, so should be all set. We should be able to trivially build an RPM from the pypi package too.
I'll do some tests with my dev socorro against the research cluster.
| Assignee | ||
Comment 10•15 years ago
|
||
Seems ok from initial testing. Now that new stage is up, would love to test for perf/correctness.
Priority: -- → P3
| Assignee | ||
Comment 11•15 years ago
|
||
Not working on this right now, but would be easy to do.
Assignee: rhelmer → nobody
Updated•14 years ago
|
Component: Socorro → General
Product: Webtools → Socorro
| Assignee | ||
Comment 12•14 years ago
|
||
This is fixed by bug 751654, and in production as of Socorro 9.
Assignee: nobody → rhelmer
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Updated•14 years ago
|
Whiteboard: [qa-]
You need to log in
before you can comment on or make changes to this bug.
Description
•