razor icon indicating copy to clipboard operation
razor copied to clipboard

Hot Reload Takes Nearly 45 Seconds to Update

Open vsfeedback opened this issue 4 years ago • 83 comments

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work] Please see attached. Hot Reload now works for me, but takes forever to update, nearly 45 seconds to be more precise.


Original Comments

Feedback Bot on 11/11/2021, 03:48 PM:

This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.


Original Solutions

(no solutions)

vsfeedback avatar Nov 13 '21 05:11 vsfeedback

@pranavkm I know that you've been looking into this already. Is there another issue to dupe this against?

mkArtakMSFT avatar Nov 13 '21 05:11 mkArtakMSFT

More reports:

  • https://developercommunity.visualstudio.com/t/VS2022-with-Blazor-Server-project-is-ter/1584485

NTaylorMullen avatar Nov 16 '21 04:11 NTaylorMullen

same for me its just not flawless yet... :(

Mercurial avatar Nov 21 '21 14:11 Mercurial

This is a duplicate of https://github.com/dotnet/aspnetcore/issues/32867. Workaround can be found here: https://developercommunity.visualstudio.com/t/Hot-Reload-in-VS-very-slow-but-fast-wit/1563649

CommonLoon102 avatar Nov 22 '21 10:11 CommonLoon102

I have similar issue, but just a lot worse.

For a slightly complicated page (~450 lines of razor, a few loops etc.) hot-reload from VS2022 takes 2:30 (2 minutes and 30 seconds) of really hammering the CPU to apply changes, and after that the changes still does not get rendered, and I have to restart the app.

Using the suggested workaround using dotnet watch it "only" takes 50-80 seconds. But now it actually also renders the changes.

It's only this extreme for this particular page. For very simple pages it's working OK, and changes are applied within 10 seconds. I've tried to find if it's any particular code on this page that is "bad" by process of elimination, and I can't find any specific error but in-line loops just seems to absolutely kill the performance.

MichelJansson avatar Dec 05 '21 18:12 MichelJansson

I do apologize for the confusion here. According to this comment, this should have been addressed in preview2? This was my understanding when I posted my last comment, which seems to have contributed to the issue being locked. 😇

But now it appears with subsequent updates that this is slated for .NET7, if I understand correctly. I am totally fine with this as long as it is being communicated correctly so that we're not operating under false impression/understanding. For instance, I wouldn't have posted my last comment on dotnet/aspnetcore#32867 as I was under the impression that a fix had already been checked in as per the previous comment (which I probably misunderstood).

In any case, please know that I for one truly appreciate all the effort being applied there with this task and the project as a whole. You are truly moving mountains over there. 🙏

Mike-E-angelo avatar Jan 28 '22 11:01 Mike-E-angelo

Based on this PR, it is being backported to .NET 6.0.3: https://github.com/dotnet/sdk/pull/23419

It was told that it will come in VS 17.2 (see last comment in the PR linked above). I don't know the ETA for that. Even 17.1 is yet to be released.

CommonLoon102 avatar Jan 28 '22 18:01 CommonLoon102

Ahhhhh 17.2, not to be confused with 17.1 Preview 2, as I was doing. :) Thank you for the pointer and correction, @CommonLoon102.

Mike-E-angelo avatar Jan 28 '22 18:01 Mike-E-angelo

@Mike-E-angelo 17.2 preview1 would ship the same day 17.1 ships (part way thru February 2022).

pranavkm avatar Jan 28 '22 18:01 pranavkm

17.2 Preview 1 is out but it is still 40 seconds to do a "hot" reload.

CommonLoon102 avatar Feb 21 '22 10:02 CommonLoon102

Not really related to this issue other than if I wasn't doing this, then I wouldn't be here in the first place. :) I recently announced my product that is built on your tech and is responsible for finding all these issues. 😁

https://alpha.starbeam.one/about/acknowledgements

I have a shout out to you there @pranavkm. Thank you for all your great work over there. 🙏

Mike-E-angelo avatar Feb 25 '22 21:02 Mike-E-angelo

Me and my team are working on a big scale project right now and we decided to update to .NET 6.0 and we have the same issue with our windows users. It looks like it works perfectly fine in the M1 Mac version. Also we noticed that some of our code that includes SQL Server works slower, noticeably slower. I, myself, use hot reload very much but i don't mind debugging every time, but it's the same speed so i do not bother.

aqim-dev avatar Mar 15 '22 10:03 aqim-dev

https://github.com/dotnet/sdk/pull/24538

🤔

Mike-E-angelo avatar Mar 26 '22 08:03 Mike-E-angelo

No comment given on the reversion, but it appears it was leading to problems such as this one, which I ran into yesterday: https://developercommunity.visualstudio.com/t/perpetual-15-20-cpu-churn-by-servicehubroslyncodea/1703772

(Reference: https://github.com/dotnet/razor-tooling/issues/5697#issuecomment-1080942033)

Mike-E-angelo avatar Mar 28 '22 17:03 Mike-E-angelo

Is there still any hope that the community will get a 3-4 seconds hot-reload time instead of 40-45 seconds? Is this still considered fixable? The issue is there since .NET 6 release and the new previews didn't bring any improvements. I also can't see a fix for this in the .NET 7 roadmap. I'm asking because we need to consider this when we deciding about the technology we want to use in new projects.

CommonLoon102 avatar May 05 '22 04:05 CommonLoon102

Not looking too promising here. Any further update, @pranavkm?

Mike-E-angelo avatar May 05 '22 06:05 Mike-E-angelo

I do most of my development using dotnet watch -- the hot reload rarely takes more than 5 seconds there. At least when it deigns to use it, anyway; there's a lot of seemingly innocuous changes that it apparently considers to be rude. The VS debugger seems a bit random on whether it will stop on breakpoints or not anyway, so I try to use it only when I can't find out what the app is up to any other way.

uecasm avatar May 05 '22 11:05 uecasm

I do most of my development using dotnet watch -- the hot reload rarely takes more than 5 seconds there.

It depends on the file you edit. I have files which reload in a second with dotnet watch, others take more, some can take up to 45 seconds. Although I just change some text in a <span>, it still takes 45 seconds...

CommonLoon102 avatar May 05 '22 11:05 CommonLoon102

For the VS hot reload performance we have a PR out in the SDK repo, which should improve things. https://github.com/dotnet/sdk/pull/24928

For dotnet watch and even faster VS we have some ideas of how to improve the performance, but don't have any concrete timelines yet.

chsienki avatar May 05 '22 20:05 chsienki

Thank you for taking the time to update us, and for all your efforts out there @chsienki & team. 🙏

Mike-E-angelo avatar May 05 '22 20:05 Mike-E-angelo

Any update with this issue, by chance? I have yet to use Hot Reload once for my Blazor solution. Well, outside of it taking a minute or so for it to work and reporting it here as a bug. :P

Mike-E-angelo avatar Sep 12 '22 18:09 Mike-E-angelo

It takes mine ~28 seconds to update on a relatively small blazor project with some Telerik controls.

I am using a 10core, 64gb machine, I am using .NET 7.0 as well.

I am using dotnet watch run / dotnet watch The workaround posted does nothing for me

It actually a lot faster if i Ctrl+C and dotnet watch run / dotnet watch again

zoinkydoink avatar Jan 22 '23 17:01 zoinkydoink

What is the latest on this please?

I love the tech but it's so disheartening when fixing a typo in an html class and then having to wait over a minute for that change to appear on the UI. It just destroys productivity.

Does anyone have any workarounds or am I best to abandon hot reload and just rebuild and retest every now and again?

image

dotnet watch ⌚ File changed: ./.Client/Pages/Activity.razor.

<LONG WAIT>

dotnet watch ⌚ Received 1 from browser in [Count: 1, MessageType: Binary, EndOfMessage: True].
dotnet watch ⌚ Received successful apply from delta applier.
dotnet watch 🔥 Hot reload of changes succeeded.
dotnet watch 🔥 Hot reload change handled in 6212834.683ms.

Drammy avatar Jun 06 '23 09:06 Drammy

@Drammy @zoinkydoink @Mike-E-angelo and others experiencing very long (>20s) hot reload times: are you all working on Blazor WebAssembly projects? Has anybody experienced these very long times in Visual Studio when working on Blazor Server projects?

DamianEdwards avatar Jun 06 '23 14:06 DamianEdwards

Blazor server here, @DamianEdwards. I have yet to ever see Hot Reload work once in a viable way while in Visual Studio. FWIW I am also the one who reported the original issue on developercommunity under a previous account, and this should reflect a Blazor server project as well.

Mike-E-angelo avatar Jun 06 '23 14:06 Mike-E-angelo

@DamianEdwards I am using Blazor Server side, I tracked down my issue further. It seems that having about 20-30 controls (html and mixed with telerik blazor) was actually the issue. If i have a blank blazor page with minimal stuff on it then hot reload is instant. so it has something to do with having too many elements on the page.

I gave up using hot reload on this page because the next thing i needed to do was redesign my page with more components than just straight up html/telerik controls directly on the page.

All in all, do a lot of testing with many controls and figure out why that is an issue.

Thanks for following up though

zoinkydoink avatar Jun 06 '23 14:06 zoinkydoink

@Drammy @zoinkydoink @Mike-E-angelo and others experiencing very long (>20s) hot reload times: are you all working on Blazor WebAssembly projects? Has anybody experienced these very long times in Visual Studio when working on Blazor Server projects?

@DamianEdwards We're developing Blazor web assembly using Rider on a Mac, so just the dotnet command line tools for us.

Drammy avatar Jun 06 '23 15:06 Drammy

For what its worth I've refactored the large page component down into numerous smaller components and the hot reload performance is much better.

Drammy avatar Jun 08 '23 09:06 Drammy

You could also try moving out components to separate projects, even to multiple projects. And only have the pages in one project which just using the components. I'm not sure if it would help on the performance, but worth a try.

CommonLoon102 avatar Jun 08 '23 13:06 CommonLoon102

See also: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1465553

tmat avatar Jun 21 '23 16:06 tmat