Subject: Re: pcre performance, was Re: git log filtering

From: Paolo Bonzini <[email-masked]>
Date: Wed, 07 Mar 2007 19:03:32 +0100

> Result: external grep wins hands-down. GNU regex loses hands-down. pcre 
> seems to be better than glibc's regex engine, and gains ever so slightly 
> when using NO_MMAP.

Indeed GNU regex 0.12 loses, and that's why it was rewritten for (IIRC)
glibc 2.3.  Older glibc's use code derived from GNU regex 0.12; but the
old GNU regex code is dead in general (maybe it survives in Emacs -- but
I don't remember), and the glibc regex code can be used by external
programs via gnulib.

glibc is slower than PCRE mostly because it is internationalized.  So
for example it supports things like stra[.ss.]e matching both strasse
and straße in a German locale, or [[=a=]] matching aàáäâ and possibly
more variations.  In theory.  In practice I couldn't make it work
while writing this message...

External grep wins hands-down because it's a DFA engine.  If the regex
uses backreferences (or the above esoteric constructs), however, external
grep will not be able to give a definite answer using the fast engine,
and will fall back to glibc regex.

Paolo