Skip to content

[PERF] Instantiations are getting too far #14902

Open
@blyxyas

Description

@blyxyas

As the documentation lints got approved, Ty::intern is now the public enemy number one. Today I analyzed all the occurrences of instantiate* functions and all Ty::interns.

Here is a list of all those calls that exceed 65 while running our test suite. Not all of these can be optimized away, but I'm sure that the greatest culprits can be optimized greatly.

There were lots of lints that use the instantiation functions <50 times in the whole test suite, so I'm pretty sure that (almost) any function that uses them > e.g. 5k times can be heavily optimized away.

For Ty::intern directly, only manual_abs_diff.rs::is_sub_expr is directly optimizable (100% of that), but it "only" creates 131 new types.
For instantiations:

  • dereference.rs for_defined_ty 2.25k (calls)
  • impl_hash_with_borrow_str_and_bytes.rs.html - 2.66k ..
  • only_used_in_recursion - 2.66k ..
  • mixed_read_write_in_expression - 20.8k
  • needless_borrows_for_generic_args - 580
  • large_enum_variant - 500
  • ty/mod.rs 2.15k
  • from_over_into - 241
  • needless_match - 322
  • utils/src/lib.rs - 9099
  • functions/results.rs - 9660
  • functions/ref_option.rs - 10488
  • mut_key.rs - 22.8k (@blyxyas)
  • non_copy_const - 1001
  • methods/mod.rs - 9361
  • self_named_constructors - 929
  • useless_asref - 191
  • path_buf_push_overwrite.rs - 168
  • map_clone.rs - 482
  • case_sensitive_file_extension_comparisons - 68
  • unnecessary_to_owned - 469
  • manual_ok_or - 90
  • get_first - 105
  • implicit_clone 107
  • iter_on_single_or_empty_collections - 79
  • unit_return_expecting_ord - 90630 (@blyxyas)
  • mut_reference.rs - 17.7k
  • transmute_undefined_repr - 349
  • needless_pass_by_ref_mut - 80
  • use_self.rs - 964
  • derive.rs - 2.66k
  • rest_pat_in_fully_bound_struct - 89
  • large_const_arrays - 589

Metadata

Metadata

Assignees

No one assigned

    Labels

    performance-projectFor issues and PRs related to the Clippy Performance Project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions