@@ -812,32 +812,38 @@ pub struct CtxtInterners<'tcx> {
812812
813813impl < ' tcx > CtxtInterners < ' tcx > {
814814 fn new ( arena : & ' tcx WorkerLocal < Arena < ' tcx > > ) -> CtxtInterners < ' tcx > {
815+ // Default interner size - this value has been chosen empirically, and may need to be adjusted
816+ // as the compiler evolves.
817+ const N : usize = 2048 ;
815818 CtxtInterners {
816819 arena,
817- type_ : Default :: default ( ) ,
818- const_lists : Default :: default ( ) ,
819- args : Default :: default ( ) ,
820- type_lists : Default :: default ( ) ,
821- region : Default :: default ( ) ,
822- poly_existential_predicates : Default :: default ( ) ,
823- canonical_var_infos : Default :: default ( ) ,
824- predicate : Default :: default ( ) ,
825- clauses : Default :: default ( ) ,
826- projs : Default :: default ( ) ,
827- place_elems : Default :: default ( ) ,
828- const_ : Default :: default ( ) ,
829- pat : Default :: default ( ) ,
830- const_allocation : Default :: default ( ) ,
831- bound_variable_kinds : Default :: default ( ) ,
832- layout : Default :: default ( ) ,
833- adt_def : Default :: default ( ) ,
834- external_constraints : Default :: default ( ) ,
835- predefined_opaques_in_body : Default :: default ( ) ,
836- fields : Default :: default ( ) ,
837- local_def_ids : Default :: default ( ) ,
838- captures : Default :: default ( ) ,
839- offset_of : Default :: default ( ) ,
840- valtree : Default :: default ( ) ,
820+ // The factors have been chosen by @FractalFir based on observed interner sizes
821+ // (obtained by printing them using `x perf eprintln --includes cargo`),
822+ // and then adjusted based on local perf runs.
823+ type_ : InternedSet :: with_capacity ( N * 16 ) ,
824+ const_lists : InternedSet :: with_capacity ( N * 4 ) ,
825+ args : InternedSet :: with_capacity ( N * 4 ) ,
826+ type_lists : InternedSet :: with_capacity ( N * 4 ) ,
827+ region : InternedSet :: with_capacity ( N * 4 ) ,
828+ poly_existential_predicates : InternedSet :: with_capacity ( N / 4 ) ,
829+ canonical_var_infos : InternedSet :: with_capacity ( N / 2 ) ,
830+ predicate : InternedSet :: with_capacity ( N ) ,
831+ clauses : InternedSet :: with_capacity ( N ) ,
832+ projs : InternedSet :: with_capacity ( N * 4 ) ,
833+ place_elems : InternedSet :: with_capacity ( N * 2 ) ,
834+ const_ : InternedSet :: with_capacity ( N * 2 ) ,
835+ pat : InternedSet :: with_capacity ( N ) ,
836+ const_allocation : InternedSet :: with_capacity ( N ) ,
837+ bound_variable_kinds : InternedSet :: with_capacity ( N * 2 ) ,
838+ layout : InternedSet :: with_capacity ( N ) ,
839+ adt_def : InternedSet :: with_capacity ( N ) ,
840+ external_constraints : InternedSet :: with_capacity ( N ) ,
841+ predefined_opaques_in_body : InternedSet :: with_capacity ( N ) ,
842+ fields : InternedSet :: with_capacity ( N * 4 ) ,
843+ local_def_ids : InternedSet :: with_capacity ( N ) ,
844+ captures : InternedSet :: with_capacity ( N ) ,
845+ offset_of : InternedSet :: with_capacity ( N ) ,
846+ valtree : InternedSet :: with_capacity ( N ) ,
841847 }
842848 }
843849
@@ -2847,6 +2853,7 @@ impl<'tcx> TyCtxt<'tcx> {
28472853 // FIXME consider asking the input slice to be sorted to avoid
28482854 // re-interning permutations, in which case that would be asserted
28492855 // here.
2856+
28502857 self . intern_local_def_ids ( clauses)
28512858 }
28522859
0 commit comments