[Updated] D8850: dirstate: restore original estimation and update comment
joerg.sonnenberger (Joerg Sonnenberger)
phabricator at mercurial-scm.org
Fri Jul 31 13:14:40 UTC 2020
Closed by commit rHGad7006830106: dirstate: restore original estimation and update comment (authored by joerg.sonnenberger).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D8850?vs=22154&id=22158
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8850/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8850
AFFECTED FILES
mercurial/dirstate.py
CHANGE DETAILS
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1658,18 +1658,12 @@
if util.safehasattr(parsers, b'dict_new_presized'):
# Make an estimate of the number of files in the dirstate based on
- # its size. From a linear regression on a set of real-world repos,
- # all over 10,000 files, the size of a dirstate entry is 2 nodes
- # plus 45 bytes. The cost of resizing is significantly higher than the cost
- # of filling in a larger presized dict, so subtract 20% from the
- # size.
- #
- # This heuristic is imperfect in many ways, so in a future dirstate
- # format update it makes sense to just record the number of entries
- # on write.
- self._map = parsers.dict_new_presized(
- len(st) // ((2 * self._nodelen + 45) * 4 // 5)
- )
+ # its size. This trades wasting some memory for avoiding costly
+ # resizes. Each entry have a prefix of 17 bytes followed by one or
+ # two path names. Studies on various large-scale real-world repositories
+ # found 54 bytes a reasonable upper limit for the average path names.
+ # Copy entries are ignored for the sake of this estimate.
+ self._map = parsers.dict_new_presized(len(st) // 71)
# Python's garbage collector triggers a GC each time a certain number
# of container objects (the number being defined by
To: joerg.sonnenberger, #hg-reviewers, Alphare, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200731/ca3c830d/attachment-0002.html>
More information about the Mercurial-patches
mailing list