public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pdm-devel] [PATCH datacenter-manager 1/2] ui: dashboard: increase max-age default to 930 seconds
@ 2025-09-05  8:32 Dominik Csapak
  2025-09-05  8:32 ` [pdm-devel] [PATCH datacenter-manager 2/2] ui: dashboard: make refresh button force the update Dominik Csapak
  2025-09-05 12:26 ` [pdm-devel] [PATCH datacenter-manager 1/2] ui: dashboard: increase max-age default to 930 seconds Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2025-09-05  8:32 UTC (permalink / raw)
  To: pdm-devel

our backend refreshes the metrics with a 15 minute interval, so
using a lower max-age will always refresh it then which is not the point
of the caching mechanism.

Use a slightly higher value than 15 minutes so we mostly use the cached
information.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/dashboard/mod.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs
index cfee55b..9d65122 100644
--- a/ui/src/dashboard/mod.rs
+++ b/ui/src/dashboard/mod.rs
@@ -55,7 +55,8 @@ mod tasks;
 use tasks::TaskSummary;
 
 /// The default 'max-age' parameter in seconds.
-pub const DEFAULT_MAX_AGE_S: u64 = 60;
+// backend refreshes resources every 15 minutes so use that +30 seconds as a buffer
+pub const DEFAULT_MAX_AGE_S: u64 = 930;
 
 /// The default refresh interval
 pub const DEFAULT_REFRESH_INTERVAL_S: u64 = DEFAULT_MAX_AGE_S / 2;
-- 
2.47.2



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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pdm-devel] [PATCH datacenter-manager 2/2] ui: dashboard: make refresh button force the update
  2025-09-05  8:32 [pdm-devel] [PATCH datacenter-manager 1/2] ui: dashboard: increase max-age default to 930 seconds Dominik Csapak
@ 2025-09-05  8:32 ` Dominik Csapak
  2025-09-05 12:26 ` [pdm-devel] [PATCH datacenter-manager 1/2] ui: dashboard: increase max-age default to 930 seconds Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2025-09-05  8:32 UTC (permalink / raw)
  To: pdm-devel

by setting 'max-age' to 0 in that case. Introduce a 'force' parameter
to the reload messges/functions so we can easily control that.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/dashboard/mod.rs        | 20 ++++++++++++--------
 ui/src/dashboard/status_row.rs | 14 +++++++-------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs
index 9d65122..cc7dc58 100644
--- a/ui/src/dashboard/mod.rs
+++ b/ui/src/dashboard/mod.rs
@@ -100,7 +100,7 @@ pub enum Msg {
     LoadingFinished(LoadingResult),
     RemoteListChanged(RemoteList),
     CreateWizard(bool),
-    Reload,
+    Reload(bool), // force
     UpdateConfig(DashboardConfig),
     ConfigWindow(bool),
     Search(Search),
@@ -289,9 +289,13 @@ impl PdmDashboard {
             )
     }
 
-    fn reload(&mut self, ctx: &yew::Context<Self>) {
+    fn reload(&mut self, ctx: &yew::Context<Self>, force: bool) {
         let link = ctx.link().clone();
-        let max_age = self.config.max_age.unwrap_or(DEFAULT_MAX_AGE_S);
+        let max_age = if force {
+            0
+        } else {
+            self.config.max_age.unwrap_or(DEFAULT_MAX_AGE_S)
+        };
         let (_, since) = Self::get_task_options(&self.config);
 
         self.load_finished_time = None;
@@ -360,7 +364,7 @@ impl Component for PdmDashboard {
             config,
         };
 
-        this.reload(ctx);
+        this.reload(ctx, false);
 
         this
     }
@@ -402,8 +406,8 @@ impl Component for PdmDashboard {
                 self.show_wizard = show;
                 true
             }
-            Msg::Reload => {
-                self.reload(ctx);
+            Msg::Reload(force) => {
+                self.reload(ctx, force);
                 true
             }
             Msg::ConfigWindow(show) => {
@@ -416,7 +420,7 @@ impl Component for PdmDashboard {
                 let (new_hours, _) = Self::get_task_options(&self.config);
 
                 if old_hours != new_hours {
-                    self.reload(ctx);
+                    self.reload(ctx, false);
                 }
 
                 self.show_config_window = false;
@@ -445,7 +449,7 @@ impl Component for PdmDashboard {
                         self.config
                             .refresh_interval
                             .unwrap_or(DEFAULT_REFRESH_INTERVAL_S),
-                        ctx.link().callback(|_| Msg::Reload),
+                        ctx.link().callback(|force| Msg::Reload(force)),
                         ctx.link().callback(|_| Msg::ConfigWindow(true)),
                     )),
             )
diff --git a/ui/src/dashboard/status_row.rs b/ui/src/dashboard/status_row.rs
index 26e3319..99cc3b5 100644
--- a/ui/src/dashboard/status_row.rs
+++ b/ui/src/dashboard/status_row.rs
@@ -17,7 +17,7 @@ pub struct DashboardStatusRow {
     last_refresh: Option<f64>,
     reload_interval_s: u64,
 
-    on_reload: Callback<()>,
+    on_reload: Callback<bool>,
 
     on_settings_click: Callback<()>,
 }
@@ -26,7 +26,7 @@ impl DashboardStatusRow {
     pub fn new(
         last_refresh: Option<f64>,
         reload_interval_s: u64,
-        on_reload: impl Into<Callback<()>>,
+        on_reload: impl Into<Callback<bool>>,
         on_settings_click: impl Into<Callback<()>>,
     ) -> Self {
         yew::props!(Self {
@@ -39,7 +39,7 @@ impl DashboardStatusRow {
 }
 
 pub enum Msg {
-    Reload,
+    Reload(bool), // force
     CheckReload,
 }
 
@@ -74,15 +74,15 @@ impl Component for PdmDashboardStatusRow {
     fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
         let props = ctx.props();
         match msg {
-            Msg::Reload => {
-                props.on_reload.emit(());
+            Msg::Reload(force) => {
+                props.on_reload.emit(force);
                 true
             }
             Msg::CheckReload => match ctx.props().last_refresh {
                 Some(last_refresh) => {
                     let duration = Date::now() / 1000.0 - last_refresh;
                     if duration >= props.reload_interval_s as f64 {
-                        ctx.link().send_message(Msg::Reload);
+                        ctx.link().send_message(Msg::Reload(false));
                     }
                     true
                 }
@@ -112,7 +112,7 @@ impl Component for PdmDashboardStatusRow {
                     })
                     .tabindex(0)
                     .disabled(is_loading)
-                    .on_activate(ctx.link().callback(|_| Msg::Reload)),
+                    .on_activate(ctx.link().callback(|_| Msg::Reload(true))),
                 )
                 .tip(tr!("Refresh now")),
             )
-- 
2.47.2



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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pdm-devel] [PATCH datacenter-manager 1/2] ui: dashboard: increase max-age default to 930 seconds
  2025-09-05  8:32 [pdm-devel] [PATCH datacenter-manager 1/2] ui: dashboard: increase max-age default to 930 seconds Dominik Csapak
  2025-09-05  8:32 ` [pdm-devel] [PATCH datacenter-manager 2/2] ui: dashboard: make refresh button force the update Dominik Csapak
@ 2025-09-05 12:26 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2025-09-05 12:26 UTC (permalink / raw)
  To: Proxmox Datacenter Manager development discussion, Dominik Csapak

Am 05.09.25 um 10:32 schrieb Dominik Csapak:
> our backend refreshes the metrics with a 15 minute interval, so
> using a lower max-age will always refresh it then which is not the point
> of the caching mechanism.
> 
> Use a slightly higher value than 15 minutes so we mostly use the cached
> information.
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  ui/src/dashboard/mod.rs | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs
> index cfee55b..9d65122 100644
> --- a/ui/src/dashboard/mod.rs
> +++ b/ui/src/dashboard/mod.rs
> @@ -55,7 +55,8 @@ mod tasks;
>  use tasks::TaskSummary;
>  
>  /// The default 'max-age' parameter in seconds.
> -pub const DEFAULT_MAX_AGE_S: u64 = 60;
> +// backend refreshes resources every 15 minutes so use that +30 seconds as a buffer
> +pub const DEFAULT_MAX_AGE_S: u64 = 930;
>  
>  /// The default refresh interval
>  pub const DEFAULT_REFRESH_INTERVAL_S: u64 = DEFAULT_MAX_AGE_S / 2;

Thanks for this series, while I initially suggested this argument I
found it not really good when rethinking it, so I tried to implement
a better logic that differs first load and successive ones.
Also went a slightly different route for the force-reload, both
implementation wise and behavior wise.

I tried to put in some rationale in the commits implementing this,
they already got pushed and are:

commit 50d0908c39c357b1b76fd12e1a56e33f29239c0b
Author: Thomas Lamprecht <t.lamprecht@proxmox.com>
Date:   Fri Sep 5 14:17:34 2025 +0200

    ui: dashboard: make reload button do a reload with low max-age
    
    Which forces a reload, but not make this a hard cut by using zero
    max-age, as that doesn't ensures real time data either (it will be
    always some 10 to 100ms old) but rather allow it to be at max 3s old.
    This ensures that high-frequent reload button clicks (also from other
    users) do not result in a overload/DOS of the remotes.
    
    Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>

commit 12ee5033aff25be41d96069c9d2ded8d5f22aa1a
Author: Thomas Lamprecht <t.lamprecht@proxmox.com>
Date:   Fri Sep 5 12:11:27 2025 +0200

    ui: dashboard: trigger normal reload directly after initial high-max-age load
    
    With this and the previous commit users should get best of both
    worlds, for one seeing some (maximal 15 minute old) data quickly at
    first render while then getting current data ASAP.
    
    Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>

commit 82f6c1937ca04308d0f44ed54082e2149af746e5
Author: Thomas Lamprecht <t.lamprecht@proxmox.com>
Date:   Fri Sep 5 11:59:03 2025 +0200

    ui: dashboard: use high max-age for initial load
    
    Use the same interval as the backend's cache polling task to try to
    ensure we get data shown to the user fast, as otherwise it's rather
    bad UX if (some) remotes are rather slow.
    
    It's planned to trigger a update with the actual configured polling
    interval directly afterwards in a future commit, but this change
    itself makes sense on it's own.
    
    Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>

commit c6c038a9cffc13c34341955c02fe290cfd38d4fe
Author: Thomas Lamprecht <t.lamprecht@proxmox.com>
Date:   Fri Sep 5 11:30:25 2025 +0200

    ui: dashboard: rework default refresh and max-age interval values
    
    Lower the default max age to 30s, which is a somewhat good default for when
    having the dashboard open for a prolonged time. Note that I plan to
    special case the first load with a higher value in a future commit to
    avoid having to compromise to much here.
    
    Actually lower the default refresh interval, as querying itself is
    cheap, at least if the backend's cache age is new enough, and doing
    that  more often while keeping a higher max-age ensures we profit from
    any actual data update, be it those from the backend's polling task or
    those from force-reloads from other updates.
    
    Also add some rationale to the doc comments, in the end this is
    naturally still chosen by gut-feeling and cannot really be derived
    with a objective and logical deduction.
    
    Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-05 12:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-05  8:32 [pdm-devel] [PATCH datacenter-manager 1/2] ui: dashboard: increase max-age default to 930 seconds Dominik Csapak
2025-09-05  8:32 ` [pdm-devel] [PATCH datacenter-manager 2/2] ui: dashboard: make refresh button force the update Dominik Csapak
2025-09-05 12:26 ` [pdm-devel] [PATCH datacenter-manager 1/2] ui: dashboard: increase max-age default to 930 seconds Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal