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

[mono] bug about wasm single thread using lock #112734

Open
srxqds opened this issue Feb 20, 2025 · 3 comments
Open

[mono] bug about wasm single thread using lock #112734

srxqds opened this issue Feb 20, 2025 · 3 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm tenet-performance Performance related issue
Milestone

Comments

@srxqds
Copy link
Contributor

srxqds commented Feb 20, 2025

we found the object interop between js and c# excecute slowly
you can find below flame graph:
Image

the AssertNotDisposed take most time of argument transfer.

we use single thread, Is it not necessary using lock at below functions :

internal void AssertNotDisposed()
{
lock (ProxyContext)
{
ObjectDisposedException.ThrowIf(IsDisposed, this);
}
}

public unsafe void ToManaged(out Task? value)
{
// there is no nice way in JS how to check that JS promise is already resolved, to send MarshalerType.TaskRejected, MarshalerType.TaskResolved
if (slot.Type == MarshalerType.None)
{
value = null;
return;
}
var ctx = ToManagedContext;
lock (ctx)

should it wrapper with FEATURE_WASM_MANAGED_THREADS as other function do.

internal void AssertNotDisposed()
        {
#if FEATURE_WASM_MANAGED_THREADS
            lock (ProxyContext)
#endif
            {
                ObjectDisposedException.ThrowIf(IsDisposed, this);
            }
        }
@srxqds srxqds added the tenet-performance Performance related issue label Feb 20, 2025
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Feb 20, 2025
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm labels Feb 20, 2025
@pavelsavara pavelsavara added this to the 10.0.0 milestone Feb 20, 2025
Copy link
Contributor

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

@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Feb 20, 2025
@srxqds
Copy link
Contributor Author

srxqds commented Feb 21, 2025

anyone can take time to figure out this?

@pavelsavara
Copy link
Member

It seems legit, I will get to it eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm tenet-performance Performance related issue
Projects
None yet
Development

No branches or pull requests

2 participants