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

Razor Class Library Build Time Serious Regression with .NET 9 SDK #59014

Open
1 task done
TimPurdum opened this issue Nov 18, 2024 · 1 comment
Open
1 task done

Razor Class Library Build Time Serious Regression with .NET 9 SDK #59014

TimPurdum opened this issue Nov 18, 2024 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components
Milestone

Comments

@TimPurdum
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Build time for a Razor Class Library with significant static assets (JavaScript files) is more than 4x slower with the .NET 9 SDK than with the .NET 8 SDK.

| SDK Version | 1st Build (after clean/restore) | 2nd Build |
|-------------|---------------------------------|-----------|
| 8.0.404     | 36.95 s                         | 23.90 s   |
| 9.0.100     | 143.5 s                         | 123.8 s   |

Expected Behavior

I would expect no such regression without changing code or at least target level. This appears to be driven mostly by the new ResolveProjectStaticWebAssets logic, which takes more than 50% of the length of the build, with a good bit of what's left being used by the other "StaticAsset" build steps.

Steps To Reproduce

  1. Make sure you have 8.0.404 and 9.0.0 SDKs installed

  2. Clone https://github.com/dymaptic/GeoBlazor

  3. In the src folder, set the global.json to

    {
      "sdk": {
        "version": "8.0.0",
        "rollForward": "latestMinor"
      }
    }
    
  4. Just to prove that these aren't related, you can delete or comment out all the custom Targets in dymaptic.GeoBlazor.Core.csproj (otherwise you do need npm and pwsh installed as well)

  5. Navigate to src/dymaptic.GeoBlazor.Core in a terminal, and run the following commands

    dotnet clean
    dotnet restore
    dotnet build -f net8.0
    dotnet build -f net8.0
    
  6. Edit the global.json file, replace 8.0.0 with 9.0.0

  7. Run the commands from step 4 again

Exceptions (if any)

No response

.NET Version

No response

Anything else?

I expect this is going to be a big issue for any other libraries that wrap significant JavaScript modules. At the very least, I need a workaround to ameliorate this regression so I can move this library to .NET 9 and beyond.

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Nov 18, 2024
@gfoidl gfoidl added area-blazor Includes: Blazor, Razor Components and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Nov 18, 2024
@javiercn
Copy link
Member

@TimPurdum thanks for contacting us.

We've identified some performance issues when dealing with large sets of assets. We are working on performance improvements for future SDK releases. I just tested with your project and the build seems to speed up significantly.

  dymaptic.GeoBlazor.Core net8.0 succeeded (6.3s) → bin\Debug\net8.0\dymaptic.GeoBlazor.Core.dll
  dymaptic.GeoBlazor.Core net7.0 succeeded (13.4s) → bin\Debug\net7.0\dymaptic.GeoBlazor.Core.dll
  dymaptic.GeoBlazor.Core net6.0 succeeded (13.4s) → bin\Debug\net6.0\dymaptic.GeoBlazor.Core.dll

Build succeeded in 17.0s

There's more work that is happening on the performance side of things to further optimize large asset collections. In the meantime, there are a couple of things you can do:

  • Exclude from the build any asset that you don't need to ship.
  • Disable static web assets during development/inner loop.
    • This will limit your ability to use MapStaticAssets in an app, but if you are producing a library, it should be fine. You can still rely on app.UseStaticFiles during development.

@javiercn javiercn added this to the 9.0.x milestone Nov 18, 2024
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
Projects
None yet
Development

No branches or pull requests

3 participants