Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoMod: Fix the algorithm for handling cycles #5628

Merged
merged 1 commit into from
Aug 3, 2022

Commits on Aug 3, 2022

  1. GoMod: Fix the algorithm for handling cycles

    The previous algorithm exhibits the following issues when run on graphs
    with cycles, in particular when the amount of edges is large:
    
    1. Cycles of length 1 lead to infinite recursion.
    2. The algorithm is inefficient in terms of execution time and memory
       allocation, as it creates a copy of the
       `predecessorNodes` set per recursion.
    3. When run against [1] the execution of `toPackageReferenceForest()`
       didn't finish within 15 minutes, causing high CPU load and memory
       consumption.
    
    If GoMod used the dependency graph format already, the solution would be
    as simple as calling `DependencyGraphBuilder.breakCycles()`. Fix the
    problem by copying the code of `DependencyGraphBuilder.breakCycles()` as
    a temporary quick fix. This saves effort, because refactoring GoMod to
    use the dependency graph is planned anyway [2], which will allow for
    removing that copied code again.
    
    [1] https://github.com/ossf/scorecard
    [2] #4249
    
    Fixes #5627.
    
    Signed-off-by: Frank Viernau <[email protected]>
    fviernau committed Aug 3, 2022
    Configuration menu
    Copy the full SHA
    1467603 View commit details
    Browse the repository at this point in the history