Skip to content

Very poor performances with TypedArrays #3891

Open
@Amoki

Description

@Amoki

Description

I'm working on creating a LWC with our 3D building viewer.
The 3D engine uses Float32Array to build GPU buffers.
When using Lightning Web Security, it is very slow. Operations usually done in ~0.5 second can take up to 50 seconds.
Digging in the debugger, I found assignation is very slow.

Steps to Reproduce

Go to https://developer.salesforce.com/docs/component-library/tools/lws-console

Copy-paste following code:

const size = 10_000_000;
const array = new Float32Array(size);

console.time("OperationTime");

for (let i = 0; i < size; i++) {
    array[i]++; // Any assignation is slow
}

console.timeEnd("OperationTime");

Open the console, toggle LWS: Enabled/LWS: Disabled and click on Evaluate

If needed, I can provide a more complex example.

Expected Results

Execution time similar with LWS (or at least not 50x slower)

Actual Results

Firefox: 7320 ms with LWS, 170 ms without
Chrome : 2902 ms with LWS, 50 ms without

Browsers Affected

All

Version

Tested with LWC 5.0.2
I don't know which version lws-console uses.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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