ForNeVeR/AvaloniaRider

High CPU usage

agnauck opened this issue · 12 comments

When the plugin is enabled I have a consistent 40%-50% CPU load on the Rider process on Windows 11.
When I disable the plugin it goes back to normal (<5%>.

I am running nightly builds of Avalonia and AvaloniaRider 1.0.3.104 on Windows 11.

All I see in the logs is the following exception, but I don't know if this is related to the issue, or normal when the Plugin should refresh the preview.

Sending StartDesignerSessionMessage
System.IO.EndOfStreamException: Attempted to read past the end of the stream.
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.ReadExact(Byte[] buffer) in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 61
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.Reader() in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 73
"C:\Program Files\dotnet\dotnet.exe" exec --runtimeconfig D:\Code\ags\Palaver.Avalonia\Palaver\bin\Debug\net6.0\Palaver.runtimeconfig.json --depsfile D:\Code\ags\Palaver.Avalonia\Palaver\bin\Debug\net6.0\Palaver.deps.json C:\Users\Alex\.nuget\packages\avalonia\11.0.999-cibuild0033725-beta\buildTransitive\..\tools\netcoreapp2.0\designer\Avalonia.Designer.HostApp.dll --transport tcp-bson://127.0.0.1:61057/ --method avalonia-remote D:\Code\ags\Palaver.Avalonia\Palaver\bin\Debug\net6.0\Palaver.dll
Process terminated with exit code 1Obtaining AppBuilder instance from Palaver.Program

seems to be relate to this:
AvaloniaUI/Avalonia#10203

consistent 40%-50% CPU load on the Rider process

Which one of Rider processes?

see here:
image

I downgraded the plugin version for now which helped.
I would assume it resolved when the Avalonia issue linked above gets closed.

Please tell us more about these CPU-eating processes. What's their command line?

see the command lines here in this screenshot:
image

The screenshot was taken with v1.0.3.103 of the plugin. There CPU is only an issue when I have many tabs in in Rider open that contain XAML code. With the latest version of the plugin 1.0.3.104 CPU is much higher because of the Avalonia issue linked above.

I can work around the issue by not having multiple XAML tabs open simultaneously.
I want to add that I am working on a 5 year old i5 quad core laptop. On current hardware the CPU load is probably much ower.

Are you absolutely sure about the difference between 1.0.3.103 and 1.0.3.104? The only changes between those versions were in commits related to the build system, and I can confirm that there's no difference in the compiled binaries.

I can recommend you to limit the previewer FPS for now, to work around the Avalonia issue. The FPS limiter is available on the plugin settings page.

image

Will it become better if you set it to, say, 10?

Are you absolutely sure about the difference between 1.0.3.103 and 1.0.3.104? The only changes between those versions were in commits related to the build system, and I can confirm that there's no difference in the compiled binaries.

no I am not. I need to make more tests. At the beginning it looked fine with the older version but then CPU spiked again.

I can recommend you to limit the previewer FPS for now, to work around the Avalonia issue. The FPS limiter is available on the plugin settings page.

Will it become better if you set it to, say, 10?

I tried values between 1-10 with no difference, but will make more tests.

Same issue, 70% i9 9900k CPU usage.
Each designer preview have .NET Host process which uses 11% of CPU.
Setting FPS limit to 1 have no difference.
I'm interested in solving the problem, it's getting hot and noisy in here :)
I'm using AvaloniaRider v1.0.4, same issue was when I use v1.0.3

Preview console:

System.IO.EndOfStreamException: Attempted to read past the end of the stream.
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.ReadExact(Byte[] buffer) in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 61
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.Reader() in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 73
Process terminated with exit code 1"C:\Program Files\dotnet\dotnet.exe" exec --runtimeconfig E:\Projects\Solutions\RareTraffic\RareTraffic\bin\Debug\net7.0-windows\RareTraffic.runtimeconfig.json --depsfile E:\Projects\Solutions\RareTraffic\RareTraffic\bin\Debug\net7.0-windows\RareTraffic.deps.json C:\Users\sorare\.nuget\packages\avalonia\11.0.0-preview7\buildTransitive\..\tools\netcoreapp2.0\designer\Avalonia.Designer.HostApp.dll --transport tcp-bson://127.0.0.1:52692/ --method avalonia-remote E:\Projects\Solutions\RareTraffic\RareTraffic\bin\Debug\net7.0-windows\RareTraffic.dll
Obtaining AppBuilder instance from RareTraffic.Bootstrapper
Initializing application in design mode
Sending StartDesignerSessionMessage

image

image

Could someone please confirm it is affected by Avalonia version?

Could someone please confirm it is affected by Avalonia version?

I am using always the latest nightly Avalonia builds. I had the issue with all nightly builds in the recent weeks.
I need to use the nightly builds because I rely on many of the v11 enhancements.

I can also confirm it's affected by Avalonia version, upgraded from 10.12 to 11.0.0-rc1.1 recently and faced the same issue (and same error)

System.IO.EndOfStreamException: Attempted to read past the end of the stream.
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.ReadExact(Byte[] buffer) in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 61
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.Reader() in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 73

also tanks the performance of the previewer, goes from updating near-instantly to me having to click the refresh button to get it to happen

Looked at the mentioned issue, and it seems like the fix for it (AvaloniaUI/Avalonia#11596) works as you'd expect with AvaloniaRider! Much better CPU usage and back to updating instantly. It still has the EndOfStreamException though, not sure if it's particularly relevant/important. Thanks again for the great plugin!