[PATCH 1 of 2 V3] phase: compute phases in C

Matt Mackall mpm at selenic.com
Tue Mar 24 14:25:29 CDT 2015


On Tue, 2015-03-24 at 11:25 -0700, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon at fb.com>
> # Date 1427220009 25200
> #      Tue Mar 24 11:00:09 2015 -0700
> # Node ID 3be72e200cf2e5e1d5aced8d5e952fa5084b7ac0
> # Parent  b7f936f47f2b104a60840bae571e009742126afc
> phase: compute phases in C
> 
> Previously, the phase computation would grow much slower as the oldest draft
> commit in the repository grew older (which is very common in repos with evolve
> on) and the number of commits increase.
> By rewriting the computation in C we can speed it up from 700ms to 7ms on
> a large repository whose oldest draft commit is a year old.


> +static Py_ssize_t add_roots_get_min(indexObject *self, PyObject *list,
> +                                    int marker, char *phases)
> +{
> +	Py_ssize_t min_idx = index_length(self) + 1;
> +	if (PyList_Size(list) != 0) {
> +		PyObject *iter = PyObject_GetIter(list);
> +		if (iter == NULL)
> +			return -2;
> +		PyObject *iter_item;
> +		long iter_item_long;

The standard compiler to use with Python 2.x on Windows is VC 2.9, which
doesn't support C99-era mixed code and declarations. All declarations
need to be at the top of the function block. You might want to try
manually compiling with gcc -std=c89 to see if any other issues pop up.

We're also going to have a problem with Py_ssize_t, which doesn't exist
in Py2.4. But you can ignore that as I'm going to try to add a
compatibility typedef to util.h to fix that.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list