Patchwork bundlerepo: let bundle repo look in the _mancache

login
register
mail settings
Submitter Durham Goode
Date Sept. 28, 2015, 5:50 p.m.
Message ID <0ecba52cd14deca2bb75.1443462626@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/10673/
State Accepted
Headers show

Comments

Durham Goode - Sept. 28, 2015, 5:50 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1443461256 25200
#      Mon Sep 28 10:27:36 2015 -0700
# Node ID 0ecba52cd14deca2bb755e02cb5a0f56e194762b
# Parent  a0eff7ebc2aebb32cf4c8da276104102ff37d786
bundlerepo: let bundle repo look in the _mancache

When looking up a base revision, we were ignoring the contents that were already
available in the manifest's _mancache. This patch allows us to use that data
instead of reading from the revlog.

This is useful in our pushrebase extension (which allows rebasing on the server
side during a push) because it allows us to prefetch the bundle base manifest
before aquiring the repo lock (1 second saving), which means doing less work inside the lock,
which means a 20% higher commit rate.
Augie Fackler - Sept. 28, 2015, 6:32 p.m.
On Mon, Sep 28, 2015 at 10:50:26AM -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1443461256 25200
> #      Mon Sep 28 10:27:36 2015 -0700
> # Node ID 0ecba52cd14deca2bb755e02cb5a0f56e194762b
> # Parent  a0eff7ebc2aebb32cf4c8da276104102ff37d786
> bundlerepo: let bundle repo look in the _mancache

queued, thanks

>
> When looking up a base revision, we were ignoring the contents that were already
> available in the manifest's _mancache. This patch allows us to use that data
> instead of reading from the revlog.
>
> This is useful in our pushrebase extension (which allows rebasing on the server
> side during a push) because it allows us to prefetch the bundle base manifest
> before aquiring the repo lock (1 second saving), which means doing less work inside the lock,
> which means a 20% higher commit rate.
>
> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
> --- a/mercurial/bundlerepo.py
> +++ b/mercurial/bundlerepo.py
> @@ -195,7 +195,15 @@ class bundlemanifest(bundlerevlog, manif
>                                linkmapper)
>
>      def baserevision(self, nodeorrev):
> -        return manifest.manifest.revision(self, nodeorrev)
> +        node = nodeorrev
> +        if isinstance(node, int):
> +            node = self.node(node)
> +
> +        if node in self._mancache:
> +            result = self._mancache[node][0].text()
> +        else:
> +            result = manifest.manifest.revision(self, nodeorrev)
> +        return result
>
>  class bundlefilelog(bundlerevlog, filelog.filelog):
>      def __init__(self, opener, path, bundle, linkmapper):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -195,7 +195,15 @@  class bundlemanifest(bundlerevlog, manif
                               linkmapper)
 
     def baserevision(self, nodeorrev):
-        return manifest.manifest.revision(self, nodeorrev)
+        node = nodeorrev
+        if isinstance(node, int):
+            node = self.node(node)
+
+        if node in self._mancache:
+            result = self._mancache[node][0].text()
+        else:
+            result = manifest.manifest.revision(self, nodeorrev)
+        return result
 
 class bundlefilelog(bundlerevlog, filelog.filelog):
     def __init__(self, opener, path, bundle, linkmapper):