From a917a894bfb7ec2af949cba20b1fe08e78ddd02b Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 13 Jan 2025 11:58:49 +0100 Subject: [PATCH] Improve prompt caching for edit prediction (#23061) This is achieved by halving the number of events instead of popping the front. Release Notes: - N/A Co-authored-by: Thorsten --- crates/zeta/src/zeta.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/zeta/src/zeta.rs b/crates/zeta/src/zeta.rs index 546f6a254905eb2237dd94c964bfa369ce7977cc..9c794dc7fc6e90651964d3f88de5399c2c90623a 100644 --- a/crates/zeta/src/zeta.rs +++ b/crates/zeta/src/zeta.rs @@ -206,7 +206,7 @@ impl Zeta { } fn push_event(&mut self, event: Event) { - const MAX_EVENT_COUNT: usize = 20; + const MAX_EVENT_COUNT: usize = 16; if let Some(Event::BufferChange { new_snapshot: last_new_snapshot, @@ -232,8 +232,8 @@ impl Zeta { } self.events.push_back(event); - if self.events.len() > MAX_EVENT_COUNT { - self.events.pop_front(); + if self.events.len() >= MAX_EVENT_COUNT { + self.events.drain(..MAX_EVENT_COUNT / 2); } }