Blame SOURCES/0081-RHEL-7-v2v-rhv-upload-Disable-Nagle-algorithm.patch

e9bfca
From 61ae7a5e6deaac5cb9d9776829ea92ac0ebcc5f8 Mon Sep 17 00:00:00 2001
e9bfca
From: Nir Soffer <nirsof@gmail.com>
e9bfca
Date: Fri, 15 Jun 2018 22:57:32 +0300
e9bfca
Subject: [PATCH] RHEL 7: v2v: rhv-upload: Disable Nagle algorithm
e9bfca
e9bfca
When sending a PUT request, the http header may be sent in the first
e9bfca
packet when calling con.endheaders(). When we send the first chunk, the
e9bfca
kernel may delay the send because the header packet was not acked yet.
e9bfca
e9bfca
We have seen PUT requests delayed by 40 milliseconds on the server side
e9bfca
during virt-v2v upload to ovirt. Here is example log from current RHEL
e9bfca
virt-v2v version, uploading to RHV 4.2.3:
e9bfca
e9bfca
2018-06-12 17:04:01,750 INFO    (Thread-2) [images] Writing 52736 bytes
e9bfca
at offset 0 flush False to /path/to/image for ticket
e9bfca
374bec27-930d-4097-8e41-e4bc23324eb0
e9bfca
e9bfca
2018-06-12 17:04:01,790 INFO    (Thread-2) [directio] Operation stats:
e9bfca
<Clock(total=0.04, read=0.04, write=0.00)>
e9bfca
e9bfca
The server spent 40 milliseconds reading 52736 bytes form
e9bfca
rhv_upload_plugin running on the same host.
e9bfca
e9bfca
This issue was fixed in python 3.5 by using the TCP_NO_DELAY option
e9bfca
after connecting[1]. I backported this change from python 3.5.
e9bfca
e9bfca
I tested the same change using imageio example upload script. With this
e9bfca
change and with optimized PATCH requests, upload time of 4G sparse image
e9bfca
was reduced from 7 minutes to 1 minute.
e9bfca
e9bfca
See this ovirt patch for more details:
e9bfca
https://gerrit.ovirt.org/#/c/92276/
e9bfca
e9bfca
This change is needed only for python 2.
e9bfca
e9bfca
[1] https://bugs.python.org/issue23302
e9bfca
---
e9bfca
 v2v/rhv-upload-plugin.py | 14 +++++++++++++-
e9bfca
 1 file changed, 13 insertions(+), 1 deletion(-)
e9bfca
e9bfca
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
e9bfca
index 3d4ed1270..b262fb3d6 100644
e9bfca
--- a/v2v/rhv-upload-plugin.py
e9bfca
+++ b/v2v/rhv-upload-plugin.py
e9bfca
@@ -25,7 +25,7 @@ import ssl
e9bfca
 import sys
e9bfca
 import time
e9bfca
 
e9bfca
-from httplib import HTTPSConnection, HTTPConnection
e9bfca
+from httplib import HTTPSConnection as _HTTPSConnection, HTTPConnection
e9bfca
 from urlparse import urlparse
e9bfca
 
e9bfca
 import ovirtsdk4 as sdk
e9bfca
@@ -51,6 +51,18 @@ def byteify(input):
e9bfca
         return input
e9bfca
 params = None
e9bfca
 
e9bfca
+class HTTPSConnection(_HTTPSConnection):
e9bfca
+    def connect(self):
e9bfca
+        """
e9bfca
+        Using TCP_NO_DELAY avoids delays when sending small payload, such as
e9bfca
+        ovirt PATCH requests.
e9bfca
+
e9bfca
+        This issue was fixed in python 3.5, see:
e9bfca
+        https://bugs.python.org/issue23302
e9bfca
+        """
e9bfca
+        _HTTPSConnection.connect(self)
e9bfca
+        self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
e9bfca
+
e9bfca
 def config(key, value):
e9bfca
     global params
e9bfca
 
e9bfca
-- 
e9bfca
2.17.1
e9bfca