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

Investigate Blazor WebAssembly startup performance characteristics #54353

Open
MackinnonBuck opened this issue Mar 4, 2024 · 2 comments
Open
Assignees
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. Perf
Milestone

Comments

@MackinnonBuck
Copy link
Member

Even when Blazor WebAssembly assets are cached, the time it takes for a Blazor WebAssembly app to initialize can be significant. We should investigate ways to further optimize Blazor WebAssembly initialization to reduce this startup time.

Some preliminary investigation suggests that Blazor-specific startup (everything that happens after the code in Program.cs starts executing) accounts for at least half the total initialization time.

We should:

  • Add instrumentation to measure how long various initialization stages take
    • Such stages include loading cached assets, initializing the .NET WebAssembly runtime, and many of the steps between the start of the app's entrypoint and the first interactive render
  • Collect traces for Blazor-specific initialization code
  • Given those results, determine what work can be done to minimize WebAssembly startup time
  • Consider benchmarking daily builds so we can track these detailed performance measurements over time

Related issues:

@MackinnonBuck MackinnonBuck added the area-blazor Includes: Blazor, Razor Components label Mar 4, 2024
@mkArtakMSFT mkArtakMSFT added bug This issue describes a behavior which is not expected - a bug. Perf labels Mar 5, 2024
@zubairkhakwani
Copy link

Currently, when using Blazor in InteractiveAuto render mode, the application starts with Blazor Server on the initial load and transitions to WebAssembly once all DLLs are loaded and cached. However, on subsequent requests, it waits for WebAssembly to start, neglecting the benefits of Blazor Server.

To enhance performance and user experience, I suggest implementing a mechanism where the first page load or any subsequent refreshes always utilize Blazor Server, while booting WebAssembly in the background. This approach can mitigate concerns about WebAssembly startup performance, as we can improve it up to a certain extent.

Making this behavior configurable would provide flexibility. Users could choose to wait for WebAssembly to load when the cache is available or opt for Blazor Server on every initial request, even if WebAssembly is downloaded.

By implementing this approach, we can optimize the application's performance and provide users with a smoother transition to WebAssembly while still leveraging the benefits of Blazor Server where applicable.

Would love to hear thoughts and feedback on this proposal!

@mkArtakMSFT
Copy link
Member

Bringing #31877 into the current milestone as @MackinnonBuck 's investigation leads us to believe that this work will bring substantial benefits to startup perf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. Perf
Projects
None yet
Development

No branches or pull requests

3 participants