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] Blazor apps started from Visual Studio have optimizations disabled, even in Release #40428

Closed
BrzVlad opened this issue Aug 5, 2020 · 8 comments · Fixed by #40429
Closed
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono tenet-performance Performance related issue
Milestone

Comments

@BrzVlad
Copy link
Member

BrzVlad commented Aug 5, 2020

Steps to reproduce:

  • Create blazor wasm template
  • Add some code that requires optimizations. For example, on counter page
@page "/counter"
@using System.Diagnostics

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
    private int currentCount = 0;
    private int result;

    private int Add (int a, int b)
    {
        return a + b;
    }

    private void TestMethod ()
    {
        for (int i = 0; i < 100000; i++) {
            int a = 10;
            int b = 20;
            result += Add (a, b);
        }

    }

    private void IncrementCount ()
    {
        Stopwatch sw = new Stopwatch ();
        sw.Start ();
        TestMethod ();
        sw.Stop ();
        Console.WriteLine ("TestMethod took {0} ms", sw.ElapsedMilliseconds);

        currentCount++;
    }
}
  • Notice that, when running from visual studio the release configuration with Start without debugging, the computation time when doing a click is around 4-5 times slower than the same operation with the web app published and deployed to an IIS instance

When initializing the runtime, mono_wasm_load_runtime always receives enable_debugging as -1 when started from visual studio, while the published version has it set to 0.

@BrzVlad BrzVlad added arch-wasm WebAssembly architecture tenet-performance Performance related issue labels Aug 5, 2020
@BrzVlad BrzVlad added this to the 5.0.0 milestone Aug 5, 2020
@Dotnet-GitSync-Bot
Copy link
Collaborator

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.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Aug 5, 2020
@BrzVlad
Copy link
Member Author

BrzVlad commented Aug 5, 2020

cc @lewing @marek-safar

@lewing
Copy link
Member

lewing commented Aug 5, 2020

I see the issue, fix incoming.

@ghost
Copy link

ghost commented Aug 6, 2020

Tagging subscribers to this area: @CoffeeFlux
See info in area-owners.md if you want to be subscribed.

@lewing
Copy link
Member

lewing commented Aug 6, 2020

@BrzVlad when you are running the release build are you choosing "run-without-debugging"?

@BrzVlad
Copy link
Member Author

BrzVlad commented Aug 6, 2020

As mentioned in the description, I go to Debug menu and click Start without debugging

@lewing
Copy link
Member

lewing commented Aug 10, 2020

closed in favor of dotnet/aspnetcore#24623

@lewing lewing closed this as completed Aug 10, 2020
@captainsafia
Copy link
Member

captainsafia commented Aug 25, 2020

@BrzVlad Thanks for reporting this issue.

Notice that, when running from visual studio the release configuration with Start without debugging, the computation time when doing a click is around 4-5 times slower than the same operation with the web app published and deployed to an IIS instance

I ran some tests with our perf benchmarking tool to verify the behavior here.

Here's a screenshot of perf stats on a Blazor app built with a Debug configuration.

localhost_5001_ (2)

And here's a screenshot of perf stats when running in a Release configuration.

localhost_5001_

There's not a major perf distinction between the two for the scenarios measured.

the computation time when doing a click is around 4-5 times slower than the same operation with the web app published and deployed to an IIS instance

This is expected since published apps run with debugging disabled.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono tenet-performance Performance related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants