Skip to content

GetModIfaceFromDisk has bad first call complexity #2304

Closed
@pepeiborra

Description

@pepeiborra

The current implementation of GetModIface is O(# of transitive import statements), i.e. it does an amount of work proportional to the number of imports in the project. To see why, notice that to evaluate GetModIface M, that is to load the interface for a module M, we first need to load the interfaces of all its DD direct imports, which involves DD recursive calls to GetModIface. Transitively, this makes one GetModIface M call for every import in the module graph of M. This leads to bad startup performance in projects with a dense module graph since:

O(# of import statements) = O(edges in module graph) ==> O(modules^2).

Once GetModIface M has been called at least once the ongoing cost is O(direct imports), thanks to early cutoff, which is very good.

How can we improve the bad performance of the first call while preserving the good performance of the second call?

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceIssues about memory consumption, responsiveness, etc.type: enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions