Skip to content

refactor(core): Removed Arc from sigs where not required#650

Open
alexsnaps wants to merge 1 commit into
praxis-proxy:mainfrom
alexsnaps:cleanups2
Open

refactor(core): Removed Arc from sigs where not required#650
alexsnaps wants to merge 1 commit into
praxis-proxy:mainfrom
alexsnaps:cleanups2

Conversation

@alexsnaps

Copy link
Copy Markdown
Member

Same as #649, but with up to date main 🤦

The deconstructing of ServerState isn't a huge deal, the incs and decs on the Arc were possibly even DCE'ed at compile time. I have not verified, but I don't think that perf gain there would be of much value. But what it does seem to show is that health_registry (currently?) isn't a "real natural fit" for the ServerState struct.

Should we drop it? Or will we need it eventually?

Signed-off-by: Alex Snaps <alex@wcgw.dev>
@alexsnaps alexsnaps requested a review from a team June 22, 2026 15:31
@alexsnaps alexsnaps requested review from shaneutt and twghu as code owners June 22, 2026 15:31
@alexsnaps

Copy link
Copy Markdown
Member Author

We can get rid of the deconstruct btw:

diff --git a/server/src/server.rs b/server/src/server.rs
index e35e8c0..efad9cf 100644
--- a/server/src/server.rs
+++ b/server/src/server.rs
@@ -180,22 +180,15 @@ fn spawn_watcher(
     state: ServerState,
 ) -> Option<std::thread::JoinHandle<()>> {
     let path = config_path?;
-    let ServerState {
-        pipelines,
-        health_registry: _,
-        kv_stores,
-        health_shutdown,
-        response_stores,
-    } = state;
     let handle = crate::watcher::spawn_config_watcher(crate::watcher::WatcherParams {
         config_path: path,
-        health_shutdown,
+        health_shutdown: state.health_shutdown,
         initial_config: config,
-        kv_stores,
-        pipelines,
+        kv_stores: state.kv_stores,
+        pipelines: state.pipelines,
         registry: Arc::new(registry),
         #[cfg(feature = "ai-inference")]
-        response_stores,
+        response_stores: state.response_stores,
         shutdown: CancellationToken::new(),
     });
     Some(handle)

I put it in to highlight the health_registry: _

Comment thread server/src/server.rs
let path = config_path?;
let ServerState {
pipelines,
health_registry: _,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, yeah as per my comment, I'd just inline the moves in the WatcherParams construction below.
But, do we want to keep health_registry as a field here?

@praxis-bot praxis-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review

Summary: Removes unnecessary Arc::clone calls in register_protocols and spawn_watcher by destructuring ServerState and narrowing the pipelines parameter type.

Overall: The intent is sound -- eliminating redundant Arc ref-count bumps. However, the destructuring introduces a conditional-compilation bug and drops the health_registry silently.

Severity Count
Critical 1
Medium 1

Comment thread server/src/server.rs
health_registry: _,
kv_stores,
health_shutdown,
response_stores,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] response_stores is destructured unconditionally, but the ServerState field is behind #[cfg(feature = "ai-inference")] (line 111-112). This will fail to compile with --no-default-features. The original code avoided this because state.response_stores was only accessed inside the #[cfg]-gated field initializer on line 198.

Add the cfg gate to the destructuring:

let ServerState {
    pipelines,
    health_registry: _,
    kv_stores,
    health_shutdown,
    #[cfg(feature = "ai-inference")]
    response_stores,
} = state;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will not keep the explicit destructure... See description

Comment thread server/src/server.rs
let path = config_path?;
let ServerState {
pipelines,
health_registry: _,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Medium] health_registry: _ silently drops the registry. The PR description asks whether health_registry should be removed from ServerState -- but since run_server_with_registry still reads state.health_registry on line 87 (for register_admin_endpoints) and line 86 won't compile if the field is removed, it must stay. The silent drop here is fine for now, but consider adding a short // consumed by register_admin_endpoints before this point comment to explain why it's discarded, since the PR description itself flags uncertainty about this field's purpose.

@shaneutt shaneutt self-assigned this Jun 22, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in AI Gateway Jun 22, 2026
@shaneutt shaneutt moved this from Backlog to Review in AI Gateway Jun 22, 2026
@shaneutt shaneutt added this to the v0.4.0 milestone Jun 22, 2026
@shaneutt shaneutt requested a review from nerdalert June 22, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Review

Development

Successfully merging this pull request may close these issues.

3 participants