Conversation
bb360e2 to
771ebe1
Compare
8a5eec0 to
2327ac5
Compare
|
Can you add a comment in code so it's obvious why a retry is needed? |
absolutely! |
0122aa9 to
cc0b058
Compare
|
@deckstose This is ready now. The collection fix didn't work but the overflow prevention in Draw does work. |
cc0b058 to
f49e166
Compare
deckstose
left a comment
There was a problem hiding this comment.
Fix is looking good to me! 🏅
5fe5eae to
26e7853
Compare
|
AS |
Oof no that was not intentional. I completely missed that. I'll make it not colored different then W |
My quick fix for this was to just add |
26e7853 to
d0c6ab0
Compare
|
Definitely not print the color twice. |
d0c6ab0 to
43bb068
Compare
Alrighty! Sounds good I've changed it so that |
906fbfa to
9557815
Compare
|
@deckstose apparently there is still an issue with this. Give me a moment to figure out what is happening edit: I think I have fixed it though I have to wait to hear back from the reporter. I think maybe it actually is possible for it to report a bad positive number as well. So I made it report bad if the number is 1 million or greater also. This means that CPU watts can only be displayed between a range of 0 - 999,999 (999KW) watts. No 1 million watt cpus allowed 😆 |
e6c0aee to
d4e7842
Compare
|
I kind of think it looks better with the padding between Also, the logic for having KW start at 10,000 is a bit odd... being as kilowatts start at 1000W, so if there was a system drawing that much or more it could be abbreviated (i.e. 1KW, if exactly 1000 watts is used... and something like 1.55KW in the case of 1550W). The highest TDP of any single CPU in production today is 500W (AMD EPYC 9965), so if a system had more than one of those, only then you'd end up in the KW territory.... but as far as reaching 10KW, I don't think it's likely to happen anytime soon... and certainly no common desktop class CPU is ever likely to get into the KW range. |
Thanks for your thoughts on this!
Ahh yes, the reason I chose to start KW at 10,000 was because the space allows for 4 digit numbers (or 3 digits and a decimal). With KW that drops to 3 digits (or 2 and a decimal). When for example 1553W was converted to KW it would be 1.5KW and would lose the precision of the last 53 watts even though there was space to display it. That was my thoughts on it anyway.
Yeah this is a very good point and I think I agree with you. I think the reason I had decided to display values that high was because technically it could already (but would overflow) and while I couldn't think of any CPU that would use that could handle so much power, I thought maybe there would be some extreme overclocker that gets the power up that high even if very unrealistic. I appreciate your feedback! I think you have convinced me to drop KW and use |
|
Agree, with padding looks good (maybe we can explore the string 'err' and/or if dimmed text looks better for the error.
Agreed, but I don't mind it either way. If it fits on the screen and the value is right I don't have a string opinion about it.
Even then you'd need a battery (laptop) that reports power statistics. I don't know of any mainstream platform with a power supply that does this. If I understand the issue correctly, this is a temporary bad value reported by the system, right? What about not changing the shown value until the next good value is read? This might work and be more comprehensible for a user? |
Oh good to know. I will add padding to it. I will also test with the string err and with dimmed text. You might be right that dimmed text could look better.
Cool. I will be considering dropping KW in favor of
Hmm.. I thought that this wattage reading was separate from the battery one. I have a laptop that shows the battery wattage but it doesn't show a value for cpu watts.
That is correct. I could make it not change until a good value is read. In fact that is what I initially did but then I changed it to this because I thought (maybe falsely) that it would be better to show an accurate representation of the current collection even if it contained a bad value vs showing an old value that may or may not represent the current state. You may be right that the user wouldn't care about that though and that using |
|
We need a design decision. I'm not sure what fits best, maybe somebody else can voice their opinion. |
9a8a258 to
6698a25
Compare
|
I have changed it to show the last valid value and set the maximum at 9,999 watts. It really is unrealistic to expect any higher value to be a good reading. I can still change this back to showing However I also removed the usage of the |
|
Ok I am almost completely certain that I have solved the final watts overflow issue. The existing part of the code that was deciding on how many decimal places to use could be off if the value was between 9.995 - 9.999... and 99.95 - 99.999... This would cause one more decimal place then should be present because after the number of decimal places was chosen the number is then rounded and can become |
6698a25 to
b2b4349
Compare
|
After this realization I have applied the one character overflow fix change to the gpu wattage readings as well. They had the potential for an overflow as well if the value was within those ranges. I am waiting to hear back from the initial reporter about testing for this hopefully last modification before marking this as ready for review |
|
This should be good to go now. It seems to have solved the both the bad sensor data overflow and the bad rounding overflow |
b629604 to
ab914c7
Compare
e79de02 to
7d5207d
Compare
prevents a rare bad sensor reading for cpu watts max cpu watts value is now 9,999 watts use `fmt::format_to` for output fix potential one character overflow for gpu pwr usage watts
7d5207d to
8af3ced
Compare


Fixes: #1478
It seems sometimes the sensor can give a bad value that gets calculated as a large negative number (ex.
-64759.826).Example
This PR prevents the bad value from breaking formatting and overflowing the screen by using the last good value if the new reading is negative or greater than 9999
Additionally the checks for decimal precision for both the CPU and GPU watts had a rounding issue that could cause a one character overflow.
Old
If the value is 10,000 or greater then the value is abbreviated and ends in
KWIf
cpu.usage_wattsis a negative value thenbadis printed to the screen instead of the watts. When watts value becomes good again then it prints it.I think the cause of the bad value is that
get_cpuConsumptionUJoules()can sometimes return 0. If that happens then this line would return a negative number.In fact if this is where the negative number is originating and it is because
current_usageis 0 then the reason that the next collection cycle isn't wildly inaccurate is because ifprevious_usageis 0 then it retrieves it fromget_cpuConsumptionUJoules()before gettingcurrent_usageagain so I'm almost certain that this must be what is happening. I suppose ifcurrent_usagevalue is 0 then this function could just try retrieving it again (along with the new timestamp) however if it did end up failing a second time in a row the screen output would still overflow so that code would still be needed. And I don't think it is a good idea to loop over it until it does get a good value. I guess a middle ground could be trying up to 5 times or something? I have added a second commit that does this. Another possibility is that if it fails 5 times in a row it could setsupports_wattsto false. screen redraw would be need for that thoughThis need testing on systems that display cpu watts as mine don't and I had to test using static values. However I do think that I have eliminated any way for the cpu watts value to be larger then 4 characters and overflow the box. And eliminated the most obvious bad wattage values. (negative or 5-digit positive)
I will wait to mark this ready for review after it has been tested by the initial issue reporter
edit: After receiving information from the issue reporter. I have learned that my attempt to fix this issue inside the collection failed. 5 attempts within such a small window was just not enough. It would likely need more time for the reading to become good again and that doesn't seem like a good idea. So instead I have removed that portion and left only the part that prevents an overflow in the Draw code.