Skip to content

Clean up mjs module for vector calculation #8666

@philippotto

Description

@philippotto

We extend the mjs npm module to add quite a bit of additional utility functions. Similar to mjs, we often (but not always) follow the signature where a third parameter can be passed for the output variable. In tight loops, this avoids allocating an array in each invocation.
However, the code often defaults to allocating a Float32Array which is often not type-compliant with our usual vectors (i.e., JS arrays with a fixed size).

I also benchmarked the different options a bit and found out that the Float32Array doesn't really add much benefit. In contrast, if the third parameter is NOT used, allocating a Float32Array is even worse than allocating a normal vector.

Benchmark is here:

On Chrome:

Image

On Firefox, float32 has a slight benefit (but still not worth it imo):

Image

Proposal:
We should clean up the mjs module so that float32 is only used where it really makes sense. maybe we can even get rid of the original mjs module and use something else?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions