Mercurial > public > mercurial-scm > hg-stable
comparison hgext/git/gitlog.py @ 52657:d7368933f4b0
git: switch changelog.shortest from LIKE to GLOB to speed up matching
For whatever reason, LIKE is way slower than GLOB. The slowdown is a
function of the number of commits in the repository.
The following data has been collected on a repository with approximately
1.2M commits. The numbers are in milliseconds and they represent the
latency of the changelog.shortest function as measured by time.time().
The shortest function was invoked via `hg log -l50 -T '{node|shortest}\n'`.
Min. 1st Qu. Median Mean 3rd Qu. Max.
279.0 284.3 419.8 381.7 421.3 426.2 (LIKE)
0.08535 0.10437 0.12231 0.11919 0.12779 0.21291 (GLOB)
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sat, 04 Jan 2025 09:38:51 -0500 |
parents | 7d2fc79a3e5a |
children | 86920d1f7632 |
comparison
equal
deleted
inserted
replaced
52656:482728ca94c1 | 52657:d7368933f4b0 |
---|---|
301 nodehex = hex(node) | 301 nodehex = hex(node) |
302 for attempt in range(minlength, len(nodehex) + 1): | 302 for attempt in range(minlength, len(nodehex) + 1): |
303 candidate = nodehex[:attempt] | 303 candidate = nodehex[:attempt] |
304 matches = int( | 304 matches = int( |
305 self._db.execute( | 305 self._db.execute( |
306 'SELECT COUNT(*) FROM changelog WHERE node LIKE ?', | 306 'SELECT COUNT(*) FROM changelog WHERE node GLOB ?', |
307 (pycompat.sysstr(candidate + b'%'),), | 307 (pycompat.sysstr(candidate + b'*'),), |
308 ).fetchone()[0] | 308 ).fetchone()[0] |
309 ) | 309 ) |
310 if matches == 1: | 310 if matches == 1: |
311 return candidate | 311 return candidate |
312 return nodehex | 312 return nodehex |