You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bb...@apache.org on 2021/01/14 00:46:52 UTC

[geode-native] branch develop updated: GEODE-8831: Fix performance degradation after changing to boost::asio (#719)

This is an automated email from the ASF dual-hosted git repository.

bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git


The following commit(s) were added to refs/heads/develop by this push:
     new ec82309  GEODE-8831: Fix performance degradation after changing to boost::asio (#719)
ec82309 is described below

commit ec823095d0efe74e025d773b7bffefadc9261f70
Author: Alberto Gomez <al...@est.tech>
AuthorDate: Thu Jan 14 01:46:43 2021 +0100

    GEODE-8831: Fix performance degradation after changing to boost::asio (#719)
    
    After replacing ACE_SOCK with boost::asio a
    significant performance degradation has been observed
    in send and receive operations.
    
    The cause has been some log debug calls added to the
    TcpConn::send and TcpConn::receive that took as
    input a stringstream previously created.
    
    After changing these logs to not use the
    stringstream, the performance of the
    native client has returned to the original
    figures.
---
 cppcache/src/TcpConn.cpp | 54 +++++++++++++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/cppcache/src/TcpConn.cpp b/cppcache/src/TcpConn.cpp
index 298384c..9bc71a9 100644
--- a/cppcache/src/TcpConn.cpp
+++ b/cppcache/src/TcpConn.cpp
@@ -163,40 +163,40 @@ TcpConn::TcpConn(const std::string ipaddr,
 }
 
 TcpConn::~TcpConn() {
-  std::stringstream ss;
-
   try {
-    ss << "Disconnected " << socket_.local_endpoint() << " -> "
-       << socket_.remote_endpoint();
-
+    LOGFINE("Disconnected %s:%u -> %s:%u",
+            socket_.local_endpoint().address().to_string().c_str(),
+            socket_.local_endpoint().port(),
+            socket_.remote_endpoint().address().to_string().c_str(),
+            socket_.remote_endpoint().port());
     socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both);
 
   } catch (...) {
-    ss = std::stringstream{};
-
-    ss << "Closed socket " << socket_.local_endpoint();
+    LOGFINE("Closed socket %s:%u ",
+            socket_.local_endpoint().address().to_string().c_str(),
+            socket_.local_endpoint().port());
   }
 
   socket_.close();
-
-  LOGFINE(ss.str());
 }
 
 size_t TcpConn::receive(char *buff, const size_t len,
                         std::chrono::milliseconds timeout) {
-  std::stringstream ss;
-  ss << "Receiving " << len << " bytes from " << socket_.remote_endpoint()
-     << " -> " << socket_.local_endpoint();
-  LOGDEBUG(ss.str());
+  LOGDEBUG("Receiving %d bytes from %s:%u -> %s:%u", len,
+           socket_.remote_endpoint().address().to_string().c_str(),
+           socket_.remote_endpoint().port(),
+           socket_.local_endpoint().address().to_string().c_str(),
+           socket_.local_endpoint().port());
   return receive(buff, len, timeout, true);
 }
 
 size_t TcpConn::receive_nothrowiftimeout(char *buff, const size_t len,
                                          std::chrono::milliseconds timeout) {
-  std::stringstream ss;
-  ss << "Receiving an unknown number of bytes from "
-     << socket_.remote_endpoint() << " -> " << socket_.local_endpoint();
-  LOGDEBUG(ss.str());
+  LOGDEBUG("Receiving an unknown number of bytes from %s:%d -> %s:%d",
+           socket_.remote_endpoint().address().to_string().c_str(),
+           socket_.remote_endpoint().port(),
+           socket_.local_endpoint().address().to_string().c_str(),
+           socket_.local_endpoint().port());
   return receive(buff, len, timeout, false);
 }
 
@@ -260,10 +260,11 @@ size_t TcpConn::receive(char *buff, const size_t len,
 
 size_t TcpConn::send(const char *buff, const size_t len,
                      std::chrono::milliseconds timeout) {
-  std::stringstream ss;
-  ss << "Sending " << len << " bytes from " << socket_.local_endpoint()
-     << " -> " << socket_.remote_endpoint();
-  LOGDEBUG(ss.str());
+  LOGDEBUG("Sending %d bytes from %s:%u -> %s:%u", len,
+           socket_.local_endpoint().address().to_string().c_str(),
+           socket_.local_endpoint().port(),
+           socket_.remote_endpoint().address().to_string().c_str(),
+           socket_.remote_endpoint().port());
 
   boost::optional<boost::system::error_code> write_result;
   std::size_t bytes_written = 0;
@@ -329,10 +330,11 @@ void TcpConn::connect(boost::asio::ip::tcp::resolver::results_type r,
     throw boost::system::system_error{boost::asio::error::operation_aborted};
   }
 
-  std::stringstream ss;
-  ss << "Connected " << socket_.local_endpoint() << " -> "
-     << socket_.remote_endpoint();
-  LOGDEBUG(ss.str());
+  LOGDEBUG("Connected %s:%u -> %s:%u",
+           socket_.local_endpoint().address().to_string().c_str(),
+           socket_.local_endpoint().port(),
+           socket_.remote_endpoint().address().to_string().c_str(),
+           socket_.remote_endpoint().port());
 }
 
 boost::asio::ip::tcp::resolver::results_type TcpConn::resolve(