Skip to content

app-server: prepare to run initialized rpcs concurrently#17372

Merged
euroelessar merged 2 commits intomainfrom
codex/concurrent-rpcs-initialized-rpcs
Apr 14, 2026
Merged

app-server: prepare to run initialized rpcs concurrently#17372
euroelessar merged 2 commits intomainfrom
codex/concurrent-rpcs-initialized-rpcs

Conversation

@euroelessar
Copy link
Copy Markdown
Collaborator

@euroelessar euroelessar commented Apr 10, 2026

Summary

  • Refactors MessageProcessor and per-connection session state so initialized service RPC handling can be moved into spawned tasks in a follow-up PR.
  • Shares the processor and initialized session data with Arc/OnceLock instead of mutable borrowed connection state.
  • Keeps initialized request handling synchronous in this PR; it does not call tokio::spawn for service RPCs yet.

Testing

@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-initialized-rpcs branch from 2435f00 to 8514a9b Compare April 10, 2026 21:55
@euroelessar euroelessar changed the title app-server: run initialized rpcs concurrently app-server: prepare initialized rpcs for concurrent dispatch Apr 10, 2026
@euroelessar euroelessar changed the title app-server: prepare initialized rpcs for concurrent dispatch app-server: prepare to run initialized rpcs concurrently Apr 10, 2026
@euroelessar euroelessar marked this pull request as ready for review April 10, 2026 22:38
@euroelessar euroelessar requested a review from owenlin0 April 10, 2026 22:38
Base automatically changed from codex/concurrent-rpcs-regression-test to main April 10, 2026 23:46
@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-initialized-rpcs branch from 8514a9b to 5c883c1 Compare April 10, 2026 23:49
Comment thread codex-rs/app-server/src/message_processor.rs
Arc::clone(&connection_state.session),
)
.await;
let opted_out_notification_methods_snapshot = connection_state
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.

Is it still necessary now that the session state is immutable after init?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

it's a bit bigger change to change this (e.g. I would need to remove ConnectionState, plumb the Arc<ConnectionSessionState> throughout the stack, etc)
ok if I do it in a followup?

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.

Yes but please really do it as a follow-up :D

return;
}

let app_server_client_name = session.app_server_client_name().map(str::to_string);
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.

ultra nit: I would defer this clone till the code actually detaches work


pub(crate) async fn process_request(
&self,
self: &Arc<Self>,
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.

This Arc receiver leaks the future concurrency implementation detail into every caller, this is strange. I would keep an &self and Arc it only at the spawn site

Copy link
Copy Markdown
Collaborator Author

@euroelessar euroelessar Apr 13, 2026

Choose a reason for hiding this comment

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

I can't promote &self into Arc<Self> without storing weak pointer on itself or similar as a field, but that would be even more strange?
alternatively we can move all the fields into a new MessageProcessorState or similar, but that does't provide clean benefits

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.

Ideally we have MessageProcessor as cheap cloneable handle we hide an Arced inner in it

But can be done in the same follow-up

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

sounds good, will add inner in the followup then

@euroelessar euroelessar force-pushed the codex/concurrent-rpcs-initialized-rpcs branch from 551d1b7 to 7e5a28b Compare April 13, 2026 18:26
@bolinfest bolinfest self-requested a review April 13, 2026 21:54
Arc::clone(&connection_state.session),
)
.await;
let opted_out_notification_methods_snapshot = connection_state
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.

Yes but please really do it as a follow-up :D


pub(crate) async fn process_request(
&self,
self: &Arc<Self>,
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.

Ideally we have MessageProcessor as cheap cloneable handle we hide an Arced inner in it

But can be done in the same follow-up

@euroelessar euroelessar merged commit 23d4098 into main Apr 14, 2026
32 of 38 checks passed
@euroelessar euroelessar deleted the codex/concurrent-rpcs-initialized-rpcs branch April 14, 2026 18:24
@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants