It is currently July 21st, 2019, 3:38 am

Question about Update and UpdateRate

Help with creating, editing & fixing problems with skins
soyelrafa
Posts: 76
Joined: March 1st, 2017, 3:09 pm

Question about Update and UpdateRate

soyelrafa » July 13th, 2017, 2:35 pm

Hello! I'm trying to set the update times of the skins to the minimum necessary, not more nor less.

I'm using a skin with a weather webparser. I see in the rainmeter documentation that update formula of a webparser is:
So the formula would be Update X UpdateDivider X UpdateRate = "how often the measure connects to the site".
However, if I set the update time of the skin to 1800000 (30 minutes), and Updaterate to 1, the skin make the parsering all the time. But if I use that formula, 1800000 x 1 = 1800000, so it must be 30 minutes too. So I want to know what I'm doing wrong.

For example:

Code: Select all

[Rainmeter]
Update=1800000

[mWeather]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1
Url=http://wxdata.weather.com/wxdata/weather/local/#Location#?cc=*&unit=#Unit#&dayf=8
RegExp=#REGEXP#
StringIndex=1
FinishAction=[!SetVariable Test (#Test#+1)][!Update]
DynamicVariables=1

Thanks and best regards!
Last edited by soyelrafa on July 13th, 2017, 8:50 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 19301
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Question about Update and UpdateRate

jsmorley » July 13th, 2017, 2:57 pm

Your problem is a horrific endless loop caused by:

FinishAction=[!SetVariable Test (#Test#+1)][!Update]

You have a large Update value, ok, bad idea (see below) but I can live with that.

However, you are having WebParser go out and get the site data and as soon as it is done, you force an update of the entire skin again. Since UpdateRate is "1", WebParser will go right back out and get data and again fire the FinishAction. You are in an endless loop where you are telling WebParser to basically hammer that site as fast as it possibly can. Not once every 30 minutes, not once a second even, but as fast as it can go. You will hit that site dozens, maybe hundreds of time per minute.

As a general practice, you want to be skeptical about using !Update in bangs. It has its place, but it is very "brute force" and can easily get you into an endless loop if you are not a bit careful. I tend to stay away from it and lean toward more targeted updates of specific things with !UpdateMeasure and !UpdateMeter.


In any case, you don't want to drive this with Update. Leave that at once a second, or Update=1000

Pretty much never set Update in [Rainmeter] more than 1000. It can be less, for animations or other things that required a more often update and redraw of the skin, or it can be Update=-1 to only update one time, if your skin is entirely driven by mouse actions and should be "on demand". But a value greater than 1000 is almost never the right solution. If you need or want things "slower", that's fine, still just set Update=1000, and use UpdateDivider and / or DefaultUpdateDivider on measures and meters to control things.

To have the WebParser measure then be set to go out to the web and get data once every 30 minutes, you would use UpdateRate=1800. Don't set, in fact pretty much never set, UpdateDivider on a WebParser measure.

You don't need or want any "lag" from the time that the WebParser measure actually finishes getting the current data, and when the skin uses it. Having the plugin say "Ok skin, I've got new data" and having the skin use that data in measures and meters one second or less later is what you want. You don't want "Ok skin, I've got new data", and the skin say "I'll get back to you on that in 30 minutes...".
soyelrafa
Posts: 76
Joined: March 1st, 2017, 3:09 pm

Re: Question about Update and UpdateRate

soyelrafa » July 13th, 2017, 8:46 pm

jsmorley wrote:Your problem is a horrific endless loop caused by:

FinishAction=[!SetVariable Test (#Test#+1)][!Update]

You have a large Update value, ok, bad idea (see below) but I can live with that.

However, you are having WebParser go out and get the site data and as soon as it is done, you force an update of the entire skin again. Since UpdateRate is "1", WebParser will go right back out and get data and again fire the FinishAction. You are in an endless loop where you are telling WebParser to basically hammer that site as fast as it possibly can. Not once every 30 minutes, not once a second even, but as fast as it can go. You will hit that site dozens, maybe hundreds of time per minute.

As a general practice, you want to be skeptical about using !Update in bangs. It has its place, but it is very "brute force" and can easily get you into an endless loop if you are not a bit careful. I tend to stay away from it and lean toward more targeted updates of specific things with !UpdateMeasure and !UpdateMeter.


In any case, you don't want to drive this with Update. Leave that at once a second, or Update=1000

Pretty much never set Update in [Rainmeter] more than 1000. It can be less, for animations or other things that required a more often update and redraw of the skin, or it can be Update=-1 to only update one time, if your skin is entirely driven by mouse actions and should be "on demand". But a value greater than 1000 is almost never the right solution. If you need or want things "slower", that's fine, still just set Update=1000, and use UpdateDivider and / or DefaultUpdateDivider on measures and meters to control things.

To have the WebParser measure then be set to go out to the web and get data once every 30 minutes, you would use UpdateRate=1800. Don't set, in fact pretty much never set, UpdateDivider on a WebParser measure.

You don't need or want any "lag" from the time that the WebParser measure actually finishes getting the current data, and when the skin uses it. Having the plugin say "Ok skin, I've got new data" and having the skin use that data in measures and meters one second or less later is what you want. You don't want "Ok skin, I've got new data", and the skin say "I'll get back to you on that in 30 minutes...".
Hello, thanks for your answer. I tried that solution because I have many skins on use and I get a CPU usage of the 8-12 %, so I tried this solution to reduce that.

In this concrete skin, the only thing that are is the weather thing, so I believe that only make an update when retrieving the info is the best solution.

About this concrete scenario, it is very bad to change Update for Redraw to avoid the loop, and let that update time at the same value? Or even in that specific scenario is better your proposed solution?

Again thanks for your answer! I have those things more clear now!

EDIT: After a little try I see that redraw is not a solution neither, so I will do the solution you proposed. Thanks again for the answer!
User avatar
jsmorley
Developer
Posts: 19301
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Question about Update and UpdateRate

jsmorley » July 13th, 2017, 9:19 pm

In my personal view, the cases where any good can come from an Update larger than 1000 are rare. If you use !UpdateDivider appropriately on measures and even meters, you can fine tune a skin as needed.
soyelrafa
Posts: 76
Joined: March 1st, 2017, 3:09 pm

Re: Question about Update and UpdateRate

soyelrafa » July 13th, 2017, 9:48 pm

jsmorley wrote:In my personal view, the cases where any good can come from an Update larger than 1000 are rare. If you use !UpdateDivider appropriately on measures and even meters, you can fine tune a skin as needed.
Perfect, thanks for the clarification!!
User avatar
StArL0rd84
Posts: 336
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Question about Update and UpdateRate

StArL0rd84 » July 14th, 2017, 3:42 pm

Hi, i have a question almost similar to soyelrafa.
Was gonna make a new thread myself till i saw this, so i hope it's ok i ask here.

My YoutubeRSS skins are almost done, and i want to make absolutely sure i don't hammer the site too often.
The skin have the ability to parse 12 channels and show the 12 latest posts from each channel.
So it would be VERY important to get this right.

As per Jsmoley's guidelines i have removed UpdateDividers from my parsers.
But im still uncertain that i have calculated UpdateRate correctly.

The skins Update is as high as the animations within will allow for smooth operation. (32)
Going out from that i used google to calculate milliseconds to minutes.
https://www.google.com/#q=milliseconds+to+minutes

I want the skins to update on the hour so my formula looks like this:
32 x 113.000 > google = 60.2 min

Am i doing it right?
(#WorkTime# = 1 ? #Work# : ([mEnergyLoss:%] > 100 ? #SleepMode# : #Rainmeter#))
User avatar
jsmorley
Developer
Posts: 19301
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Question about Update and UpdateRate

jsmorley » July 14th, 2017, 4:16 pm

There are 31.25 increments of 32 milliseconds in a second.

1000 / 32 = 31.25

There are 3600 seconds in an hour

So

UpdateDivider=((1000 / 32) * 3600)

Or

UpdateDivider=(31.25 * 3600)

Or

Update=32
UpdateDivider=112500

I think that is right...