From c23a8eaa891a1b16ec0b59074147400b6fcabb21 Mon Sep 17 00:00:00 2001 From: Federico Carrone Date: Tue, 17 Nov 2026 19:12:21 -0300 Subject: [PATCH] perf(macros): #[inline] the generated immediate dispatch After the module split (#278) the compiler stopped inlining __spawned_handle_immediate into SendEnvelope::handle, adding 22 instructions per send: +3.6% over v0.8.0 on async_ct_send_p1/p2, which the cumulative perf budget against the release would fail. With the hint, handler body and reply() inline again and every gated async benchmark is below v0.8.0. --- CHANGELOG.md | 6 ++++++ macros/src/actor.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index baacb052c..2facc4fbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ out of the JVM's default heap. Client-compat now warns, in the job summary, when a client's graph holds a second spawned version. The PR template asks for an independent review of concurrency changes and trace-validated models. +- `#[actor]` marks the generated await-free dispatch + (`__spawned_handle_immediate`) `#[inline]`. Since the module split (#278) + the compiler had stopped inlining it into the envelope, adding 22 + instructions per `send` (+3.6% over 0.8.0 on `async_ct_send_*`, +0.4% to + +1.2% on the async request benchmarks). With the hint every gated async + benchmark is below 0.8.0 (send -3.4%, requests -0.6% to -0.9%). - Fix the flaky `supervision::transient_startup_timeout_retries_after_actual_cleanup` (a 20 ms startup deadline raced the fast starts on a loaded host, which also made cargo-mutants report surviving mutants as caught): the replacement's diff --git a/macros/src/actor.rs b/macros/src/actor.rs index 218191c8f..dd7aac5e1 100644 --- a/macros/src/actor.rs +++ b/macros/src/actor.rs @@ -632,6 +632,12 @@ pub(crate) fn expand(attr: TokenStream, item: TokenStream) -> TokenStream { let _ = #reply_name.reply(self.#method_name(#msg_name, #ctx_name).await); } + // Inlined into the envelope's dispatch with the + // handler body and reply(); left to the heuristics, + // whether that happens depends on how the crate is + // split into modules (+3.6% instructions per send + // after #278). + #[inline] fn __spawned_handle_immediate<#turn_lifetime>( &mut self, #msg_name: #msg_ty,