]> arthur.barton.de Git - bup.git/commitdiff
server: only suggest a max of one pack per receive-objects cycle. bup-0.13
authorAvery Pennarun <apenwarr@gmail.com>
Sun, 21 Mar 2010 20:48:23 +0000 (16:48 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Sun, 21 Mar 2010 20:50:06 +0000 (16:50 -0400)
Since the client only handles one at a time and forgets the others anyway,
suggesting others is a bit of a waste of time... and because of the cheating
way we figure out which index to suggest when using a midx, suggesting packs
is more expensive than it should be anyway.

The "correct" fix in the long term will be to make the client accept
multiple suggestions at once, plus make midx files a little smarter about
figuring out which pack is the one that needs to be suggested.  But in the
meantime, this makes things a little nicer: there are fewer confusing log
messages from the server, and a lot less disk grinding related to looking
into which pack to suggest, followed by finding out that we've already
suggested that pack anyway.

cmd/server-cmd.py

index 495fedaa915253056fee75ee5887ea27edeb8dfb..c74ffbffb43339f6b6bd9f0345dfc4f939a5375a 100755 (executable)
@@ -76,7 +76,12 @@ def receive_objects(conn, junk):
         (type, content) = git._decode_packobj(buf)
         sha = git.calc_hash(type, content)
         oldpack = w.exists(sha)
-        if oldpack and (oldpack == True or oldpack.endswith('.midx')):
+        # FIXME: we only suggest a single index per cycle, because the client
+        # is currently dumb to download more than one per cycle anyway.
+        # Actually we should fix the client, but this is a minor optimization
+        # on the server side.
+        if not suggested and \
+          oldpack and (oldpack == True or oldpack.endswith('.midx')):
             # FIXME: we shouldn't really have to know about midx files
             # at this layer.  But exists() on a midx doesn't return the
             # packname (since it doesn't know)... probably we should just
@@ -90,7 +95,7 @@ def receive_objects(conn, junk):
             assert(oldpack != True)
             assert(not oldpack.endswith('.midx'))
             w.objcache.refresh(skip_midx = False)
-        if oldpack:
+        if not suggested and oldpack:
             assert(oldpack.endswith('.idx'))
             (dir,name) = os.path.split(oldpack)
             if not (name in suggested):