Patchwork D3453: revlog: use radix tree also for matching keys shorter than 4 hex digits

login
register
mail settings
Submitter phabricator
Date May 6, 2018, 4:53 a.m.
Message ID <differential-rev-PHID-DREV-3zarbgrzxdvt6m3wxvoq-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31289/
State Superseded
Headers show

Comments

phabricator - May 6, 2018, 4:53 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I don't know what the reason for the 4-digit limit was, and I can't
  think of any real disadvantages of using the radix tree also when the
  requested minimum length is short. This speeds up `hg log -T
  '{shortest(node,1)}\n'` from 2m16s to 4.5s by making that not fall
  back to pure code.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3453

AFFECTED FILES
  mercurial/cext/revlog.c

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
Yuya Nishihara - May 7, 2018, 1:05 p.m.
"I don't know what the reason for the 4-digit limit was,"

I guessed it would avoid building a full radix tree where a given hash
was likely to be ambiguous, but maybe I'm wrong since it seems clear that
linear scan in Python wouldn't be faster than building radix tree in C.
phabricator - May 7, 2018, 1:09 p.m.
yuja added a comment.


  "I don't know what the reason for the 4-digit limit was,"
  
  I guessed it would avoid building a full radix tree where a given hash
  was likely to be ambiguous, but maybe I'm wrong since it seems clear that
  linear scan in Python wouldn't be faster than building radix tree in C.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3453

To: martinvonz, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -1251,7 +1251,7 @@ 
 	if (!PyArg_ParseTuple(args, PY23("s#", "y#"), &node, &nodelen))
 		return NULL;
 
-	if (nodelen < 4) {
+	if (nodelen < 1) {
 		PyErr_SetString(PyExc_ValueError, "key too short");
 		return NULL;
 	}