mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Share resumed rollout history (#28426)
## Summary Resuming a persisted thread currently deep-clones its complete rollout history several times. `InitialHistory` is retained for the app-server response, copied into thread persistence, and copied again by read-only accessors. These copies scale with the complete rollout rather than the bounded model context and add measurable latency for large sessions. This change stores resumed rollout history in `Arc<Vec<RolloutItem>>`. Rollout loading wraps the parsed vector once, while app-server response construction, session initialization, and thread persistence share it through inexpensive `Arc` clones. Read-only history access now returns a borrowed slice, and fork paths use `Arc::unwrap_or_clone` where they genuinely need mutable ownership. Rollout reconstruction also consumes its temporary context instead of cloning the reconstructed model history. The serialized representation remains unchanged. In an artificial 123 MB rollout benchmark, sharing resumed history reduced cold resume latency by roughly 9–10%. The affected crates compile with their test targets, all 80 thread-store tests pass, and the Bazel dependency lock remains valid.
This commit is contained in:
1 parent
4147824509
commit
330ae6a516
17 files changed
+102
-85
No files matched your search
@@ -100,12 +100,13 @@ impl LiveThread {
|
||||
|
||||
pub async fn resume(
|
||||
thread_store: Arc<dyn ThreadStore>,
|
||||
mut params: ResumeThreadParams,
|
||||
params: ResumeThreadParams,
|
||||
) -> ThreadStoreResult<Self> {
|
||||
let thread_id = params.thread_id;
|
||||
let should_load_history = params.history.is_none();
|
||||
let include_archived = params.include_archived;
|
||||
thread_store.resume_thread(params.clone()).await?;
|
||||
let mut metadata_sync = ThreadMetadataSync::for_resume(¶ms);
|
||||
thread_store.resume_thread(params).await?;
|
||||
if should_load_history {
|
||||
match thread_store
|
||||
.load_history(LoadThreadHistoryParams {
|
||||
@@ -114,7 +115,7 @@ impl LiveThread {
|
||||
})
|
||||
.await
|
||||
{
|
||||
Ok(history) => params.history = Some(history.items),
|
||||
Ok(history) => metadata_sync.record_resume_history(&history.items),
|
||||
Err(err) => {
|
||||
if let Err(discard_err) = thread_store.discard_thread(thread_id).await {
|
||||
warn!(
|
||||
@@ -125,7 +126,6 @@ impl LiveThread {
|
||||
}
|
||||
}
|
||||
}
|
||||
let metadata_sync = ThreadMetadataSync::for_resume(¶ms);
|
||||
Ok(Self {
|
||||
thread_id,
|
||||
thread_store,
|
||||
|
||||
Reference in new issue
Block a user