obsolete: avoid slow, generic date parsing
Simple profiling of `hg log -r .` revealed ~18,000 calls to
mercurial.i18n.gettext() on the author's repository. The
culprit was 3 _() calls in util.parsedate() multiplied by
~6000 obsmarkers originating from the parsing of obsmarkers.
Changing the obsmarker code to parse the stored format of
dates instead of going through a generic path eliminates these
gettext() lookups and makes `hg log -r .` execute ~10% faster
on the author's repo. The performance gain is proportional to
the number of obsmarkers.
The author attempted to patch util.parsedate() to avoid the
gettext() lookups. However, that code is whacky and the author
is jet lagged, so the approach was not attempted.
--- a/mercurial/obsolete.py Fri Aug 29 12:06:31 2014 +0200
+++ b/mercurial/obsolete.py Fri Aug 29 18:00:44 2014 +0200
@@ -170,8 +170,9 @@
off += mdsize
meta = decodemeta(metadata)
try:
- date = util.parsedate(decodemeta(metadata).pop('date', '0 0'))
- except util.Abort:
+ when, offset = decodemeta(metadata).pop('date', '0 0').split(' ')
+ date = float(when), int(offset)
+ except ValueError:
date = (0., 0)
parents = None
if 'p2' in meta: