Remove _ensure_flush() from SSYNC receiver
The Receiver._ensure_flush() method in ssync_receiver.py has
the following comment:
Sends a blank line sufficient to flush buffers.
This is to ensure Eventlet versions that don't support
eventlet.minimum_write_chunk_size will send any previous data
buffered.
If https://bitbucket.org/eventlet/eventlet/pull-request/37
ever gets released in an Eventlet version, we should make
this yield only for versions older than that.
The reference pull request was included with eventlet 0.14 [1] and
swift now requires >=0.16.1 so it is safe to remove _ensure_flush()
and save > 8k bytes per SSYNC response.
[1] 4bd654205a
Change-Id: I367e9a6e92b7ea75fe7e5795cded212657de57ed
This commit is contained in:
parent
3aa06f185a
commit
191f2a00bd
@ -89,8 +89,9 @@ class Receiver(object):
|
|||||||
try:
|
try:
|
||||||
# Double try blocks in case our main error handlers fail.
|
# Double try blocks in case our main error handlers fail.
|
||||||
try:
|
try:
|
||||||
for data in self._ensure_flush():
|
# Need to send something to trigger wsgi to return response
|
||||||
yield data
|
# headers and kick off the ssync exchange.
|
||||||
|
yield '\r\n'
|
||||||
# If semaphore is in use, try to acquire it, non-blocking, and
|
# If semaphore is in use, try to acquire it, non-blocking, and
|
||||||
# return a 503 if it fails.
|
# return a 503 if it fails.
|
||||||
if self.app.replication_semaphore:
|
if self.app.replication_semaphore:
|
||||||
@ -142,20 +143,6 @@ class Receiver(object):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass # We're okay with the above failing.
|
pass # We're okay with the above failing.
|
||||||
|
|
||||||
def _ensure_flush(self):
|
|
||||||
"""
|
|
||||||
Sends a blank line sufficient to flush buffers.
|
|
||||||
|
|
||||||
This is to ensure Eventlet versions that don't support
|
|
||||||
eventlet.minimum_write_chunk_size will send any previous data
|
|
||||||
buffered.
|
|
||||||
|
|
||||||
If https://bitbucket.org/eventlet/eventlet/pull-request/37
|
|
||||||
ever gets released in an Eventlet version, we should make
|
|
||||||
this yield only for versions older than that.
|
|
||||||
"""
|
|
||||||
yield ' ' * eventlet.wsgi.MINIMUM_CHUNK_SIZE + '\r\n'
|
|
||||||
|
|
||||||
def initialize_request(self):
|
def initialize_request(self):
|
||||||
"""
|
"""
|
||||||
Basic validation of request and mount check.
|
Basic validation of request and mount check.
|
||||||
@ -163,7 +150,9 @@ class Receiver(object):
|
|||||||
This function will be called before attempting to acquire a
|
This function will be called before attempting to acquire a
|
||||||
replication semaphore lock, so contains only quick checks.
|
replication semaphore lock, so contains only quick checks.
|
||||||
"""
|
"""
|
||||||
# The following is the setting we talk about above in _ensure_flush.
|
# This environ override has been supported since eventlet 0.14:
|
||||||
|
# https://bitbucket.org/eventlet/eventlet/commits/ \
|
||||||
|
# 4bd654205a4217970a57a7c4802fed7ff2c8b770
|
||||||
self.request.environ['eventlet.minimum_write_chunk_size'] = 0
|
self.request.environ['eventlet.minimum_write_chunk_size'] = 0
|
||||||
self.device, self.partition, self.policy = \
|
self.device, self.partition, self.policy = \
|
||||||
request_helpers.get_name_and_placement(self.request, 2, 2, False)
|
request_helpers.get_name_and_placement(self.request, 2, 2, False)
|
||||||
@ -250,8 +239,6 @@ class Receiver(object):
|
|||||||
yield '\r\n'.join(object_hashes)
|
yield '\r\n'.join(object_hashes)
|
||||||
yield '\r\n'
|
yield '\r\n'
|
||||||
yield ':MISSING_CHECK: END\r\n'
|
yield ':MISSING_CHECK: END\r\n'
|
||||||
for data in self._ensure_flush():
|
|
||||||
yield data
|
|
||||||
|
|
||||||
def updates(self):
|
def updates(self):
|
||||||
"""
|
"""
|
||||||
@ -385,5 +372,3 @@ class Receiver(object):
|
|||||||
(failures, successes))
|
(failures, successes))
|
||||||
yield ':UPDATES: START\r\n'
|
yield ':UPDATES: START\r\n'
|
||||||
yield ':UPDATES: END\r\n'
|
yield ':UPDATES: END\r\n'
|
||||||
for data in self._ensure_flush():
|
|
||||||
yield data
|
|
||||||
|
@ -1830,14 +1830,14 @@ class TestSsyncReplication(TestBaseSsync):
|
|||||||
self.assertFalse(results['tx_updates'])
|
self.assertFalse(results['tx_updates'])
|
||||||
self.assertFalse(results['rx_updates'])
|
self.assertFalse(results['rx_updates'])
|
||||||
# Minimal receiver response as read by sender:
|
# Minimal receiver response as read by sender:
|
||||||
# 2 * 4098 <-- _ensure_flush() twice
|
# 2 <-- initial \r\n to start ssync exchange
|
||||||
# + 23 <-- :MISSING CHECK START\r\n
|
# + 23 <-- :MISSING CHECK START\r\n
|
||||||
# + 2 <-- \r\n (minimal missing check response)
|
# + 2 <-- \r\n (minimal missing check response)
|
||||||
# + 21 <-- :MISSING CHECK END\r\n
|
# + 21 <-- :MISSING CHECK END\r\n
|
||||||
# + 17 <-- :UPDATES START\r\n
|
# + 17 <-- :UPDATES START\r\n
|
||||||
# + 15 <-- :UPDATES END\r\n
|
# + 15 <-- :UPDATES END\r\n
|
||||||
# TOTAL = 8274
|
# TOTAL = 80
|
||||||
self.assertEqual(8274, trace.get('readline_bytes'))
|
self.assertEqual(80, trace.get('readline_bytes'))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user