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

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