@@ -100,15 +100,11 @@ impl Default for Config {
100100 // globals, memories, etc. Instance allocations are relatively small and are largely inconsequential
101101 // compared to other runtime state, but a number needs to be chosen here so a relatively large threshold
102102 // of 10MB is arbitrarily chosen. It should be unlikely that any reasonably-sized module hits this limit.
103- . max_component_instance_size (
104- env ( "SPIN_WASMTIME_INSTANCE_SIZE" , ( 10 * MB ) as u32 ) as usize
105- )
106- . max_core_instance_size (
107- env ( "SPIN_WASMTIME_CORE_INSTANCE_SIZE" , ( 10 * MB ) as u32 ) as usize
108- )
103+ . max_component_instance_size ( env ( "SPIN_WASMTIME_INSTANCE_SIZE" , 10 * MB ) as usize )
104+ . max_core_instance_size ( env ( "SPIN_WASMTIME_CORE_INSTANCE_SIZE" , 10 * MB ) as usize )
109105 . max_core_instances_per_component ( env ( "SPIN_WASMTIME_CORE_INSTANCE_COUNT" , 200 ) )
110106 . max_tables_per_component ( env ( "SPIN_WASMTIME_INSTANCE_TABLES" , 20 ) )
111- . table_elements ( env ( "SPIN_WASMTIME_INSTANCE_TABLE_ELEMENTS" , 100_000 ) as usize )
107+ . table_elements ( env ( "SPIN_WASMTIME_INSTANCE_TABLE_ELEMENTS" , 100_000 ) )
112108 // The number of memories an instance can have effectively limits the number of inner components
113109 // a composed component can have (since each inner component has its own memory). We default to 32 for now, and
114110 // we'll see how often this limit gets reached.
@@ -120,14 +116,21 @@ impl Default for Config {
120116 // `StoreLimitsAsync` accounting method too.
121117 . max_memory_size ( 4 * GB )
122118 // These numbers are completely arbitrary at something above 0.
123- . linear_memory_keep_resident ( ( 2 * MB ) as usize )
124- . table_keep_resident ( ( MB / 2 ) as usize ) ;
119+ . linear_memory_keep_resident ( env (
120+ "SPIN_WASMTIME_LINEAR_MEMORY_KEEP_RESIDENT" ,
121+ 2 * MB ,
122+ ) as usize )
123+ . table_keep_resident ( env ( "SPIN_WASMTIME_TABLE_KEEP_RESIDENT" , MB / 2 ) as usize ) ;
125124 inner. allocation_strategy ( InstanceAllocationStrategy :: Pooling ( pooling_config) ) ;
126125 }
127126
128127 return Self { inner } ;
129128
130- fn env ( name : & str , default : u32 ) -> u32 {
129+ fn env < T > ( name : & str , default : T ) -> T
130+ where
131+ T : std:: str:: FromStr ,
132+ T :: Err : std:: fmt:: Display ,
133+ {
131134 match std:: env:: var ( name) {
132135 Ok ( val) => val
133136 . parse ( )
0 commit comments