-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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][AOT] Invoking Action<struct> is 7x slower than Action<ref> #50757
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
I doubt it will significantly remove the gap, but maybe return an existing Color instance instead of a new one? This test case has to create a new instance and zero it (not THAT expensive, but definitely Work) then pass it as an argument value, vs the ref one just passing a nullptr. |
There are workarounds for that case specifically for sure (e.g. not use a generic delegate is a very good start), yet there are many cases where this is not possible to change (in the BCL or existing nuget packages). I'd find interesting for the sharedvt generics exclusion when running mixed-mode AOT to be configurable, as the performance impact is far from neutral. |
I just meant from the perspective of "if this is fixed the two timing values should be ~equal", I absolutely agree |
Tagging subscribers to this area: @CoffeeFlux Issue DetailsDescriptionConsidering this code, using Mixed mode AOT without profile; private static void TestRegisterColor()
{
var sw = Stopwatch.StartNew();
int value = 0;
for (int i = 0; i < 10000000; i++)
{
RegisterColor(null, c => value++);
}
sw.Stop();
Console.WriteLine($"Color: {sw.ElapsedMilliseconds}");
}
private static void TestRegisterOther()
{
var sw = Stopwatch.StartNew();
int value = 0;
for (int i = 0; i < 10000000; i++)
{
RegisterOther(null, c => value++);
}
sw.Stop();
Console.WriteLine($"Other: {sw.ElapsedMilliseconds}");
}
private static void RegisterColor(object o, Action<Color> action)
{
action(new Color());
}
private static void RegisterOther(object o, Action<IDisposable> action)
{
action(null);
} and public struct Color
{
public byte A { get; set; }
public byte B { get; set; }
public byte G { get; set; }
public byte R { get; set; }
} Results are:
Repro: https://github.com/jeromelaban/Wasm.Samples/tree/master/Bug50757/Bug50757 ConfigurationRegression?No Other information
|
FYI @jeffschwMSFT most of these wasm AOT-specific issues should just get the AOT label. |
As per @vargaz's help, adding |
@jeromelaban @vargaz - based on above comment from @jeromelaban - this seems completed ? |
Closing this, @jeromelaban please reopen if this is still an issue. |
Description
Considering this code, using Mixed mode AOT without profile;
and
Results are:
Repro: https://github.com/jeromelaban/Wasm.Samples/tree/master/Bug50757/Bug50757
Configuration
b7a1648
Regression?
No
Other information
The text was updated successfully, but these errors were encountered: