From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 1B1C71FF389 for ; Wed, 5 Jun 2024 12:54:44 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8282131A9E; Wed, 5 Jun 2024 12:55:01 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Wed, 5 Jun 2024 12:54:09 +0200 Message-Id: <20240605105416.278748-52-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240605105416.278748-1-c.ebner@proxmox.com> References: <20240605105416.278748-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH v9 proxmox-backup 51/58] client: pxar: set cache limit based on nofile rlimit X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" The lookahead cache size requires the resource limit for open file handles to be high in order to allow for efficient reuse of unchanged file payloads. Increase the nofile soft limit to the hard limit and dynamically adapt the cache size to the new soft limit minus the half of the previous soft limit. The `PxarCreateOptions` and the `Archiver` are therefore extended by an additional field to store the maximum cache size, with fallback to a default size of 512 entries. Signed-off-by: Christian Ebner --- changes since version 8: - no changes pbs-client/src/pxar/create.rs | 6 ++++-- proxmox-backup-client/src/main.rs | 21 ++++++++++++++++--- .../src/proxmox_restore_daemon/api.rs | 1 + pxar-bin/src/main.rs | 1 + 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs index 42e4dc502..fcfb9a09c 100644 --- a/pbs-client/src/pxar/create.rs +++ b/pbs-client/src/pxar/create.rs @@ -56,6 +56,8 @@ pub struct PxarCreateOptions { pub skip_e2big_xattr: bool, /// Reference state for partial backups pub previous_ref: Option, + /// Maximum number of lookahead cache entries + pub max_cache_size: Option, } pub type MetadataArchiveReader = Arc; @@ -275,7 +277,7 @@ where forced_boundaries, suggested_boundaries, previous_payload_index, - cache: PxarLookaheadCache::new(None), + cache: PxarLookaheadCache::new(options.max_cache_size), reuse_stats: ReuseStats::default(), }; @@ -1924,7 +1926,7 @@ mod tests { forced_boundaries: Some(forced_boundaries), previous_payload_index, suggested_boundaries: Some(suggested_boundaries), - cache: PxarLookaheadCache::new(), + cache: PxarLookaheadCache::new(None), reuse_stats: ReuseStats::default(), }; diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs index a17588edf..e01da26fc 100644 --- a/proxmox-backup-client/src/main.rs +++ b/proxmox-backup-client/src/main.rs @@ -41,7 +41,7 @@ use pbs_client::tools::{ crypto_parameters, format_key_source, get_encryption_key_password, KEYFD_SCHEMA, KEYFILE_SCHEMA, MASTER_PUBKEY_FD_SCHEMA, MASTER_PUBKEY_FILE_SCHEMA, }, - CHUNK_SIZE_SCHEMA, REPO_URL_SCHEMA, + raise_nofile_limit, CHUNK_SIZE_SCHEMA, REPO_URL_SCHEMA, }; use pbs_client::{ delete_ticket_info, parse_backup_specification, view_task_result, BackupDetectionMode, @@ -1074,7 +1074,8 @@ async fn create_backup( .start_directory(std::ffi::CString::new(target.as_str())?.as_c_str())?; let mut previous_ref = None; - if detection_mode.is_metadata() { + let max_cache_size = if detection_mode.is_metadata() { + let old_rlimit = raise_nofile_limit()?; if let Some(ref manifest) = previous_manifest { // BackupWriter::start created a new snapshot, get the one before if let Some(backup_time) = client.previous_backup_time().await? { @@ -1100,7 +1101,20 @@ async fn create_backup( .await? } } - } + + if old_rlimit.rlim_max <= 4096 { + log::info!( + "resource limit for open file handles low: {}", + old_rlimit.rlim_max, + ); + } + + Some(usize::try_from( + old_rlimit.rlim_max - old_rlimit.rlim_cur / 2, + )?) + } else { + None + }; let pxar_options = pbs_client::pxar::PxarCreateOptions { device_set: devices.clone(), @@ -1109,6 +1123,7 @@ async fn create_backup( skip_lost_and_found, skip_e2big_xattr, previous_ref, + max_cache_size, }; let upload_options = UploadOptions { diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs index 80af5011e..0a535b7a7 100644 --- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs +++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs @@ -361,6 +361,7 @@ fn extract( skip_lost_and_found: false, skip_e2big_xattr: false, previous_ref: None, + max_cache_size: None, }; let pxar_writer = pxar::PxarVariant::Unified(TokioWriter::new(writer)); diff --git a/pxar-bin/src/main.rs b/pxar-bin/src/main.rs index fa584b4e8..e62348e25 100644 --- a/pxar-bin/src/main.rs +++ b/pxar-bin/src/main.rs @@ -376,6 +376,7 @@ async fn create_archive( skip_lost_and_found: false, skip_e2big_xattr: false, previous_ref: None, + max_cache_size: None, }; let source = PathBuf::from(source); -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel