mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

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

97ae69
From 61ae7a5e6deaac5cb9d9776829ea92ac0ebcc5f8 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
97ae69
index 3d4ed1270..b262fb3d6 100644
97ae69
--- a/v2v/rhv-upload-plugin.py
97ae69
+++ b/v2v/rhv-upload-plugin.py
97ae69
@@ -25,7 +25,7 @@ import ssl
97ae69
 import sys
97ae69
 import time
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
97ae69
@@ -51,6 +51,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
-- 
c71420
2.20.1
97ae69