@@ -812,47 +812,35 @@ pub struct CtxtInterners<'tcx> {
812
812
813
813
impl < ' tcx > CtxtInterners < ' tcx > {
814
814
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 DEF_INTERN_SIZE : usize = 2048 ;
815
818
CtxtInterners {
816
819
arena,
817
- // From some experiments, it looks like there usualy are < 2^20 types.
818
- // 2^20 * 24 bytes ~ 25 MB, which is acceptable IMHO.
819
- type_ : InternedSet :: with_capacity ( 1048576 ) ,
820
- // Const lists don't seem to be too common, but I still reserver 128 of them, since
821
- // it is cheap anyway
822
- const_lists : InternedSet :: with_capacity ( 128 ) ,
823
- // From some experiments, it looks like there usualy are < 2^20 arg lists.
824
- // 2^20 * 8 bytes ~ 9 MB, which is acceptable IMHO.
825
- args : InternedSet :: with_capacity ( 1048576 ) ,
826
- // From some experiments, it looks like there usualy are < 2^19 type_lists.
827
- type_lists : InternedSet :: with_capacity ( 524288 ) ,
828
- region : InternedSet :: with_capacity ( 4096 ) ,
829
- // There are usually very few `poly_existential_predicates` - for cargo, there were 119.
830
- // So, 256 ought to be more than enough for all cases.
831
- poly_existential_predicates : InternedSet :: with_capacity ( 256 ) ,
832
- // There is usually very few `canonical_var_infos` - for cargo, there were 379.
833
- // So, 512 ought to be more than enough for all cases.
834
- canonical_var_infos : InternedSet :: with_capacity ( 512 ) ,
835
- predicate : InternedSet :: with_capacity ( 1024 ) ,
836
- clauses : InternedSet :: with_capacity ( 1024 ) ,
837
- // Projs don't seem to be too common, but I still reserver 128 of them, since
838
- // it is cheap anyway
839
- projs : InternedSet :: with_capacity ( 128 ) ,
840
- // There semes to be > 2^16 place_elems.
841
- place_elems : InternedSet :: with_capacity ( 65536 ) ,
842
- const_ : InternedSet :: with_capacity ( 4096 ) ,
843
- pat : InternedSet :: with_capacity ( 1024 ) ,
844
- const_allocation : InternedSet :: with_capacity ( 1024 ) ,
845
- // There is usually < 2^13 bound_variable_kinds
846
- bound_variable_kinds : InternedSet :: with_capacity ( 8192 ) ,
847
- layout : InternedSet :: with_capacity ( 4096 ) ,
848
- adt_def : InternedSet :: with_capacity ( 1024 ) ,
849
- external_constraints : InternedSet :: with_capacity ( 1024 ) ,
850
- predefined_opaques_in_body : InternedSet :: with_capacity ( 1024 ) ,
851
- fields : InternedSet :: with_capacity ( 4096 ) ,
852
- local_def_ids : InternedSet :: with_capacity ( 1024 ) ,
853
- captures : InternedSet :: with_capacity ( 1024 ) ,
854
- offset_of : InternedSet :: with_capacity ( 1024 ) ,
855
- valtree : InternedSet :: with_capacity ( 1024 ) ,
820
+ type_ : InternedSet :: with_capacity ( DEF_INTERN_SIZE * 16 ) ,
821
+ const_lists : InternedSet :: with_capacity ( DEF_INTERN_SIZE * 4 ) ,
822
+ args : InternedSet :: with_capacity ( DEF_INTERN_SIZE * 4 ) ,
823
+ type_lists : InternedSet :: with_capacity ( DEF_INTERN_SIZE * 4 ) ,
824
+ region : InternedSet :: with_capacity ( DEF_INTERN_SIZE * 4 ) ,
825
+ poly_existential_predicates : InternedSet :: with_capacity ( DEF_INTERN_SIZE /4 ) ,
826
+ canonical_var_infos : InternedSet :: with_capacity ( DEF_INTERN_SIZE /2 ) ,
827
+ predicate : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
828
+ clauses : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
829
+ projs : InternedSet :: with_capacity ( DEF_INTERN_SIZE * 4 ) ,
830
+ place_elems : InternedSet :: with_capacity ( DEF_INTERN_SIZE * 2 ) ,
831
+ const_ : InternedSet :: with_capacity ( DEF_INTERN_SIZE * 2 ) ,
832
+ pat : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
833
+ const_allocation : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
834
+ bound_variable_kinds : InternedSet :: with_capacity ( DEF_INTERN_SIZE * 2 ) ,
835
+ layout : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
836
+ adt_def : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
837
+ external_constraints : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
838
+ predefined_opaques_in_body : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
839
+ fields : InternedSet :: with_capacity ( DEF_INTERN_SIZE * 4 ) ,
840
+ local_def_ids : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
841
+ captures : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
842
+ offset_of : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
843
+ valtree : InternedSet :: with_capacity ( DEF_INTERN_SIZE ) ,
856
844
}
857
845
}
858
846
0 commit comments