Patchwork D7882: lfs: avoid quadratic performance in processing server responses

login
register
mail settings
Submitter phabricator
Date Jan. 15, 2020, 1:17 p.m.
Message ID <fd2a20802e2a49c85b400df1b170b41d@localhost.localdomain>
Download mbox | patch
Permalink /patch/44363/
State Not Applicable
Headers show

Comments

phabricator - Jan. 15, 2020, 1:17 p.m.
Closed by commit rHGffac09da7a19: lfs: avoid quadratic performance in processing server responses (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7882?vs=19281&id=19292

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7882/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7882

AFFECTED FILES
  hgext/lfs/blobstore.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -503,7 +503,6 @@ 
         for k, v in headers:
             request.add_header(pycompat.strurl(k), pycompat.strurl(v))
 
-        response = b''
         try:
             with contextlib.closing(self.urlopener.open(request)) as res:
                 contentlength = res.info().get(b"content-length")
@@ -520,11 +519,14 @@ 
                     # blobstore
                     localstore.download(oid, res, contentlength)
                 else:
+                    blocks = []
                     while True:
                         data = res.read(1048576)
                         if not data:
                             break
-                        response += data
+                        blocks.append(data)
+
+                    response = b"".join(blocks)
                     if response:
                         ui.debug(b'lfs %s response: %s' % (action, response))
         except util.urlerr.httperror as ex: