Mercurial > hg
comparison mercurial/obsolete.py @ 22309:a65697c3f20e
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.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 29 Aug 2014 18:00:44 +0200 |
parents | 10e87c67f1c7 |
children | 3363f2d36015 |
comparison
equal
deleted
inserted
replaced
22308:246b6a9c8d8f | 22309:a65697c3f20e |
---|---|
168 'short, %d bytes expected, got %d') | 168 'short, %d bytes expected, got %d') |
169 % (mdsize, len(metadata))) | 169 % (mdsize, len(metadata))) |
170 off += mdsize | 170 off += mdsize |
171 meta = decodemeta(metadata) | 171 meta = decodemeta(metadata) |
172 try: | 172 try: |
173 date = util.parsedate(decodemeta(metadata).pop('date', '0 0')) | 173 when, offset = decodemeta(metadata).pop('date', '0 0').split(' ') |
174 except util.Abort: | 174 date = float(when), int(offset) |
175 except ValueError: | |
175 date = (0., 0) | 176 date = (0., 0) |
176 parents = None | 177 parents = None |
177 if 'p2' in meta: | 178 if 'p2' in meta: |
178 parents = (meta.pop('p1', None), meta.pop('p2', None)) | 179 parents = (meta.pop('p1', None), meta.pop('p2', None)) |
179 elif 'p1' in meta: | 180 elif 'p1' in meta: |