lazytiger opened issue #8793:
I want to test if I can use the parallel feature in the specs crate.
#[derive(Component)] #[storage(VecStorage)] pub struct Int32Comp { pub data: i32, } pub struct SumSystem; impl<'a> System<'a> for SumSystem { type SystemData = (Write<'a, i32>, ReadStorage<'a, Int32Comp>); fn run(&mut self, (mut sum, i32comp): Self::SystemData) { for i32comp in (&i32comp).join() { *sum += i32comp.data; } } } #[no_mangle] pub extern "system" fn add(i: i32, j: i32) -> i32 { let mut world = World::new(); world.register::<Int32Comp>(); for data in i..j { world.create_entity().with(Int32Comp { data }).build(); } world.insert(0); let pool = ThreadPoolBuilder::new().build().unwrap(); let mut dispatcher = DispatcherBuilder::new().with(SumSystem, "sum_system", &[]).with_pool(Arc::new(pool)).build(); dispatcher.dispatch(&mut world); let sum = world.fetch::<i32>(); *sum }
- When i=0, j=1, the Engine with default config failed: memory allocation of memory allocation of 10361552 bytes failed
- When i=0, j=10, the Engine with max_wasm_stack=1024102410, it works
- When i=0, j=20, the Engine with max_wasm_stack=1024102410 it fails: memory allocation of memory allocation of 10361552 bytes failed
I have tested max_wasm_stack=200x1024x1024, it fails the same.
I wonder if this is a bug or if I just missed some configuration.
bjorn3 commented on issue #8793:
What is the max memory size set by the wasm module? Wasm shared memories are required to set some limit to their size. It may be the case that the linker defaulted to a too small size.
lazytiger edited issue #8793:
I want to test if I can use the parallel feature in the specs crate.
#[derive(Component)] #[storage(VecStorage)] pub struct Int32Comp { pub data: i32, } pub struct SumSystem; impl<'a> System<'a> for SumSystem { type SystemData = (Write<'a, i32>, ReadStorage<'a, Int32Comp>); fn run(&mut self, (mut sum, i32comp): Self::SystemData) { for i32comp in (&i32comp).join() { *sum += i32comp.data; } } } #[no_mangle] pub extern "system" fn add(i: i32, j: i32) -> i32 { let mut world = World::new(); world.register::<Int32Comp>(); for data in i..j { world.create_entity().with(Int32Comp { data }).build(); } world.insert(0); let pool = ThreadPoolBuilder::new().build().unwrap(); let mut dispatcher = DispatcherBuilder::new().with(SumSystem, "sum_system", &[]).with_pool(Arc::new(pool)).build(); dispatcher.dispatch(&mut world); let sum = world.fetch::<i32>(); *sum }
- When i=0, j=1, the Engine with default config failed: memory allocation of memory allocation of 10361552 bytes failed
- When i=0, j=10, the Engine with max_wasm_stack=1024x1024x10, it works
- When i=0, j=20, the Engine with max_wasm_stack=1024x1024x10 it fails: memory allocation of memory allocation of 10361552 bytes failed
I have tested max_wasm_stack=200x1024x1024, it fails the same.
I wonder if this is a bug or if I just missed some configuration.
lazytiger commented on issue #8793:
I use default for all the other config parameters
lazytiger edited a comment on issue #8793:
I use default for all the other config parameters. @bjorn3 How can I set max memory size, I don't find an API related to this purpose except max_wasm_stack
lazytiger commented on issue #8793:
ImportType { module: "env", name: "memory", ty: Memory(MemoryType { ty: Memory { minimum: 17, maximum: Some(17), shared: true, memory64: false } }) }
The shared memory maximum is 17, how can I change the maximum? Thanks
lazytiger commented on issue #8793:
Thanks for your help. I use the walrus crate to modify the wasm file, and it works.
lazytiger closed issue #8793:
I want to test if I can use the parallel feature in the specs crate.
#[derive(Component)] #[storage(VecStorage)] pub struct Int32Comp { pub data: i32, } pub struct SumSystem; impl<'a> System<'a> for SumSystem { type SystemData = (Write<'a, i32>, ReadStorage<'a, Int32Comp>); fn run(&mut self, (mut sum, i32comp): Self::SystemData) { for i32comp in (&i32comp).join() { *sum += i32comp.data; } } } #[no_mangle] pub extern "system" fn add(i: i32, j: i32) -> i32 { let mut world = World::new(); world.register::<Int32Comp>(); for data in i..j { world.create_entity().with(Int32Comp { data }).build(); } world.insert(0); let pool = ThreadPoolBuilder::new().build().unwrap(); let mut dispatcher = DispatcherBuilder::new().with(SumSystem, "sum_system", &[]).with_pool(Arc::new(pool)).build(); dispatcher.dispatch(&mut world); let sum = world.fetch::<i32>(); *sum }
- When i=0, j=1, the Engine with default config failed: memory allocation of memory allocation of 10361552 bytes failed
- When i=0, j=10, the Engine with max_wasm_stack=1024x1024x10, it works
- When i=0, j=20, the Engine with max_wasm_stack=1024x1024x10 it fails: memory allocation of memory allocation of 10361552 bytes failed
I have tested max_wasm_stack=200x1024x1024, it fails the same.
I wonder if this is a bug or if I just missed some configuration.
bjorn3 commented on issue #8793:
You can set the mac size by passing
--max-memory
to the linker as alternative.
Last updated: Dec 23 2024 at 12:05 UTC