It is currently April 18th, 2024, 10:33 pm

[Help] Some questions about performance

Get help with creating, editing & fixing problems with skins
ruby_chan_42
Posts: 3
Joined: January 24th, 2021, 4:57 pm

[Help] Some questions about performance

Post by ruby_chan_42 »

i first posted this on the subreddit and i've been told to post it here, so i'm just going to copy and paste it, i hope you don't mind

I've been tinkering with rainmeter for a while now and maybe i missed this, or didn't search hard enough, but i have some doubts regarding performance.

1. is it more efficient to have a bunch of small skins or is it better to have as much info as posible in the same skin? For example, I have ram, cpu and gpu on separate skins because I need them to update at different rates, would it be better to merge them and add UpdateDivider to everything, or just keep it as is?

2. Speaking of UpdateDivider, if i have a bunch of decorative texts, lines and borders, all of them with updatedivider=-1, should i replace them with static images or am i good?

3. Also on the topic of updates, let's say I have a skin that shows seconds, minutes, hours, day, month and year, I have all of them paused except the seconds, so when the seconds measure updates i run an If condition, If seconds==0 Update Minutes, and do the same for all the rest, only update hours if minutes is 0, Days if Hour is 0 and so on, does that affect performance at all? if so, does it improve it, or makes things worse?[/list]

That's all i can think for now, but i also have some doubts about how WebMeasure parents and childs thing woks, I read the documentation but either it wasn't very clear, or im dumb, I don't discard the second option.
If you have any tips you've learned, posts, discussions, anything related to this, I'd appreciate if you could share that,

Thanks in advance

og post: https://www.reddit.com/r/Rainmeter/comments/l4123v/some_questions_about_performance/
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: [Help] Some questions about performance

Post by Active Colors »

The developers might have more technical details than me.
ruby_chan_42 wrote: January 24th, 2021, 5:07 pm 1. is it more efficient to have a bunch of small skins or is it better to have as much info as posible in the same skin? For example, I have ram, cpu and gpu on separate skins because I need them to update at different rates, would it be better to merge them and add UpdateDivider to everything, or just keep it as is?
I would say it is better to have them in one skin since this would involve less canvases (skins) to draw on desktop and less to update. Even though the amount of information is the same in both cases, in the case where you have multiple skins – you are updating multiple skins which is a some impact.
ruby_chan_42 wrote: January 24th, 2021, 5:07 pm 2. Speaking of UpdateDivider, if i have a bunch of decorative texts, lines and borders, all of them with updatedivider=-1, should i replace them with static images or am i good?
Image files cost more in terms of performance. It is better to use shapes and texts in this case. If you use a small image and don't manipulate its width and/or height it is not making a visible impact. ScaleMargins is useful for graphical elements like backgrounds.
ruby_chan_42 wrote: January 24th, 2021, 5:07 pm 3. Also on the topic of updates, let's say I have a skin that shows seconds, minutes, hours, day, month and year, I have all of them paused except the seconds, so when the seconds measure updates i run an If condition, If seconds==0 Update Minutes, and do the same for all the rest, only update hours if minutes is 0, Days if Hour is 0 and so on, does that affect performance at all? if so, does it improve it, or makes things worse?
That's an interesting approach I have never thought about this before. But the amount of things to update is insignificant here. Since you update your skin and seconds once a second in this manner it is already causing a "pressure". But make sure when you run this skin for the first time or refresh it, all the info is updated on the refresh with OnRefreshAction.
User avatar
Alex88
Posts: 92
Joined: July 18th, 2020, 1:23 am
Location: California

Re: [Help] Some questions about performance

Post by Alex88 »

ruby_chan_42 wrote: January 24th, 2021, 5:07 pm 1. is it more efficient to have a bunch of small skins or is it better to have as much info as posible in the same skin? For example, I have ram, cpu and gpu on separate skins because I need them to update at different rates, would it be better to merge them and add UpdateDivider to everything, or just keep it as is?
In general terms, unless you have a lot of measures and meters where some include very fast update rates (50ms, 25ms, etc.), I would expect the difference to be negligible. If anything, like AC mentioned, it's probably better to consolidate it to a single skin and apply the appropriate UpdateDivider=# to have a single 'canvas' instead of individually painting many small ones.

It's not about the exact question but check out this thread and particularly this post that are closely related experiments going further into the general question of update rates and resource usage. What exactly happens during an update cycle is explained here.
ruby_chan_42 wrote: January 24th, 2021, 5:07 pm 2. Speaking of UpdateDivider, if i have a bunch of decorative texts, lines and borders, all of them with updatedivider=-1, should i replace them with static images or am i good?
Unless you already wanted to stylize the text further than what's possible in Rainmeter, the built-in text and shapes have better performance compared to having many images.
ruby_chan_42 wrote: January 24th, 2021, 5:07 pm 3. Also on the topic of updates, let's say I have a skin that shows seconds, minutes, hours, day, month and year, I have all of them paused except the seconds, so when the seconds measure updates i run an If condition, If seconds==0 Update Minutes, and do the same for all the rest, only update hours if minutes is 0, Days if Hour is 0 and so on, does that affect performance at all? if so, does it improve it, or makes things worse?[/list]
Similar to what AC said, it's an interesting idea, but unless you're flipping on and off tons of fast-moving measures and meters, it's best just to set individual UpdateDividers and they'll update correctly on their own.

Another tool to use is DefaultUpdateDivider in the [Rainmeter] section. A good use of it with skins with many (but not all) static measures/meters could be:

Code: Select all

[Rainmeter]
Update=1000
DefaultUpdateDivider=-1
...

[StaticMeter1]
...

[DynamicMeter1]
UpdateDivider=1
...

[DynamicMeter2]
UpdateDivider=5
...
That will start with the normal 1 second (or whatever you choose) global update rate, apply UpdateDivider=-1 to every measure and meter, then individual UpdateDividers can cover any needed update rate. From what I've tried that's basically the best way to go.
ruby_chan_42
Posts: 3
Joined: January 24th, 2021, 4:57 pm

Re: [Help] Some questions about performance

Post by ruby_chan_42 »

Active Colors wrote: January 24th, 2021, 5:35 pm Image files cost more in terms of performance. It is better to use shapes and texts in this case. If you use a small image and don't manipulate its width and/or height it is not making a visible impact. ScaleMargins is useful for graphical elements like backgrounds.
That's actually really useful, i have to read more about scale margins, but i'm guessing, and correct me if i'm wrong, but if a skin has an update of -1 having modified images wouldn't impact performance, right?
Active Colors wrote: January 24th, 2021, 5:35 pm That's an interesting approach I have never thought about this before. But the amount of things to update is insignificant here. Since you update your skin and seconds once a second in this manner it is already causing a "pressure". But make sure when you run this skin for the first time or refresh it, all the info is updated on the refresh with OnRefreshAction.
the "OnRefreshAction" bit is really interesting, i thought all meters updated automatically regardles of dividers or such.
But also, would it really cause so much preasure? I mean, you are right, i'm checking every second to update de minutes, but the if inside the minutes' measure would only run every 60 seconds, the hours one every hour and so on.
I don't want to say you are wrong here, surely you know better than me, but from my point of view it seems more efficient to update the months every time the day changes rather than every second, again, I may be completely wrong, and would love to be corrected, and learn more

Sorry for the late response, btw
ruby_chan_42
Posts: 3
Joined: January 24th, 2021, 4:57 pm

Re: [Help] Some questions about performance

Post by ruby_chan_42 »

Alex88 wrote: January 25th, 2021, 4:54 am In general terms, unless you have a lot of measures and meters where some include very fast update rates (50ms, 25ms, etc.), I would expect the difference to be negligible. If anything, like AC mentioned, it's probably better to consolidate it to a single skin and apply the appropriate UpdateDivider=# to have a single 'canvas' instead of individually painting many small ones.

It's not about the exact question but check out this thread and particularly this post that are closely related experiments going further into the general question of update rates and resource usage. What exactly happens during an update cycle is explained here.
Okay, i read throgh most of that, the images thing, the update divider and the code, really interesting I must say, and I assure you I'll check it again if i run into some issues.

And reading all of that, I'll ask you a question if I may. I have a skin that is a menu/launcher, update is set to 100 and Default update divider to -1, what i want is when i hover over an item in the menu it changes color and a sort of border appears, i have all that done with some lua, tried to use as less bangs as possible (don't know if that's good). Basically what it does when you hover an item is this:

Code: Select all

MouseOverAction=[!CommandMeasure "MenuLua" "hoverMenuItem('[#isItemSelected]', '[#itemSelected]','([#MenuStartX]-10)', '(([#MenuStartY]+([#gap]*7))-15)', '8')"]

Code: Select all

function hoverMenuItem(isSelected, selectedItem, MoveToX, MoveToY, item)

    if selectedItem ~= item then
        if isSelected == 'false' then

            drawHoveredItem(SKIN:ParseFormula(MoveToX), SKIN:ParseFormula(MoveToY), item, MenuBg)

        else

            drawHoveredItem(SKIN:ParseFormula(MoveToX), SKIN:ParseFormula(MoveToY), item, MenuUnderline)

        end

    end

end

function drawHoveredItem(MoveToX, MoveToY, item, overlay)
    RedMenuText = SKIN:GetMeter('menu_item_' .. item)

    overlay:SetX(MoveToX)
    overlay:SetY(MoveToY)

    overlay:Show()

    SKIN:Bang('!SetOption', RedMenuText:GetName(), 'FontColor', colorBlue)
    SKIN:Bang('!SetOption', RedMenuText:GetName(), 'InlineSetting', 'Shadow | 0 | 0 | #Glow# |'.. colorBlue)
    SKIN:Bang('!UpdateMeter', RedMenuText:GetName())
end

isItemSelected is a variable and checks if another item has been clicked
itemSelected stores what the clicked item is
overlay is the border to show arround the hovered item, it's a meter and i only have one, so i move to the needed position

the problem comes when i go over the items really fast, rainmeter starts consuming all my CPU, is there a way to make it more efficient? or do i just have to be careful?

you don't have to answer if you don't want to.

and sorry for taking so long to answer, you have been really helpful, thanks ^^
User avatar
Alex88
Posts: 92
Joined: July 18th, 2020, 1:23 am
Location: California

Re: [Help] Some questions about performance

Post by Alex88 »

ruby_chan_42 wrote: January 30th, 2021, 7:07 pm ...
And reading all of that, I'll ask you a question if I may. I have a skin that is a menu/launcher, update is set to 100 and Default update divider to -1, what i want is when i hover over an item in the menu it changes color and a sort of border appears, i have all that done with some lua, tried to use as less bangs as possible (don't know if that's good). Basically what it does when you hover an item is this:
...
the problem comes when i go over the items really fast, rainmeter starts consuming all my CPU, is there a way to make it more efficient? or do i just have to be careful?
...
Note I don't fully know Lua yet, so I can't speak to specifics about if it is optimized or not, but the code is short and simple enough that I can definitely follow the logic of it and would guess it's not the issue. But even before the Lua, it sounds like if you're painting and re-painting the skin canvas quickly, it will be GPU intensive, so I would first check that hardware acceleration is on (for some systems the opposite is better).
Even with generally optimized configs and without Lua or complex configs, spamming buttons and similar will generally consume resources quickly unless the GPU is handling it, hardware acceleration on (same note as above, a few systems are opposite, better with hardware acceleration off).