This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: More backref performance - no strncmp


On Thu, Oct 24, 2002 at 10:25:03AM +0200, Paolo Bonzini wrote:
> Actually, note that strncmp is not as extremely optimized as memcmp (the
> loop is unrolled, but no strange tricks).  So the most highly optimized
> function, in the context of regex matching, turns out to be the slowest
> because of the startup overheads!  Since my_memcmp is as unoptimized as
> strncmp, but is inlined and simpler, it makes sense that it is faster.

So how about using inline ra_memcmp which would compare the first char
and if it is not equal, fall back to normal memcmp? If real memcmp is slower
than the inline for large strings, then something is really wrong and it
should be fixed in the real memcmp implementation. Note you cannot be ever
sure regex won't have to compare 4K or longer strings, at which point
at least on most arches my_memcmp will be way slower (lot of memcmp
implementations compare 4 or 8 bytes at a time).

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]