Make cross-importing faster

We previously computed cross-imports by comparing N transitive imports against N transitive imports. This is wasteful, because at least one of the two modules in a pair has to actually declare a cross-import overlay for us to discover one, and the vast majority of modules don’t declare any.

This commit makes us instead compare N transitive imports against M transitive imports which are known to declare at least one cross-import overlay. Since N is potentailly in the thousands while M is perhaps in the double digits, this should be good for a substantial time savings.

However, this optimization has made a test of another cross-import performance optimization fail—not because we have regressed on that, but because it skips work the test case expects us to perform. I have XFAILed that test for now.

Fixes <rdar://problem/59538458>.
This commit is contained in:
Brent Royal-Gordon
2020-02-20 00:34:42 -08:00
parent 261e9e4eb9
commit a3e3598b9a
3 changed files with 96 additions and 35 deletions

View File

@@ -260,6 +260,18 @@ public:
/// Add a file declaring a cross-import overlay.
void addCrossImportOverlayFile(StringRef file);
/// If this method returns \c false, the module does not declare any
/// cross-import overlays.
///
/// This is a quick check you can use to bail out of expensive logic early;
/// however, a \c true return doesn't guarantee that the module declares
/// cross-import overlays--it only means that it \em might declare some.
///
/// (Specifically, this method checks if the module loader found any
/// swiftoverlay files, but does not load the files to see if they list any
/// overlay modules.)
bool mightDeclareCrossImportOverlays() const;
/// Append to \p overlayNames the names of all modules that this module
/// declares should be imported when \p bystanderName is imported.
///