Stream: git-wasmtime

Topic: wasmtime / issue #8793 Allocation failed when running a m...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 13 2024 at 06:23):

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
}

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.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 13 2024 at 06:36):

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.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 13 2024 at 06:37):

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
}

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.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 13 2024 at 06:37):

lazytiger commented on issue #8793:

I use default for all the other config parameters

view this post on Zulip Wasmtime GitHub notifications bot (Jun 13 2024 at 06:42):

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

view this post on Zulip Wasmtime GitHub notifications bot (Jun 13 2024 at 06:52):

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

view this post on Zulip Wasmtime GitHub notifications bot (Jun 13 2024 at 07:23):

lazytiger commented on issue #8793:

Thanks for your help. I use the walrus crate to modify the wasm file, and it works.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 13 2024 at 07:23):

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
}

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.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 13 2024 at 09:17):

bjorn3 commented on issue #8793:

You can set the mac size by passing --max-memory to the linker as alternative.


Last updated: Nov 22 2024 at 16:03 UTC