From e5b4d8b8ade846ad09423fcfb40555f80c8caef3 Mon Sep 17 00:00:00 2001 From: Richard Fillman Date: Wed, 18 Oct 2017 17:19:59 -0700 Subject: [PATCH] Move small fields to avoid padding in AsyncSocket.h and AsyncSSLSocket.h Summary: Compiled mcrouter with the 'Wpadded' flag to try to find any wasted space. Mcrouter itself did not have anything, but there was a lot in AsyncSocket.h and AsyncSSLSocket.h so looked into those and removed a bit of wasted space Reviewed By: yfeldblum, brianwatling Differential Revision: D6033977 fbshipit-source-id: 2dc127208e09980be6a5db576b45d30ac6e044ff --- folly/io/async/AsyncSSLSocket.h | 7 ++++--- folly/io/async/AsyncSocket.h | 12 +++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/folly/io/async/AsyncSSLSocket.h b/folly/io/async/AsyncSSLSocket.h index 874fb9dd..8de643b8 100644 --- a/folly/io/async/AsyncSSLSocket.h +++ b/folly/io/async/AsyncSSLSocket.h @@ -877,8 +877,6 @@ class AsyncSSLSocket : public virtual AsyncSocket { SSL_SESSION *sslSession_{nullptr}; Timeout handshakeTimeout_; Timeout connectionTimeout_; - // whether the SSL session was resumed using session ID or not - bool sessionIDResumed_{false}; // The app byte num that we are tracking for the MSG_EOR // Only one app EOR byte can be tracked. @@ -918,10 +916,13 @@ class AsyncSSLSocket : public virtual AsyncSocket { std::chrono::steady_clock::time_point handshakeStartTime_; std::chrono::steady_clock::time_point handshakeEndTime_; std::chrono::milliseconds handshakeConnectTimeout_{0}; - bool sessionResumptionAttempted_{false}; std::chrono::milliseconds totalConnectTimeout_{0}; std::string sslVerificationAlert_; + + bool sessionResumptionAttempted_{false}; + // whether the SSL session was resumed using session ID or not + bool sessionIDResumed_{false}; }; } // namespace diff --git a/folly/io/async/AsyncSocket.h b/folly/io/async/AsyncSocket.h index a4c637bb..35a2149b 100644 --- a/folly/io/async/AsyncSocket.h +++ b/folly/io/async/AsyncSocket.h @@ -1183,6 +1183,11 @@ class AsyncSocket : virtual public AsyncTransportWrapper { ///< The address we are connecting from uint32_t sendTimeout_; ///< The send timeout, in milliseconds uint16_t maxReadsPerEvent_; ///< Max reads per event loop iteration + + bool isBufferMovable_{false}; + + int8_t readErr_{READ_NO_ERROR}; ///< The read error encountered, if any + EventBase* eventBase_; ///< The EventBase WriteTimeout writeTimeout_; ///< A timeout for connect and write IoHandler ioHandler_; ///< A EventHandler to monitor the fd @@ -1198,19 +1203,18 @@ class AsyncSocket : virtual public AsyncTransportWrapper { std::weak_ptr wShutdownSocketSet_; size_t appBytesReceived_; ///< Num of bytes received from socket size_t appBytesWritten_; ///< Num of bytes written to socket - bool isBufferMovable_{false}; // Pre-received data, to be returned to read callback before any data from the // socket. std::unique_ptr preReceivedData_; - int8_t readErr_{READ_NO_ERROR}; ///< The read error encountered, if any - std::chrono::steady_clock::time_point connectStartTime_; std::chrono::steady_clock::time_point connectEndTime_; std::chrono::milliseconds connectTimeout_{0}; + std::unique_ptr evbChangeCb_{nullptr}; + BufferCallback* bufferCallback_{nullptr}; bool tfoEnabled_{false}; bool tfoAttempted_{false}; @@ -1222,8 +1226,6 @@ class AsyncSocket : virtual public AsyncTransportWrapper { bool zeroCopyEnabled_{false}; bool zeroCopyVal_{false}; size_t zeroCopyWriteChainThreshold_{kDefaultZeroCopyThreshold}; - - std::unique_ptr evbChangeCb_{nullptr}; }; #ifdef _MSC_VER #pragma vtordisp(pop) -- 2.34.1