It is currently April 26th, 2024, 3:53 am

Skin performance issues: High CPU usage from RunCommand plugin

Get help with creating, editing & fixing problems with skins
User avatar
Sacha00Z
Posts: 1
Joined: May 2nd, 2022, 1:31 am

Skin performance issues: High CPU usage from RunCommand plugin

Post by Sacha00Z »

Is there a way of optimising my configuration?

I'm using the RunCommand plugin to call a PowerShell command "Get-Service". I have a series of measures that check the running state of a series of Windows Services. My PowerShell command returns the state of the service (Running/Stopped)

The problem is that my skin absolutely hammers my CPU, occupying 100% CPU every refresh cycle, and 45% of my battery usage (PowerShell) when unplugged. Additionally, meters are not updating on the first refresh cycle. I could increase the update interval if it weren't for the fact that meter updates only occur after the second update cycle.

Setup
(Details ommitted)

Code: Select all

[Rainmeter]
Update=25000
OnUpdateAction=[!CommandMeasure measureSvc1 "Run"][!CommandMeasure measureSvc2 "Run"][!CommandMeasure measureSvc3 "Run"][!CommandMeasure measureSvc4 "Run"][!CommandMeasure measureSvc5 "Run"]

[Variables]
; Configure your solution here. Label to display in skin and the name of each Windows Service to query
Line1Label=Some Service
Line1SvcName=_SomeService1
Line2Label=Another Windows Service
Line2SvcName=_AWinSvc2
Line3Label=SQL Server
Line3SvcName=MSSQL$SQLEXPRESS
Line4Label=Something else
Line4SvcName=com.dockeing.service
Line5Label=Last thing
Line5SvcName=_InternalSystem

Measures

Code: Select all


[measureSvc1]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell
Parameter=(Get-Service '#Line1SvcName#' | Format-Table -HideTableHeaders -Property Status | Out-string).Trim()
State=Hide
DynamicVariables=1
OutputType=ANSI
IfMatch=Stopped
IfMatchAction=[!SetOption MeterIconLine1 ImageName #@#Images\Stopped.png][!SetOption MeterValueLine1 Text ""][!UpdateMeter MeterIconLine1][!Redraw]
IfMatch2=Running
IfMatchAction2=[!SetOption MeterIconLine1 ImageName #@#Images\Running.png][!SetOption MeterValueLine1 Text ""][!UpdateMeter MeterIconLine1][!Redraw]
IfNotMatchAction=[!SetOption MeterIconLine1 ImageName #@#Images\Updating.png][!SetOption MeterValueLine1 Text "Unknown"][!UpdateMeter MeterIconLine1][!Redraw]

; (...copy paste measure 5 times...)

Meters

Code: Select all


; Line 1 
;------------------
[meterLabelLine1]
Meter=String
MeterStyle=styleLeftText
X=10
Y=40   ; Line 1 starts at 40px, and add 20px to each subsequent line
W=190
H=14
Text=#Line1Label#

[MeterValueLine1]
Meter=String
MeasureName=measureSvc1
MeterStyle=styleRightText
X=180
Y=0r
W=190
H=14
Text=%1 

[MeterIconLine1]
Meter=Image
ImageName=#@#Images\Updating.png
X=185
Y=0r
LeftMouseDoubleClickAction=[!Refresh][!Redraw]

[meterSeperator1]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=52
W=190
H=1

; (...copy paste meter 5 times incrementing variables and y values by 20px...)

User avatar
Active Colors
Moderator
Posts: 1254
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Skin performance issues: High CPU usage from RunCommand plugin

Post by Active Colors »

Sacha00Z wrote: May 2nd, 2022, 2:02 am Is there a way of optimising my configuration?

I'm using the RunCommand plugin to call a PowerShell command "Get-Service". I have a series of measures that check the running state of a series of Windows Services. My PowerShell command returns the state of the service (Running/Stopped)

The problem is that my skin absolutely hammers my CPU, occupying 100% CPU every refresh cycle, and 45% of my battery usage (PowerShell) when unplugged.


The CPU spike is happening because you are running five RunCommand commands at the same time. There is no risk by itself running five commands simultaneously, but the spike is happening due to your commands being resource intensive.

I am not sure if you really need to run them simultaneously. If you can run them one after another, then you can do it this way:

Code: Select all

[Rainmeter]
OnUpdateAction=[!CommandMeasure measureSvc1 "Run"]

[measureSvc1]
Measure=Plugin
Plugin=RunCommand
FinishAction=[!CommandMeasure measureSvc2 "Run"]

[measureSvc2]
Measure=Plugin
Plugin=RunCommand
FinishAction=[!CommandMeasure measureSvc3 "Run"]

[measureSvc3]
Measure=Plugin
Plugin=RunCommand
FinishAction=[!CommandMeasure measureSvc4 "Run"]

[measureSvc4]
Measure=Plugin
Plugin=RunCommand
FinishAction=[!CommandMeasure measureSvc5 "Run"]

[measureSvc5]
Measure=Plugin
Plugin=RunCommand
User avatar
Active Colors
Moderator
Posts: 1254
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Skin performance issues: High CPU usage from RunCommand plugin

Post by Active Colors »

Sacha00Z wrote: May 2nd, 2022, 2:02 am Additionally, meters are not updating on the first refresh cycle. I could increase the update interval if it weren't for the fact that meter updates only occur after the second update cycle.
I think this is due to missing bangs.

For example, here and similarly everywhere:

Code: Select all

IfMatchAction2=[!SetOption MeterIconLine1 ImageName #@#Images\Running.png][!SetOption MeterValueLine1 Text ""][!UpdateMeter MeterIconLine1][!Redraw]
you set some option to two meters, but you update only one of them.

This sequence should now work:

Code: Select all

[!SetOption MeterIconLine1 ...][!SetOption MeterValueLine1 ...][!UpdateMeter MeterIconLine1][!UpdateMeter MeterValueLine1][!Redraw]