public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-mail-forward] pve-notify-worker: use current-thread runtime
Date: Mon, 23 Nov 2026 10:20:04 +0100	[thread overview]
Message-ID: <20261123092004.120457-1-l.wagner@proxmox.com> (raw)

The multi-threaded runtime used by proxmox_async::runtime::main by
default spawns one worker thread per CPU core, which is wasteful for
something as trivial as pve-notify-worker.

The send code path is fully sync at the moment and invoked via
spawn_blocking; the async parts of the worker are simple enough to not
gain any significant advantage from the heavy multi-threaded
work-stealing runtime, thus we just pick the current-thread runtime.

If proxmox-notify gains any meaningful async code paths, we might want
to switch to the multi-threaded runtime again, but with a limited number
of workers.

Also only pull in the necessary features of tokio, 'rt'.  We still pull
in 'rt-multi-thread' via proxmox-async, so the binary itself only
shrinks by about 20KB.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 pve-notify-worker/Cargo.toml  | 2 +-
 pve-notify-worker/src/main.rs | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/pve-notify-worker/Cargo.toml b/pve-notify-worker/Cargo.toml
index 61738e9..99f7abf 100644
--- a/pve-notify-worker/Cargo.toml
+++ b/pve-notify-worker/Cargo.toml
@@ -10,7 +10,7 @@ homepage.workspace = true
 [dependencies]
 anyhow.workspace = true
 futures.workspace = true
-tokio = { workspace = true, features = [ "full" ] }
+tokio = { workspace = true, features = [ "rt" ] }
 tracing.workspace = true
 
 common.workspace = true
diff --git a/pve-notify-worker/src/main.rs b/pve-notify-worker/src/main.rs
index 5f13b25..a6de5dd 100644
--- a/pve-notify-worker/src/main.rs
+++ b/pve-notify-worker/src/main.rs
@@ -29,7 +29,14 @@ fn main() -> Result<(), Error> {
         .journald()
         .init()?;
 
-    proxmox_async::runtime::main(run())
+    let runtime = proxmox_async::runtime::get_runtime_with_builder(|| {
+        let mut builder = tokio::runtime::Builder::new_current_thread();
+        builder.enable_all();
+
+        builder
+    });
+
+    runtime.block_on(run())
 }
 
 async fn run() -> Result<(), Error> {
-- 
2.47.3





             reply	other threads:[~2026-11-23  9:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  9:20 Lukas Wagner [this message]
2026-11-23 10:39 ` [PATCH proxmox-mail-forward] pve-notify-worker: use current-thread runtime Lukas Wagner
2026-11-23 10:54 ` superseded: " Lukas Wagner

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=20261123092004.120457-1-l.wagner@proxmox.com \
    --to=l.wagner@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal