Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
ep: Fix e2e_latency tracking (#51852)
Oleksiy Syvokon7cf7dcac5133
diff --git a/crates/edit_prediction/src/edit_prediction.rs b/crates/edit_prediction/src/edit_prediction.rsindex b8a631955ec..da2392d7576 100644--- a/crates/edit_prediction/src/edit_prediction.rs+++ b/crates/edit_prediction/src/edit_prediction.rs@@ -2151,11 +2151,12 @@ impl EditPredictionStore {let project_state = this.get_or_init_project(&project, cx);let throttle = *select_throttle(project_state, request_trigger);+ let now = cx.background_executor().now();throttle.and_then(|(last_entity, last_timestamp)| {if throttle_entity != last_entity {return None;}- (last_timestamp + throttle_timeout).checked_duration_since(Instant::now())+ (last_timestamp + throttle_timeout).checked_duration_since(now)})}).ok()@@ -2183,7 +2184,7 @@ impl EditPredictionStore {return;}- let new_refresh = (throttle_entity, Instant::now());+ let new_refresh = (throttle_entity, cx.background_executor().now());*select_throttle(project_state, request_trigger) = Some(new_refresh);is_cancelled = false;})diff --git a/crates/edit_prediction/src/edit_prediction_tests.rs b/crates/edit_prediction/src/edit_prediction_tests.rsindex 5daa7ee4a0d..257dd255cbb 100644--- a/crates/edit_prediction/src/edit_prediction_tests.rs+++ b/crates/edit_prediction/src/edit_prediction_tests.rs@@ -1807,7 +1807,9 @@ async fn test_cancel_second_on_third_request(cx: &mut TestAppContext) {reason: EditPredictionRejectReason::Replaced,was_shown: false,model_version: None,- e2e_latency_ms: Some(0),+ // 2 throttle waits (for 2nd and 3rd requests) elapsed+ // between this request's start and response.+ e2e_latency_ms: Some(2 * EditPredictionStore::THROTTLE_TIMEOUT.as_millis()),}]);diff --git a/crates/edit_prediction/src/zeta.rs b/crates/edit_prediction/src/zeta.rsindex e7d38df5c8e..fdfe3ebcf06 100644--- a/crates/edit_prediction/src/zeta.rs+++ b/crates/edit_prediction/src/zeta.rs@@ -365,10 +365,10 @@ pub fn request_prediction_with_zeta(});cx.spawn(async move |this, cx| {- let request_duration = cx.background_executor().now() - request_start;let Some((id, prediction)) = handle_api_response(&this, request_task.await, cx)? else {return Ok(None);};+ let request_duration = cx.background_executor().now() - request_start;let Some(Prediction {prompt_input: inputs,