[PATCH 2 of 2] revset-phases: prefetch attributes in phases-related revsets

Augie Fackler raf at durin42.com
Fri Oct 17 09:23:34 CDT 2014


On Thu, Oct 16, 2014 at 06:37:57PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1413506818 25200
> #      Thu Oct 16 17:46:58 2014 -0700
> # Node ID 0a56b289c24b0ce697d6ec859852abf7856b2280
> # Parent  eaceb9c9e15a4fa0fa3efb53234782c56e4af9a6
> revset-phases: prefetch attributes in phases-related revsets

queued, thanks.

>
> Pre-fetching attributes gives a significant performance boost. Such is Python.
>
>
> draft()
> 0) wall 0.011661 comb 0.010000 user 0.010000 sys 0.000000 (best of 205)
> 1) wall 0.009804 comb 0.000000 user 0.000000 sys 0.000000 (best of 231)
>
> draft() - ::bookmark()
> 0) wall 0.014173 comb 0.010000 user 0.010000 sys 0.000000 (best of 177)
> 1) wall 0.012966 comb 0.010000 user 0.010000 sys 0.000000 (best of 182)
>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -741,12 +741,13 @@ def divergent(repo, subset, x):
>  def draft(repo, subset, x):
>      """``draft()``
>      Changeset in draft phase."""
>      # i18n: "draft" is a keyword
>      getargs(x, 0, 0, _("draft takes no arguments"))
> -    pc = repo._phasecache
> -    condition = lambda r: pc.phase(repo, r) == phases.draft
> +    phase = repo._phasecache.phase
> +    target = phases.draft
> +    condition = lambda r: phase(repo, r) == target
>      return subset.filter(condition, cache=False)
>
>  def extinct(repo, subset, x):
>      """``extinct()``
>      Obsolete changesets with obsolete descendants only.
> @@ -1289,12 +1290,13 @@ def present(repo, subset, x):
>  def public(repo, subset, x):
>      """``public()``
>      Changeset in public phase."""
>      # i18n: "public" is a keyword
>      getargs(x, 0, 0, _("public takes no arguments"))
> -    pc = repo._phasecache
> -    condition = lambda r: pc.phase(repo, r) == phases.public
> +    phase = repo._phasecache.phase
> +    target = phases.public
> +    condition = lambda r: phase(repo, r) == target
>      return subset.filter(condition, cache=False)
>
>  def remote(repo, subset, x):
>      """``remote([id [,path]])``
>      Local revision that corresponds to the given identifier in a
> @@ -1488,12 +1490,13 @@ def roots(repo, subset, x):
>  def secret(repo, subset, x):
>      """``secret()``
>      Changeset in secret phase."""
>      # i18n: "secret" is a keyword
>      getargs(x, 0, 0, _("secret takes no arguments"))
> -    pc = repo._phasecache
> -    condition = lambda x: pc.phase(repo, x) == phases.secret
> +    phase = repo._phasecache.phase
> +    target = phases.secret
> +    condition = lambda r: phase(repo, r) == target
>      return subset.filter(condition, cache=False)
>
>  def sort(repo, subset, x):
>      """``sort(set[, [-]key...])``
>      Sort set by keys. The default sort order is ascending, specify a key
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list