Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] Optimize out references to a bunch of BCL methods during JS interop startup #101217

Merged
merged 3 commits into from
Apr 19, 2024

Conversation

kg
Copy link
Member

@kg kg commented Apr 17, 2024

During startup for a simple wasm browser app, by my testing the interpreter has to generate code for ~870 methods. This PR reduces it to ~750.

Most of the methods removed are SIMD-related, i.e. vector infrastructure or vectorized string algorithms. The interpolated string also pulls in a ton of threading and synchronization stuff due to renting from a pool.

Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

@lewing
Copy link
Member

lewing commented Apr 17, 2024

Is there a reason not to do the parsing in js or unmanaged?

@kg
Copy link
Member Author

kg commented Apr 17, 2024

We could move it all there, yeah. It's just more invasive. Happy to do it.

@kg
Copy link
Member Author

kg commented Apr 18, 2024

Took some measurements, and this reduces the % of total startup JS samples underneath *bind_assembly* from 10-20% to 3-4%. Some of the work potentially moves elsewhere in startup for a larger application, of course.

@pavelsavara
Copy link
Member

Is there a reason not to do the parsing in js or unmanaged?

I think it's next logical step 🤣

See c34474e

image

now seriously, i'm OK with moving it back, it seems we only needed to parse it on C# side in order to format that wrapper_name interpolated string.

kg added 2 commits April 18, 2024 13:56
Remove interpolated string from jsinterop startup
@kg kg merged commit b621129 into dotnet:main Apr 19, 2024
95 of 98 checks passed
matouskozak pushed a commit to matouskozak/runtime that referenced this pull request Apr 30, 2024
…terop startup (dotnet#101217)

During startup for a simple wasm browser app, by my testing the interpreter has to generate code for ~870 methods. This PR reduces it to ~750.

Most of the methods removed are SIMD-related, i.e. vector infrastructure or vectorized string algorithms. The interpolated string also pulls in a ton of threading and synchronization stuff due to renting from a pool.

In the future we could move all of this string logic into C or JS to avoid involving managed code at all, since the resulting string is not used by C#.
@github-actions github-actions bot locked and limited conversation to collaborators May 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants