From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 9A03920EC7F for ; Tue, 23 Apr 2024 15:24:36 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 74CB932C73; Tue, 23 Apr 2024 15:24:40 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Tue, 23 Apr 2024 15:23:39 +0200 Message-ID: <20240423132341.570192-1-c.heiss@proxmox.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.005 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH installer] tui: update screen during installation only when necessary X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" This can significantly reduces CPU load and even speed up the installation a lot on single-core machines. While the latter may not be a realistic target for obvious reasons, lowering overall CPU usage is always a good thing. Also helps with flickering during the installation process quite a bit too. E.g. a test installation on a single-core VM goes down from 47:35 min w/o the patch to 2:26 min w/ the patch, a ~94%(!) decrease in time. Signed-off-by: Christoph Heiss --- proxmox-tui-installer/src/main.rs | 3 -- .../src/views/install_progress.rs | 32 +++++++++++-------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/proxmox-tui-installer/src/main.rs b/proxmox-tui-installer/src/main.rs index 2462a58..4fb7afd 100644 --- a/proxmox-tui-installer/src/main.rs +++ b/proxmox-tui-installer/src/main.rs @@ -664,9 +664,6 @@ fn summary_dialog(siv: &mut Cursive) -> InstallerView { } fn install_progress_dialog(siv: &mut Cursive) -> InstallerView { - // Ensure the screen is updated independently of keyboard events and such - siv.set_autorefresh(true); - let state = siv.user_data::().cloned().unwrap(); InstallerView::with_raw(&state, InstallProgressView::new(siv)) } diff --git a/proxmox-tui-installer/src/views/install_progress.rs b/proxmox-tui-installer/src/views/install_progress.rs index 71af484..6453426 100644 --- a/proxmox-tui-installer/src/views/install_progress.rs +++ b/proxmox-tui-installer/src/views/install_progress.rs @@ -1,7 +1,7 @@ use cursive::{ utils::Counter, view::{Nameable, Resizable, ViewWrapper}, - views::{Dialog, DummyView, LinearLayout, PaddedView, ProgressBar, TextContent, TextView}, + views::{Dialog, DummyView, LinearLayout, PaddedView, ProgressBar, TextView}, CbSink, Cursive, }; use serde::Deserialize; @@ -21,15 +21,15 @@ pub struct InstallProgressView { } impl InstallProgressView { + const PROGRESS_TEXT_VIEW_ID: &str = "progress-text"; + pub fn new(siv: &mut Cursive) -> Self { let cb_sink = siv.cb_sink().clone(); let state = siv.user_data::().unwrap(); - let progress_text = TextContent::new("starting the installation .."); let progress_task = { - let progress_text = progress_text.clone(); let state = state.clone(); - move |counter: Counter| Self::progress_task(counter, cb_sink, state, progress_text) + move |counter: Counter| Self::progress_task(counter, cb_sink, state) }; let progress_bar = ProgressBar::new().with_task(progress_task).full_width(); @@ -41,7 +41,11 @@ impl InstallProgressView { LinearLayout::vertical() .child(PaddedView::lrtb(1, 1, 0, 0, progress_bar)) .child(DummyView) - .child(TextView::new_with_content(progress_text).center()) + .child( + TextView::new("starting the installation ..") + .center() + .with_name(Self::PROGRESS_TEXT_VIEW_ID), + ) .child(PaddedView::lrtb( 1, 1, @@ -54,12 +58,7 @@ impl InstallProgressView { Self { view } } - fn progress_task( - counter: Counter, - cb_sink: CbSink, - state: InstallerState, - progress_text: TextContent, - ) { + fn progress_task(counter: Counter, cb_sink: CbSink, state: InstallerState) { let mut child = match spawn_low_level_installer(state.in_test_mode) { Ok(child) => child, Err(err) => { @@ -129,13 +128,18 @@ impl InstallProgressView { }), UiMessage::Progress { ratio, text } => { counter.set((ratio * 100.).floor() as usize); - progress_text.set_content(text); - Ok(()) + cb_sink.send(Box::new(move |siv| { + siv.call_on_name(Self::PROGRESS_TEXT_VIEW_ID, |v: &mut TextView| { + v.set_content(text); + }); + })) } UiMessage::Finished { state, message } => { counter.set(100); - progress_text.set_content(message.to_owned()); cb_sink.send(Box::new(move |siv| { + siv.call_on_name(Self::PROGRESS_TEXT_VIEW_ID, |v: &mut TextView| { + v.set_content(&message); + }); Self::prepare_for_reboot(siv, state == "ok", &message); })) } -- 2.44.0 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel