From 3ae0543fddd79ed215f9c1f57e2096ea66486c61 Mon Sep 17 00:00:00 2001 From: "Adam Perry @ OpenAI" Date: Fri, 26 Jun 2026 18:07:41 -0700 Subject: [PATCH] core: overlap diff root discovery with world state (#30286) ## Why Remote diff-root discovery is independent of world-state construction, but it ran afterward and added filesystem metadata latency before the first model request. Overlap the independent work so thread-cold turns do not pay those waits serially. ## What - Run `record_context_updates_and_set_reference_context_item` and `turn_diff_display_roots` with `tokio::join!`. - Reuse the same resolved display roots when constructing `TurnDiffTracker`; no cache or behavior lifecycle changes are introduced. ## Validation A synthetic executor-skill benchmark with artificial network delay: thread-cold model-request p50 improved from about 1.79 s to 1.58 s. --- codex-rs/core/src/session/turn.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/codex-rs/core/src/session/turn.rs b/codex-rs/core/src/session/turn.rs index 7b509ae42..2e948b9c1 100644 --- a/codex-rs/core/src/session/turn.rs +++ b/codex-rs/core/src/session/turn.rs @@ -167,9 +167,10 @@ pub(crate) async fn run_turn( // run_turn owns the step used to seed context and make the first sampling request. let first_step_context = sess.capture_step_context(Arc::clone(&turn_context)).await; // Keep the exact model-visible state used by this turn and its inline compactions. - let mut world_state = sess - .record_context_updates_and_set_reference_context_item(first_step_context.as_ref()) - .await; + let (mut world_state, display_roots) = tokio::join!( + sess.record_context_updates_and_set_reference_context_item(first_step_context.as_ref()), + turn_diff_display_roots(turn_context.as_ref()), + ); let Some((injection_items, explicitly_enabled_connectors)) = build_skills_and_plugins( &sess, @@ -209,7 +210,6 @@ pub(crate) async fn run_turn( let mut stop_hook_active = false; // Although from the perspective of codex.rs, TurnDiffTracker has the lifecycle of a Task which contains // many turns, from the perspective of the user, it is a single turn. - let display_roots = turn_diff_display_roots(turn_context.as_ref()).await; let turn_diff_tracker = Arc::new(tokio::sync::Mutex::new( TurnDiffTracker::with_environment_display_roots(display_roots), ));