From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Dominik Csapak <d.csapak@proxmox.com>
Subject: Re: [pve-devel] [PATCH manager v2 1/2] ui: resource tree: use 'diskuse' instead of calculating everytime
Date: Thu, 22 Jan 2026 16:25:26 +0100 [thread overview]
Message-ID: <91e967d8-fe7a-4588-bc72-bf3b5074cbe3@proxmox.com> (raw)
In-Reply-To: <20251212074419.275374-1-d.csapak@proxmox.com>
Am 12.12.25 um 08:44 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% .
>
> This works because we only overwrite the values in the treestore if
> anything changed, so multiple small changes to the diskuse will not be
> lost.
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> changes from v1:
> * improve commmit message to note why many small changes are not lost
> * use `>= 0.01` instead of `> 0.009`
>
> 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..b0e094f1 100644
> --- a/www/manager6/tree/ResourceTree.js
> +++ b/www/manager6/tree/ResourceTree.js
> @@ -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;
While the API is hard to change, we could still use a bit more telling
variable names, like diskUsage and oldDiskUsage. Just a not, and if I would not
had noticed below tiny potential bug, I might have just fixed this up locally.
> + let oldDiskuse = olditem.data.diskuse;
> +
> + if (diskuse !== undefined || oldDiskuse !== undefined) {
> + if (Math.abs(diskuse - oldDiskuse) >= 0.01) {
this is never true vor the case where one is defined and the other
value is undefined though, as the result then is NaN. But, when old is
undefined and new isn't we probably always want to trigger a change event?
Might be enough to add a extra branch like:
} else if (typeof diskUsage !== typeof oldDiskUsage) {
changed = true;
}
> 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
next prev parent reply other threads:[~2026-01-22 15:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-12 7:40 Dominik Csapak
2025-12-12 7:40 ` [pve-devel] [PATCH manager v2 2/2] ui: resource tree: only fire 'refresh' event when something changed Dominik Csapak
2026-01-22 15:31 ` Thomas Lamprecht
2026-01-22 14:04 ` [pve-devel] [PATCH manager v2 1/2] ui: resource tree: use 'diskuse' instead of calculating everytime Dominik Csapak
2026-01-22 15:19 ` Fiona Ebner
2026-01-22 15:25 ` Thomas Lamprecht [this message]
2026-01-22 15:28 ` Dominik Csapak
2026-01-23 8:15 ` [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=91e967d8-fe7a-4588-bc72-bf3b5074cbe3@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=d.csapak@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox