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

fix(perf): Unexpanding pipeline without StageContext #3307

Merged
merged 1 commit into from
Nov 19, 2019

Commits on Nov 19, 2019

  1. fix(perf): Unexpanding pipeline without StageContext

    When calling the following endpoint: `v2/applications/{}/pipelines` with `expand=false`
    the `TaskController` will try "unexpand" the pipelines by removing "context" from all the stages.
    However, there is a wrinkle: during removal of the context we want to preserve the `group` key (if it exists).
    In order to check if the key is there, we make a call to `context.group`. The problem is that the `context` is actually a
    `StageContext` and the `.group` is actually a `StageContext::get("group")`.
    This particular call traverses the entire execution graph to see if `group` exists not only in the current stage context
    but also in the outputs of any of it's parent stages. Well, if the stage graph is large this is a O(n^2) operation.
    
    The kicker is that the `group` should never occur in the outputs (and if it does we don't care).
    This stage replaces the implicit groovy call to `.get` with explicit call to `.containsKey` which doesn't traverse the stage hierarchy.
    
    The result (on a 300 stage Kayenta canary pipeline):
    Before: 17.2s to fetch the last 2 executions
    After:   0.2s to fetch the last 2 executions
    marchello2000 committed Nov 19, 2019
    Configuration menu
    Copy the full SHA
    f38e6f6 View commit details
    Browse the repository at this point in the history