[PATCH 1 of 2 V5] delta: have a native implementation of _findsnapshot

Boris FELD boris.feld at octobus.net
Fri Jan 4 03:49:04 EST 2019


On 03/01/2019 09:40, Yuya Nishihara wrote:
> On Wed, 02 Jan 2019 12:33:25 +0100, Boris Feld wrote:
>> # HG changeset patch
>> # User Boris Feld <boris.feld at octobus.net>
>> # Date 1545297320 -3600
>> #      Thu Dec 20 10:15:20 2018 +0100
>> # Node ID aef438c9ecdbae3efb5f57f56041109cd5acda39
>> # Parent  9e593db5f1a1b08f812591439c831ace55bca321
>> # EXP-Topic sparse-revlog
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r aef438c9ecdb
>> delta: have a native implementation of _findsnapshot
>>
>> The function might traverse a lot of revision, a native implementation get
>> significantly faster.
>>
>> example affected manifest write
>> before: 0.114989
>> after:  0.067141 (-42%)
>>
>> diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
>> --- a/mercurial/cext/revlog.c
>> +++ b/mercurial/cext/revlog.c
>> @@ -1050,6 +1050,75 @@ static PyObject *index_issnapshot(indexO
>>  	return PyBool_FromLong((long)issnap);
>>  }
>>  
>> +static PyObject *index_findsnapshots(indexObject *self, PyObject *args)
>> +{
>> +	Py_ssize_t start_rev;
>> +	PyObject *cache;
>> +	Py_ssize_t base;
>> +	Py_ssize_t rev;
>> +	int issnap;
>> +	PyObject *key = NULL;
>> +	PyObject *allvalues = NULL;
>> +	PyObject *value = NULL;
> Nit: several variables can be moved inside the "for" loop.

Okay moving them.

A couple of weeks ago, you moved a variable declaration higher in the
function because of some windows thingy. Can you elaborate on the
special case you were trying to avoid?
>
>> +	for (rev = start_rev; rev < length; rev++) {
>> +		Py_CLEAR(key);
>> +		Py_CLEAR(value);
>> +		allvalues = NULL;
> and we won't have to nullify the allvalues if it's declared inside the loop.
Good catch, thanks
>
>> +	}
>> +	Py_INCREF(Py_None);
>> +	return Py_None;
> Py_RETURN_NONE;
>
>> +bail:
>> +	Py_XDECREF(key);
>> +	Py_XDECREF(value);
>> +	Py_RETURN_NONE;
> return NULL;
oops, thanks for catching that.
>
>> +}
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list