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

Speed up opt_normalize_projection_type #50818

Merged
merged 2 commits into from
May 18, 2018

Commits on May 16, 2018

  1. Avoid repeated HashMap lookups in opt_normalize_projection_type.

    There is a hot path through `opt_normalize_projection_type`:
    - `try_start` does a cache lookup (#1).
    - The result is a `NormalizedTy`.
    - There are no unresolved type vars, so we call `complete`.
    - `complete` does *another* cache lookup (rust-lang#2), then calls
      `SnapshotMap::insert`.
    - `insert` does *another* cache lookup (rust-lang#3), inserting the same value
      that's already in the cache.
    
    This patch optimizes this hot path by introducing `complete_normalized`,
    for use when the value is known in advance to be a `NormalizedTy`. It
    always avoids lookup rust-lang#2. Furthermore, if the `NormalizedTy`'s
    obligations are empty (the common case), we know that lookup rust-lang#3 would be
    a no-op, so we avoid it, while inserting a Noop into the `SnapshotMap`'s
    undo log.
    nnethercote committed May 16, 2018
    Configuration menu
    Copy the full SHA
    f778bde View commit details
    Browse the repository at this point in the history

Commits on May 17, 2018

  1. Avoid allocations in opt_normalize_projection_type.

    This patch changes `opt_normalize_project_type` so it appends
    obligations to a given obligations vector, instead of returning a new
    obligations vector.
    
    This change avoids lots of allocations. In the most extreme case, for a
    clean "Check" build of serde it reduces the total number of allocations
    by 20%.
    nnethercote committed May 17, 2018
    Configuration menu
    Copy the full SHA
    47bc774 View commit details
    Browse the repository at this point in the history