all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox-mail-forward] pve-notify-worker: use current-thread runtime
@ 2026-11-23  9:20 Lukas Wagner
  2026-11-23 10:39 ` Lukas Wagner
  2026-11-23 10:54 ` superseded: " Lukas Wagner
  0 siblings, 2 replies; 3+ messages in thread
From: Lukas Wagner @ 2026-11-23  9:20 UTC (permalink / raw)
  To: pve-devel

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





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

* Re: [PATCH proxmox-mail-forward] pve-notify-worker: use current-thread runtime
  2026-11-23  9:20 [PATCH proxmox-mail-forward] pve-notify-worker: use current-thread runtime Lukas Wagner
@ 2026-11-23 10:39 ` Lukas Wagner
  2026-11-23 10:54 ` superseded: " Lukas Wagner
  1 sibling, 0 replies; 3+ messages in thread
From: Lukas Wagner @ 2026-11-23 10:39 UTC (permalink / raw)
  To: Lukas Wagner, pve-devel

On Mon Nov 23, 2026 at 10:20 AM CET, Lukas Wagner wrote:
> 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.

After some off-list dicussion with Max I've decided that I'll continue
to use the multi-threaded runtime, but with low cap on the number of
workers.

v2 incoming - sorry for the noise.

>
> 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> {






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

* superseded: [PATCH proxmox-mail-forward] pve-notify-worker: use current-thread runtime
  2026-11-23  9:20 [PATCH proxmox-mail-forward] pve-notify-worker: use current-thread runtime Lukas Wagner
  2026-11-23 10:39 ` Lukas Wagner
@ 2026-11-23 10:54 ` Lukas Wagner
  1 sibling, 0 replies; 3+ messages in thread
From: Lukas Wagner @ 2026-11-23 10:54 UTC (permalink / raw)
  To: Lukas Wagner, pve-devel

On Mon Nov 23, 2026 at 10:20 AM CET, Lukas Wagner wrote:
> 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.

superseded by:

https://lore.proxmox.com/all/20261123105236.212117-1-l.wagner@proxmox.com/T/#u




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

end of thread, other threads:[~2026-11-23 10:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23  9:20 [PATCH proxmox-mail-forward] pve-notify-worker: use current-thread runtime Lukas Wagner
2026-11-23 10:39 ` Lukas Wagner
2026-11-23 10:54 ` superseded: " Lukas Wagner

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