[PATCH 1 of 2] phase: compute phases in C
Adrian Buehlmann
adrian at cadifra.com
Fri Mar 20 16:30:27 CDT 2015
On 2015-03-20 22:08, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon at fb.com>
> # Date 1426874708 25200
> # Fri Mar 20 11:05:08 2015 -0700
> # Node ID 1c9600e6ceab57b48827292c7b01ed9a625da1fd
> # 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.
>
> diff --git a/mercurial/parsers.c b/mercurial/parsers.c
> --- a/mercurial/parsers.c
> +++ b/mercurial/parsers.c
> @@ -13,6 +13,7 @@
> #include <string.h>
>
> #include "util.h"
> +#define MIN(a, b) (((a)<(b))?(a):(b))
>
> static char *versionerrortext = "Python minor version mismatch";
>
> @@ -911,6 +912,143 @@
> }
> }
>
> +static long add_roots_get_min(indexObject *self, PyObject *list, int marker,
> + char *phases)
> +{
> + if (PyList_Size(list) != 0) {
> + long min_idx = index_length(self) + 1;
In case anyone still cares about the Windows platform: C's 'long' type
is notoriously problematic, as Windows uses the LLP64 model for 64-bit
target, which means long is 32 bit - which may surprise Linux folks.
More information about the Mercurial-devel
mailing list