diff options
author | Nate Goergen <nate.goergen.gitlab1@mile10.com> | 2015-03-01 20:03:35 -0600 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2015-04-02 15:38:56 -0700 |
commit | 7a8989d21de2f9a121eafe56ce0b557572a498d4 (patch) | |
tree | 1eea44816a0574f7896947809ea6b7f7aa90d2f9 | |
parent | 4b0b45a60de40f0d0b734b73adaf829cf7e63e8a (diff) |
controlport: improving transport layer throughput.
* made a new TbufferedTransportFactory class to create transports with buffer sizes different (i.e. greater) than the Thrift default of 512 bytes.
* note: this should eventually be user configurable as a ControlPort setting in the GNU Radio config file
** hard-coding a value for now for an assumed Ethernet MTU of 1500 bytes.. Not ideal, but better than the Thrift default.
-rw-r--r-- | gnuradio-runtime/include/gnuradio/thrift_server_template.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/gnuradio-runtime/include/gnuradio/thrift_server_template.h b/gnuradio-runtime/include/gnuradio/thrift_server_template.h index 3147696c91..5de0112c78 100644 --- a/gnuradio-runtime/include/gnuradio/thrift_server_template.h +++ b/gnuradio-runtime/include/gnuradio/thrift_server_template.h @@ -37,6 +37,15 @@ using namespace apache; +namespace { + static const unsigned int ETHERNET_HEADER_SIZE(14); + static const unsigned int IP_HEADER_SIZE(20); + static const unsigned int TCP_HEADER_SIZE(32); + static const unsigned int ETHERNET_TYPICAL_MTU(1500); + static const unsigned int ALRIGHT_DEFAULT_BUFFER_SIZE( + ETHERNET_TYPICAL_MTU - ETHERNET_HEADER_SIZE - IP_HEADER_SIZE - TCP_HEADER_SIZE); +} + template<typename TserverBase, typename TserverClass, typename TImplClass, typename TThriftClass> class thrift_server_template : public thrift_application_base<TserverBase, TImplClass> { @@ -52,6 +61,29 @@ protected: TserverBase* d_server; const std::string d_contolPortName, d_endpointName; + +private: + + /** + * Custom TransportFactory that allows you to override the default Thrift buffer size + * of 512 bytes. + * + */ + class TBufferedTransportFactory : public thrift::transport::TTransportFactory { + public: + TBufferedTransportFactory() : bufferSize(ALRIGHT_DEFAULT_BUFFER_SIZE) {;} + TBufferedTransportFactory(const unsigned int _bufferSize) : bufferSize(_bufferSize) {;} + + virtual ~TBufferedTransportFactory() {} + + virtual boost::shared_ptr<thrift::transport::TTransport> getTransport( + boost::shared_ptr<thrift::transport::TTransport> trans) { + return boost::shared_ptr<thrift::transport::TTransport>( + new thrift::transport::TBufferedTransport(trans, bufferSize)); + } + private: + unsigned int bufferSize; + }; }; template<typename TserverBase, typename TserverClass, typename TImplClass, typename TThriftClass> @@ -72,7 +104,7 @@ thrift_server_template<TserverBase, TserverClass, TImplClass, TThriftClass>::thr serverTransport(new thrift::transport::TServerSocket(9090)); boost::shared_ptr<thrift::transport::TTransportFactory> - transportFactory(new thrift::transport::TBufferedTransportFactory()); + transportFactory(new thrift_server_template::TBufferedTransportFactory()); boost::shared_ptr<thrift::protocol::TProtocolFactory> protocolFactory(new thrift::protocol::TBinaryProtocolFactory()); |