Commit Graph

191 Commits

Author SHA1 Message Date
Bryan O'Sullivan
98bb617e51 parsers: allow nt_find to signal an ambiguous match 2012-05-08 14:48:44 -07:00
Bryan O'Sullivan
2b933f4aaf parsers: factor out radix tree initialization 2012-05-08 14:48:39 -07:00
Bryan O'Sullivan
7434efb91b parsers: update ntrev when we stop scanning
This prevents us from inserting some nodes twice, wasting work.
2012-05-08 14:46:06 -07:00
Bryan O'Sullivan
6f88d16cf2 parsers: use the correct maximum radix tree depth
Previously, we would not use more than half of a SHA-1 hash when
constructing and searching the tree.
2012-05-08 14:46:04 -07:00
Matt Mackall
d8dfd80d76 parsers: fix refcount bug on corrupt index
When we encounter a corrupt index, we "fail" the init but our
destructor still gets called. On some systems, this was causing us to
attempt to decref a dangling to self->data.
2012-05-07 15:40:50 -05:00
Adrian Buehlmann
4482ec8070 parsers: statically initializing tp_new to PyType_GenericNew is not portable
As detailed on http://docs.python.org/extending/newtypes.html (quote):

  "In this case, we can just use the default implementation provided by the API
  function PyType_GenericNew(). We’d like to just assign this to the
  tp_new slot, but we can’t, for portability sake. On some platforms or
  compilers, we can’t statically initialize a structure member with a function
  defined in another C module, so, instead, we’ll assign the tp_new slot in the
  module initialization function just before calling PyType_Ready()."

Fixes "gcc (GCC) 3.4.5 (mingw-vista special r3)" complaining with:

  mercurial/parsers.c:1096: error: initializer element is not constant
  mercurial/parsers.c:1096: error: (near initialization for `indexType.tp_new')
2012-05-08 11:20:07 +02:00
Bryan O'Sullivan
1eb25dc7ef parsers: fix refcount leak, simplify init of index (issue3417)
This is most easily verified using valgrind on a long-running
process, as the leak has no visible consequences during normal
one-shot command usage.

In one window:

  valgrind --leak-check=full --suppressions=valgrind-python.supp \
    python ./hg serve

In another:

  for ((i=0;i<100;i++)); do
    curl -s http://localhost:8000/file/tip/README >/dev/null
  done

valgrind should report no leaks.
2012-05-02 14:37:44 -07:00
Matt Mackall
0fa9895915 util.h: replace ntohl/htonl with get/putbe32 2012-04-16 11:26:00 -05:00
Bryan O'Sullivan
dc46676e81 parsers: use base-16 trie for faster node->rev mapping
This greatly speeds up node->rev lookups, with results that are
often user-perceptible: for instance, "hg --time log" of the node
associated with rev 1000 on a linux-2.6 repo improves from 0.3
seconds to 0.03.  I have not found any instances of slowdowns.

The new perfnodelookup command in contrib/perf.py demonstrates the
speedup more dramatically, since it performs no I/O.  For a single
lookup, the new code is about 40x faster.

These changes also prepare the ground for the possibility of further
improving the performance of prefix-based node lookups.
2012-04-12 14:05:59 -07:00
Matt Mackall
0ba5fb4cce util.h: more Python 2.4 fixes 2012-04-10 16:53:29 -05:00
Matt Mackall
fd4256c9b1 util.h: unify some common platform tweaks 2012-04-10 12:07:14 -05:00
Bryan O'Sullivan
774e52cd41 parsers: fix a memleak, and add a clearcaches method to the index
This change also fixes a nasty memory leak: previously, self->caches
was not being freed.

The new clearcaches method lets us benchmark with finer granularity,
as it lets us separate the cost of loading a revlog index from those
of populating and accessing the cache data structures.
2012-04-06 00:28:36 -07:00
Bryan O'Sullivan
849e7f15fd parsers: incrementally parse the revlog index in C
We only parse entries in a revlog index file when they are actually
needed, and cache them when first requested.

This makes a huge difference to performance on large revlogs when
accessing the tip revision or performing a handful of numeric lookups
(very common cases).  For instance, "hg --time tip --template {node}"
on a tree with 300,000 revs takes 0.15 before, 0.02 after.

Even for revlog-intensive operations (e.g. running "hg log" to
completion), the lazy approach is about 1% faster than the eager
parse_index2.
2012-04-05 13:00:35 -07:00
Bryan O'Sullivan
3fbc354649 parsers: strictly check for 20-byte hashes where they're required 2012-05-12 20:25:33 +02:00
Matt Mackall
cb69aaee4e parsers: avoid pointer aliasing
Newer versions of GCC have aggressive pointer alias optimizations that
might get fooled by our pointer manipulations. These issues shouldn't
be encountered in practice because distutils compiles extensions with
-fno-strict-alias but the code was not valid according to the standard.
2011-08-10 13:40:01 -05:00
Martin Geisler
a76e121863 backout of e4cb9628354c
Matt and a majority of crew did not like this approach.
2011-01-27 11:15:08 +01:00
Martin Geisler
d23e1973c2 specify C indention style using Emacs file local variables 2011-01-26 12:05:01 +01:00
Benoit Boissinot
6c18ebff9d parsers.c: fix comment 2011-01-15 12:44:28 +01:00
Matt Mackall
846d35e24f revlog: only build the nodemap on demand 2011-01-11 17:01:04 -06:00
Renato Cunha
e7d8ae78a9 parsers.c: Added support for py3k.
This patch adds support for py3k in parsers.c. This is accomplished by including
a header file responsible for abstracting the API differences between python 2
and python 3.
2010-06-15 19:49:56 -03:00
Matt Mackall
69f9d533aa parsers: fix some signed comparison issues
(spotted by Steve Borho)
2010-02-13 17:37:44 -06:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Nicolas Dumazet
9e39f64d52 parsers.c: parse_manifest: fixing refcount of flags
When flags was DECREF'ed, scope was referencing to the outer variable,
outside of the block.
It was in fact always NULL: the real Python object was never decref'ed.
2009-08-27 14:15:04 +02:00
Thomas Arendsen Hein
8999e196bc Some additional space/tab cleanups 2008-10-20 15:19:05 +02:00
Dirkjan Ochtman
f5ea74b223 clean up trailing spaces, leading spaces in C 2008-10-20 14:57:04 +02:00
Benoit Boissinot
bc6e674802 merge with crew 2008-10-19 20:29:41 +02:00
Benoit Boissinot
fdd2a14dd6 parsers.c: do not try to untrack after a failure 2008-10-19 20:17:06 +02:00
Benoit Boissinot
64b6a68b1b parsers.c: fix integer overflows
thanks to zzuf for helping finding those
2008-10-19 20:16:37 +02:00
Thomas Arendsen Hein
1493b09823 Merge with crew 2008-10-19 19:10:26 +02:00
Benoit Boissinot
0a350d3213 parsers.c: there is no reference to data_obj, so it shouldn't be decref'ed 2008-10-19 16:11:23 +02:00
Thomas Arendsen Hein
e5350e7597 Copy index before parsing to enforce alignment with inline data present.
Fixes issue1348 (Bus error in parsers.c) on Solaris/sparc.
2008-10-19 15:08:30 +02:00
Benoit Boissinot
1abf8f679b index parser: fix refcounting in case of errors, refactor
due to incorrect refcounting, on a bad revlog it was failing with:
*** glibc detected *** /usr/bin/python: corrupted double-linked list: 0x0816d318 ***
and a backtrace.
2008-10-19 01:26:46 +02:00
Benoit Boissinot
d3445ca0d4 merge with crew 2008-10-18 20:39:08 +02:00
Benoit Boissinot
6de97a000b revlog parser: use ntohl() instead of ntohll() (fix endianness issues) 2008-10-18 20:23:46 +02:00
Bernhard Leiner
7989d67052 C implementation of revlog index parsing 2008-10-17 01:03:38 +02:00
Matt Mackall
1c5fcf7d0e dirstate: C parsing extension 2008-10-12 15:21:08 -05:00
Matt Mackall
b98e1b895d parsers: speed up hex decoding for manifests 2008-10-12 15:21:08 -05:00
Matt Mackall
9124c02fed parsers: clean up whitespace 2008-10-12 15:21:08 -05:00
Dhruva Krishnamurthy
343c16ff75 Fix missing uint64_t definition in parsers.c under Windows 2008-10-18 14:43:20 +02:00
Benoit Boissinot
5e3666db4b fix const annotation warning 2008-03-28 19:47:22 +01:00
Bryan O'Sullivan
8a988e392e manifest: improve parsing performance by 8x via a new C extension 2008-03-26 10:12:10 -07:00