[patch] syntax:plain for .hgignore

Matt Mackall mpm at selenic.com
Thu Sep 13 14:32:55 CDT 2007

On Thu, Sep 13, 2007 at 08:18:46PM +0200, Guido Ostkamp wrote:
> On Wed, 12 Sep 2007, Matt Mackall wrote:
> >Can you mail your .hgignore file? Privately and/or obfuscated is fine.
> I hope my private email with the hgignore has reached you in the meantime.
> May I kindly ask, whether you have been able to reproduce the problem on 
> your system?

Just took a stab at it. Adding syntax:regex before all the fixed
patterns took it from .610s to .329s for an empty repo. Our glob to
regex conversion could use some optimizing, apparently. Folding a
bunch of fixed patterns together by hand took that down to .239s. Time
to run hg -v is .078, so the ignore pattern building got 3.3 times
faster and the resulting ignore file is 73 lines and 13k vs 624 lines
and 23k in the original.

Now running this ignore file in my kernel repo:

no ignore file: 1.301s
your original:  2.874s
with regexp:    2.151s
with folding:   1.535s

Assuming your ignore file isn't trimming substantial work from the
tree walk, we can figure that 2.874 - 1.301 - (.610 - .078) = 1.041s
for matching in your original, vs 1.535 - 1.301 - (.239 - .078) =
.073s for matching for my improved version (14.2x).

Does this kind of speed improvement even make sense? Yes. All of the
regex matching of the form foo/bar/baz is a simple string match. If we
compare foo/bar/baz|foo/bar/quux with foo/bar/(baz|quux), we can very
often eliminate an entire match immediately. As my optimized ignore
file has about a tenth of the full path patterns as yours, it's doing
a lot less backtracking work.

Mathematics is the supreme nostalgia of our time.

More information about the Mercurial-devel mailing list