Skip to content

Commit 3ae0543

Browse files
authored
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.
1 parent d4ec08b commit 3ae0543

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

codex-rs/core/src/session/turn.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ pub(crate) async fn run_turn(
167167
// run_turn owns the step used to seed context and make the first sampling request.
168168
let first_step_context = sess.capture_step_context(Arc::clone(&turn_context)).await;
169169
// Keep the exact model-visible state used by this turn and its inline compactions.
170-
let mut world_state = sess
171-
.record_context_updates_and_set_reference_context_item(first_step_context.as_ref())
172-
.await;
170+
let (mut world_state, display_roots) = tokio::join!(
171+
sess.record_context_updates_and_set_reference_context_item(first_step_context.as_ref()),
172+
turn_diff_display_roots(turn_context.as_ref()),
173+
);
173174

174175
let Some((injection_items, explicitly_enabled_connectors)) = build_skills_and_plugins(
175176
&sess,
@@ -209,7 +210,6 @@ pub(crate) async fn run_turn(
209210
let mut stop_hook_active = false;
210211
// Although from the perspective of codex.rs, TurnDiffTracker has the lifecycle of a Task which contains
211212
// many turns, from the perspective of the user, it is a single turn.
212-
let display_roots = turn_diff_display_roots(turn_context.as_ref()).await;
213213
let turn_diff_tracker = Arc::new(tokio::sync::Mutex::new(
214214
TurnDiffTracker::with_environment_display_roots(display_roots),
215215
));

0 commit comments

Comments
 (0)