all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v2] Set MMAP_THRESHOLD to a fixed value (128K)
Date: Tue, 25 Jan 2022 13:34:21 +0100	[thread overview]
Message-ID: <20220125123421.2240918-1-dietmar@proxmox.com> (raw)

This reduces RSS size by factor 10-20 when running backups.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
---

Changes since v1: use libc bindings


 pbs-tools/src/lib.rs              | 10 ++++++++++
 proxmox-backup-client/src/main.rs |  2 ++
 src/bin/proxmox-backup-api.rs     |  2 ++
 src/bin/proxmox-backup-proxy.rs   |  3 +++
 4 files changed, 17 insertions(+)

diff --git a/pbs-tools/src/lib.rs b/pbs-tools/src/lib.rs
index 053b3c0c..670811fe 100644
--- a/pbs-tools/src/lib.rs
+++ b/pbs-tools/src/lib.rs
@@ -8,3 +8,13 @@ pub mod sha;
 pub mod ticket;
 
 pub mod async_lru_cache;
+
+/// Set MMAP_THRESHOLD to a fixed value (128K)
+///
+/// This reduces RSS size by factor 10-20 when running backups (not
+/// sure why).
+pub fn setup_libc_malloc_opts() {
+    unsafe {
+        libc::mallopt(libc::M_MMAP_THRESHOLD, 4096*32);
+    }
+}
diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
index 50682637..a51d5bef 100644
--- a/proxmox-backup-client/src/main.rs
+++ b/proxmox-backup-client/src/main.rs
@@ -1465,6 +1465,8 @@ impl ReadAt for BufferedDynamicReadAt {
 
 fn main() {
 
+    pbs_tools::setup_libc_malloc_opts();
+
     let backup_cmd_def = CliCommand::new(&API_METHOD_CREATE_BACKUP)
         .arg_param(&["backupspec"])
         .completion_cb("repository", complete_repository)
diff --git a/src/bin/proxmox-backup-api.rs b/src/bin/proxmox-backup-api.rs
index e6fc5f23..ee037a3b 100644
--- a/src/bin/proxmox-backup-api.rs
+++ b/src/bin/proxmox-backup-api.rs
@@ -19,6 +19,8 @@ use proxmox_backup::auth_helpers::*;
 use proxmox_backup::config;
 
 fn main() {
+    pbs_tools::setup_libc_malloc_opts();
+
     proxmox_backup::tools::setup_safe_path_env();
 
     if let Err(err) = proxmox_async::runtime::main(run()) {
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index 523966cf..13025271 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -73,6 +73,9 @@ use proxmox_backup::server::do_verification_job;
 use proxmox_backup::server::do_prune_job;
 
 fn main() -> Result<(), Error> {
+
+    pbs_tools::setup_libc_malloc_opts();
+
     proxmox_backup::tools::setup_safe_path_env();
 
     let backup_uid = pbs_config::backup_user()?.uid;
-- 
2.30.2





                 reply	other threads:[~2022-01-25 12:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220125123421.2240918-1-dietmar@proxmox.com \
    --to=dietmar@proxmox.com \
    --cc=pbs-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