@@ -811,34 +811,48 @@ pub struct CtxtInterners<'tcx> {
811
811
}
812
812
813
813
impl < ' tcx > CtxtInterners < ' tcx > {
814
- fn new ( arena : & ' tcx WorkerLocal < Arena < ' tcx > > ) -> CtxtInterners < ' tcx > {
814
+ fn new ( arena : & ' tcx WorkerLocal < Arena < ' tcx > > ) -> CtxtInterners < ' tcx > {
815
815
CtxtInterners {
816
816
arena,
817
- // There are likely to be a lot of types. This should occupy 0.4 MB.
818
- type_ : InternedSet :: with_capacity ( 16384 ) ,
819
- const_lists : InternedSet :: with_capacity ( 4096 ) ,
820
- args : InternedSet :: with_capacity ( 4096 ) ,
821
- type_lists : InternedSet :: with_capacity ( 4096 ) ,
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 ) ,
822
828
region : InternedSet :: with_capacity ( 4096 ) ,
823
- poly_existential_predicates : InternedSet :: with_capacity ( 1024 ) ,
824
- canonical_var_infos : InternedSet :: with_capacity ( 1024 ) ,
825
- predicate : InternedSet :: with_capacity ( 1024 ) ,
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 ) ,
826
836
clauses : InternedSet :: with_capacity ( 1024 ) ,
827
- projs : InternedSet :: with_capacity ( 4096 ) ,
828
- place_elems : InternedSet :: with_capacity ( 4096 ) ,
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 ) ,
829
842
const_ : InternedSet :: with_capacity ( 4096 ) ,
830
843
pat : InternedSet :: with_capacity ( 1024 ) ,
831
844
const_allocation : InternedSet :: with_capacity ( 1024 ) ,
832
- bound_variable_kinds : InternedSet :: with_capacity ( 1024 ) ,
833
- layout : 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 ) ,
834
848
adt_def : InternedSet :: with_capacity ( 1024 ) ,
835
849
external_constraints : InternedSet :: with_capacity ( 1024 ) ,
836
850
predefined_opaques_in_body : InternedSet :: with_capacity ( 1024 ) ,
837
851
fields : InternedSet :: with_capacity ( 4096 ) ,
838
852
local_def_ids : InternedSet :: with_capacity ( 1024 ) ,
839
853
captures : InternedSet :: with_capacity ( 1024 ) ,
840
854
offset_of : InternedSet :: with_capacity ( 1024 ) ,
841
- valtree : InternedSet :: with_capacity ( 1024 ) ,
855
+ valtree : InternedSet :: with_capacity ( 1024 ) ,
842
856
}
843
857
}
844
858
@@ -2550,6 +2564,7 @@ macro_rules! slice_interners {
2550
2564
( $( $field: ident: $vis: vis $method: ident( $ty: ty) ) ,+ $( , ) ?) => (
2551
2565
impl <' tcx> TyCtxt <' tcx> {
2552
2566
$( $vis fn $method( self , v: & [ $ty] ) -> & ' tcx List <$ty> {
2567
+ //eprintln!("{} len:{}",stringify!($field), self.interners.$field.len());
2553
2568
if v. is_empty( ) {
2554
2569
List :: empty( )
2555
2570
} else {
@@ -2848,6 +2863,7 @@ impl<'tcx> TyCtxt<'tcx> {
2848
2863
// FIXME consider asking the input slice to be sorted to avoid
2849
2864
// re-interning permutations, in which case that would be asserted
2850
2865
// here.
2866
+
2851
2867
self . intern_local_def_ids ( clauses)
2852
2868
}
2853
2869
0 commit comments