Skip to content

Option to provide the .wasm file's ArrayBuffer instead of library fetching it #53

@manzik

Description

@manzik

First of all, thank you for your great library, I love it! Great job maintaining it and keeping it up to date I'm relying on it heavily.
So hats off!

I was wondering if you can add an option where I could pass in a pre-fetched ArrayBuffer of wasm file and pass that instead of the folder where the wasm file is located.

My use case: I'm using the library to process multiple graphviz source files and get output in parallel (using web workers). And this has decreased my code's runtime from 4 seconds to 1 second on my machine's localhost.

The issue is that if I have 4 cores, each worker will download the wasm file separately and spend ~400ms redoing a work that can be easily done just once for all of them, and that is on localhost. This number will be much higher in production and waste a lot of resources.

So if you add an option for passing typed array or ArrayBuffer that can be avoided.
I also have to mention it's impossible to pass around all kinds of objects between worker and master processes and they have to be clonable which is why I would need to pass an ArrayBuffer or a data type like that and passing library's objects around wouldn't work.

Pretty sure being able to fetch the wasm file's data and reuse them whenever needed could be useful in some other cases too.

Thanks again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions