Patchwork [6,of,6,V2] obsstore: cache size computation for fm1 node

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 4, 2014, 3:16 p.m.
Message ID <6289daa98b37da9e9948.1417706179@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/7002/
State Accepted
Headers show

Comments

Pierre-Yves David - Dec. 4, 2014, 3:16 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1417073013 28800
#      Wed Nov 26 23:23:33 2014 -0800
# Node ID 6289daa98b37da9e9948db4f8fdda17b0a0f507b
# Parent  786d60c87bc62b1e5ce5c479d9ebc3973f6b3fa3
obsstore: cache size computation for fm1 node

We have two different types of node type (sha1 and sha256, only sha1 is used
now) and therefor different sizes for them. We now compute the value once
instead of redoing the computation every loop. This has no visible performance
impact.
Matt Mackall - Dec. 8, 2014, 11:35 p.m.
On Thu, 2014-12-04 at 07:16 -0800, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1417073013 28800
> #      Wed Nov 26 23:23:33 2014 -0800
> # Node ID 6289daa98b37da9e9948db4f8fdda17b0a0f507b
> # Parent  786d60c87bc62b1e5ce5c479d9ebc3973f6b3fa3
> obsstore: cache size computation for fm1 node

These are queued for default, thanks.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -274,10 +274,12 @@  def _fm0decodemeta(data):
 # - remaining bytes: the metadata, each (key, value) pair after the other.
 _fm1version = 1
 _fm1fixed = '>IdhHBBB20s'
 _fm1nodesha1 = '20s'
 _fm1nodesha256 = '32s'
+_fm1nodesha1size = _calcsize(_fm1nodesha1)
+_fm1nodesha256size = _calcsize(_fm1nodesha256)
 _fm1fsize = _calcsize(_fm1fixed)
 _fm1parentnone = 3
 _fm1parentshift = 14
 _fm1parentmask = (_fm1parentnone << _fm1parentshift)
 _fm1metapair = 'BB'
@@ -296,13 +298,14 @@  def _fm1readmarkers(data, off=0):
         if numpar == _fm1parentnone:
             numpar = None
         # build the date tuple (upgrade tz minutes to seconds)
         date = (seconds, tz * 60)
         _fm1node = _fm1nodesha1
+        fnodesize = _fm1nodesha1size
         if flags & usingsha256:
             _fm1node = _fm1nodesha256
-        fnodesize = _calcsize(_fm1node)
+            fnodesize = _fm1nodesha256size
         # read replacement
         sucs = ()
         if numsuc:
             s = (fnodesize * numsuc)
             cur = data[off:off + s]