Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

[Interface Types] Avoid memory copy #88

Open
@redradist

Description

@redradist

Hi all,

Seems like from proposal of interface type I've understood that adapter functions would copy types from one abi to another abi ?

If so than it can hit performance, consider case of one million elements in some data type ...

... and I would suggest the better approach ...

What if instead of coping we will use just interface like in Java, C#, C++ (abstract type) or Rust (traits) ?
Lets imagine that list (vector or some other type in language) will be presented through the bunch on functions, it will provide additional wrapper functions that should be called instead of native api of some language

Lets consider List ...
In the following language it has the following types:

  1. C++ -> std::vector<>
  2. Rust -> std::Vec<>
  3. Swift -> std::Vec<>

From all this types we can see common semantic and instead of coping types between platforms lets add additional functions ...
I think will be better if these functions will be just interface and provide mechanism of reading and writing data in native abi of the wasm module

For List we can add the following common api:

  1. T * data() (pointer to a data)
  2. size() (size that is stored by this pointer)
  3. insert(T) (or add)
  4. delete(T) (or remove)

This approach will increase overall performance, because it does not require coping data between languages abi, but just provides mechanism of accessing data from native abi

I wrote this idea to @linclark at twitter, but seems like she has lots of messages and she did not see mine, that is why I decided to write here ;)

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