all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Fiona Ebner <f.ebner@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH manager 1/2] ui: resource tree: use 'diskuse' instead of calculating everytime
Date: Thu, 11 Dec 2025 14:57:00 +0100	[thread overview]
Message-ID: <ff225b29-3d5a-46dc-9750-f2a98d7d2e06@proxmox.com> (raw)
In-Reply-To: <dfa2ab9c-35ff-4a17-8534-48d89063aa3b@proxmox.com>



On 12/11/25 2:30 PM, Fiona Ebner wrote:
> Am 18.11.25 um 3:48 PM schrieb Dominik Csapak:
>> the resource store has a field 'diskuse' which it calculates on update.
>> Use that instead of calculating the value ourselves everytime.
>>
>> For change detection, we only need a resolution of 0.01 (since we want
>> to use the percentage as integer) so check that the difference of old and new
>> is bigger than 0.9% .
>>
>> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
>> ---
>>   www/manager6/tree/ResourceTree.js | 27 ++++++++++++++++++---------
>>   1 file changed, 18 insertions(+), 9 deletions(-)
>>
>> diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js
>> index bb016f8c..4c4e2908 100644
>> --- a/www/manager6/tree/ResourceTree.js
>> +++ b/www/manager6/tree/ResourceTree.js
>> @@ -57,7 +57,7 @@ Ext.define('PVE.tree.ResourceTree', {
>>                   let text = info.text;
>>                   let status = '';
>>                   if (info.type === 'storage') {
>> -                    let usage = info.disk / info.maxdisk;
>> +                    let usage = info.diskuse;
>>                       if (usage >= 0.0 && usage <= 1.0) {
>>                           let barHeight = (usage * 100).toFixed(0);
>>                           let remainingHeight = (100 - barHeight).toFixed(0);
>> @@ -186,7 +186,7 @@ Ext.define('PVE.tree.ResourceTree', {
>>               qtips.push(Ext.String.format(gettext('HA State: {0}'), info.hastate));
>>           }
>>           if (info.type === 'storage') {
>> -            let usage = info.disk / info.maxdisk;
>> +            let usage = info.diskuse;
>>               if (usage >= 0.0 && usage <= 1.0) {
>>                   qtips.push(Ext.String.format(gettext('Usage: {0}%'), (usage * 100).toFixed(2)));
>>               }
>> @@ -310,8 +310,6 @@ Ext.define('PVE.tree.ResourceTree', {
>>           let stateid = 'rid';
>>   
>>           const changedFields = [
>> -            'disk',
>> -            'maxdisk',
>>               'vmid',
>>               'name',
>>               'type',
>> @@ -409,14 +407,25 @@ Ext.define('PVE.tree.ResourceTree', {
>>                           }
>>                       }
>>   
>> -                    // tree item has been updated
>> -                    for (const field of changedFields) {
>> -                        if (item.data[field] !== olditem.data[field]) {
>> +                    let diskuse = item.data.diskuse;
>> +                    let oldDiskuse = olditem.data.diskuse;
>> +
>> +                    if (diskuse !== undefined || oldDiskuse !== undefined) {
>> +                        if (Math.abs(diskuse - oldDiskuse) > 0.009) {
> 
> Is there a specific reason for using > 0.009? You write "resolution of
> 0.01", so intuitively, I'd expect >= 0.01 or, maybe if rounding matters,
>> = 0.0095.
> 

yeah >= 0.01 is better than whatever i wrote here :P

> If we get a lot of incremental small changes after each other, we might
> not detect a change even though it could've changed a lot overall?

this is only true if another field that triggers a rerender would also
change, in which case we'd also re-render the storage usage anyway.

if the item does not change, we don't overwrite the old data
this part is outside the git context:

```
if (changed) {
     olditem.beginEdit();
     let info = olditem.data;
     Ext.apply(info, item.data)
     if (info.id !== oldid) {
         info.id = oldid;
     }
     me.setIconCls(info);
     olditem.commit();
}
```

so only if any of the relevant data changes we update
the element in the tree store

> 
>>                               changed = true;
>> -                            break;
>>                           }
>>                       }
>> -                    // FIXME: also test filterfn()?
>> +
>> +                    if (!changed) {
>> +                        // tree item has been updated
>> +                        for (const field of changedFields) {
>> +                            if (item.data[field] !== olditem.data[field]) {
>> +                                changed = true;
>> +                                break;
>> +                            }
>> +                        }
>> +                        // FIXME: also test filterfn()?
>> +                    }
>>                   }
>>   
>>                   if (changed) {
> 



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-12-11 13:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-18 14:48 Dominik Csapak
2025-11-18 14:48 ` [pve-devel] [PATCH manager 2/2] ui: resource tree: only fire 'refresh' event when something changed Dominik Csapak
2025-12-11 13:30 ` [pve-devel] [PATCH manager 1/2] ui: resource tree: use 'diskuse' instead of calculating everytime Fiona Ebner
2025-12-11 13:32   ` Fiona Ebner
2025-12-11 13:57   ` Dominik Csapak [this message]
2025-12-12  7:51 ` [pve-devel] superseded: " Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ff225b29-3d5a-46dc-9750-f2a98d7d2e06@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal