Re: [PATCH V2 2/2] module: Fix performance regression on modules with large symbol tables

Rusty Russell
2011-11-16T02:33:07Z

On Mon, 14 Nov 2011 08:48:52 +0000, "Jan Beulich" <JBeulich@suse.com> wrote:
> > + name = &mod->strtab[src->st_name];
> > + if (unlikely(!test_bit(src->st_name, info->strmap))) {
> > + /* Symbol name has already been copied; find it. */
> > + char *dup;
> > +
> > + for (dup = mod->core_strtab; strcmp(dup, name); dup++)
> > + BUG_ON(dup > s);
>
> Aren't you concerned that this again will be rather slow? It would be
> pretty easy to accelerate by comparing only with the tail of each string
> (as nothing else can possibly match), moving from string to string instead
> of from character to character.

Kevin's central thesis is that this is actually really unusual.

I'm not sure how much faster a tail search would be in practice. We're
still scanning the string. Perhaps a "dup[0] == name[0] &&" would
optimize it almost as well, if gcc doesn't already?

Kevin, you're probably in an optimal position to get numbers on this?

Thanks,
Rusty.