This is an archive of the discontinued LLVM Phabricator instance.

Bypass GetNormalizedFile when not necessary...
ClosedPublic

Authored by jingham on Mar 23 2017, 11:37 AM.

Details

Reviewers
clayborg
labath
Summary

Something in the changes in FileSpec::Equal and more particularly FileSpec::GetNormalizedPath over the past 3 or 4 months have made the file comparisons that happen when we're matching file & line breakpoints against loaded libraries much slower. I have reports of setting 50 breakpoints on a fairly complex program with ~10000 source files now takes many minutes, and the sample shows almost all the time spent in GetNormalizedFile.

I still have to figure out what got slow here, but in the near term, the FileSpec::Equals algorithm was computing the normalized path in many cases where it didn't need to. The only way two FileSpecs can be equal if their filenames are not equal is if one or the other filename is "." or "..".

This patch takes advantage of that observation to short cut all compares with unequal filenames that aren't "." or "..". Since almost all file compares done when setting breakpoints are for unequal filenames, this should reduce the time spent setting breakpoint.

Diff Detail

Repository
rL LLVM

Event Timeline

jingham created this revision.Mar 23 2017, 11:37 AM
jingham added a reviewer: labath.
jingham added a reviewer: clayborg.
clayborg requested changes to this revision.Mar 23 2017, 5:03 PM

Since we are going for speed here, I added a few suggestions for making it quicker.

source/Utility/FileSpec.cpp
441–443

Add a return of false here and avoid the whole "last_component_is_dot" stuff below?

444

Can we look at remove_backups here and avoid the last_component_is_dot functionality if it is false?

This revision now requires changes to proceed.Mar 23 2017, 5:03 PM
jingham updated this revision to Diff 93020.Mar 24 2017, 4:18 PM
jingham edited edge metadata.

How does this look?

labath accepted this revision.Mar 26 2017, 11:09 AM

Seems legit.

I've added unit tests for this method when I last touched it, but it looks like there are no cases which test the "last component is dot" case. Would you mind adding one or two of these?

clayborg accepted this revision.Mar 26 2017, 3:45 PM

Much better.

This revision is now accepted and ready to land.Mar 26 2017, 3:45 PM
jingham closed this revision.Mar 27 2017, 12:25 PM

Closed by r298876