It is currently September 21st, 2020, 1:10 pm

[Bug?] UsageMonitor plugin error

Report bugs with the Rainmeter application and suggest features.
User avatar
pul53dr1v3r
Posts: 406
Joined: July 30th, 2014, 10:30 am

Re: [Bug?] UsageMonitor plugin error

Post by pul53dr1v3r »

@tjh
i'm using a CPU that's ~10 years old (i3 540) combined with one SSD.
Also, DynamicVariables and SetOption have been used a lot.

So, if i understood well, you finally got the error and figured out what's the couse of it... :great:
User avatar
balala
Rainmeter Sage
Posts: 11374
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Bug?] UsageMonitor plugin error

Post by balala »

pul53dr1v3r wrote: August 5th, 2020, 2:05 pm Also, DynamicVariables and SetOption have been used a lot.
Recommend not to set dynamic variables, only when needed. For instance on measures or meters using dyanmically set variables (variables set with !SetVariable bangs) or section variables. The measures or meters having options set with !SetOption bangs don't require to set dynamic variables.
User avatar
pul53dr1v3r
Posts: 406
Joined: July 30th, 2014, 10:30 am

Re: [Bug?] UsageMonitor plugin error

Post by pul53dr1v3r »

balala wrote: August 5th, 2020, 5:49 pm Recommend not to set dynamic variables, only when needed. For instance on measures or meters using dyanmically set variables (variables set with !SetVariable bangs) or section variables. The measures or meters having options set with !SetOption bangs don't require to set dynamic variables.
Agree, and i'll have to recheck the code in search for the small mistakes. :rosegift:
User avatar
balala
Rainmeter Sage
Posts: 11374
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Bug?] UsageMonitor plugin error

Post by balala »

pul53dr1v3r wrote: August 6th, 2020, 9:03 pm Agree, and i'll have to recheck the code in search for the small mistakes. :rosegift:
Don't misunderstand me: the code probably does work even with the added DynamicVariables option as well. They are just not needed and are increasing a little bit the CPU usage (even if not too much).
User avatar
tjhrulz
Developer
Posts: 252
Joined: October 13th, 2016, 1:28 am
Location: Earth

Re: [Bug?] UsageMonitor plugin error

Post by tjhrulz »

balala wrote: August 7th, 2020, 7:49 am Don't misunderstand me: the code probably does work even with the added DynamicVariables option as well. They are just not needed and are increasing a little bit the CPU usage (even if not too much).
I actually built it so it would not increase the CPU (Even though I never explicitly said DV is safe) because I know very few people know the !SetOptions trick. IT seems that actually may be the cause (It also is likely going to happen more in a heavy graphics skin) of the issue as once I switched my test skins to DV and loaded a few from modern gadgets I seem to have triggered the issue.

My bet is having ran through the code I passed the old instance by reference instead of by value when a measure reloaded. So that may be how it is becoming null as in the very rare chance that reload happens on a measure and then UsageMonitiors backhaul updates between that reload and a give GetString for that measure then the Instance would be null due to me improperly keeping the old instance the measure had last time.

I have fixed this in the code and also played it safe switching a few other cases of me passing by reference when I should be passing by value just to be safe. Running it through its passes now and hopefully will have one for you guys to test this evening.
User avatar
balala
Rainmeter Sage
Posts: 11374
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Bug?] UsageMonitor plugin error

Post by balala »

tjhrulz wrote: August 7th, 2020, 7:59 pm I actually built it so it would not increase the CPU (Even though I never explicitly said DV is safe) because I know very few people know the !SetOptions trick.
Which !SetOption (not !SetOptions) trick did you think to?
User avatar
pul53dr1v3r
Posts: 406
Joined: July 30th, 2014, 10:30 am

Re: [Bug?] UsageMonitor plugin error

Post by pul53dr1v3r »

balala wrote: August 7th, 2020, 7:49 am Don't misunderstand me: the code probably does work even with the added DynamicVariables option as well. They are just not needed and are increasing a little bit the CPU usage (even if not too much).
It's a golden advice that buries my sporadic carelessness. The performacne are one of the most important things i care for so i goes without saying how much such a thing is valuable. :great:
User avatar
Yincognito
Posts: 2565
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Bug?] UsageMonitor plugin error

Post by Yincognito »

tjhrulz wrote: August 7th, 2020, 7:59 pmMy bet is having ran through the code I passed the old instance by reference instead of by value when a measure reloaded. So that may be how it is becoming null as in the very rare chance that reload happens on a measure and then UsageMonitiors backhaul updates between that reload and a give GetString for that measure then the Instance would be null due to me improperly keeping the old instance the measure had last time.

I have fixed this in the code and also played it safe switching a few other cases of me passing by reference when I should be passing by value just to be safe. Running it through its passes now and hopefully will have one for you guys to test this evening.
That explains it, assuming that this is indeed what happens. Looking forward to see your updated version - hopefully it will still work with DV properly. I mean, there are cases when !SetOption just isn't feasible, as you might want to avoid having to update the measure / meter too soon and such, not to mention the !SetVariable bang is a bit shorter in length, so it's more comfortable too. :)
User avatar
tjhrulz
Developer
Posts: 252
Joined: October 13th, 2016, 1:28 am
Location: Earth

Re: [Bug?] UsageMonitor plugin error

Post by tjhrulz »

balala wrote: August 7th, 2020, 8:23 pm Which !SetOption (not !SetOptions) trick did you think to?
Well !SetOption effectively is the same as if dynamic variables was set for one update cycle. Thus if you know when something is going to change for a measure you can just set options it and get the same effect. Now there sometimes will be some quirks where you'll need to make sure that an option is set as the variable itself and not the value of the variable or else it won't update without having changed that option as well. But if I were to write a how to optimize a skin 101 this is pretty much your first thing you can do as almost 100% of the time that can be used instead of dynamic variables, and the performance is usually significantly better.

This is actually my number one thing I critique skins on that are posted in the rainmeter discord
User avatar
Yincognito
Posts: 2565
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Bug?] UsageMonitor plugin error

Post by Yincognito »

pul53dr1v3r wrote: August 7th, 2020, 8:45 pm It's a golden advice that buries my sporadic carelessness. The performacne are one of the most important things i care for so i goes without saying how much such a thing is valuable. :great:
Me too, but DV is rarely going to produce a significant impact on performance, really. Obviously, I'm not talking about monster skins / skin suites that have other things coded inefficiently or a buch of other resources involved, as those will for sure feel the added pressure from DV. From what I can tell (hopefully I'm not mistaken), DV is only a "threat" to performance as an additional effect on other much worse CPU usage hogs.