[PATCH] D39609: Remove a std::map and std::set that show up in LLD profiles

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 15:18:33 PDT 2017


rnk added a comment.

In https://reviews.llvm.org/D39609#915412, @ruiu wrote:

> Is Config->GCRoot that slow? If so, if you replace it with SetVector, is it still slow?


We spend 350ms out of 52s in the GCRoot->insert call, so I guess 0.6%.

I suspect that the majority of this comes from this loop over exports:

  // Windows specific -- Make sure we resolve all dllexported symbols.
  for (Export &E : Config->Exports) {
    if (!E.ForwardTo.empty())
      continue;
    E.Sym = addUndefined(E.Name);
    if (!E.Directives)
      Symtab->mangleMaybe(E.Sym);
  }

Consider that there are many duplicate /export: directives in each object file. Therefore, most calls to addUndefined will be for symbols that we already have. The code I'm changing does one lookup of the string (this is necessary) and then a set lookup of the SymbolBody pointer. That set lookup is completely unnecessary, though, if we add the GCRoot bit to SymbolBody.

I haven't tried SetVector, I don't think the performance difference will be measurable. My goal isn't to compare containers, it's to eliminate the pointer set lookup completely.


https://reviews.llvm.org/D39609





More information about the llvm-commits mailing list