@@ -100,15 +100,11 @@ impl Default for Config {
100
100
// globals, memories, etc. Instance allocations are relatively small and are largely inconsequential
101
101
// compared to other runtime state, but a number needs to be chosen here so a relatively large threshold
102
102
// 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 )
109
105
. max_core_instances_per_component ( env ( "SPIN_WASMTIME_CORE_INSTANCE_COUNT" , 200 ) )
110
106
. 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 ) )
112
108
// The number of memories an instance can have effectively limits the number of inner components
113
109
// a composed component can have (since each inner component has its own memory). We default to 32 for now, and
114
110
// we'll see how often this limit gets reached.
@@ -120,14 +116,21 @@ impl Default for Config {
120
116
// `StoreLimitsAsync` accounting method too.
121
117
. max_memory_size ( 4 * GB )
122
118
// 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 ) ;
125
124
inner. allocation_strategy ( InstanceAllocationStrategy :: Pooling ( pooling_config) ) ;
126
125
}
127
126
128
127
return Self { inner } ;
129
128
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
+ {
131
134
match std:: env:: var ( name) {
132
135
Ok ( val) => val
133
136
. parse ( )
0 commit comments