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