assistant: Refesh message headers only for dirty messages (#16881)
We've noticed performance issues in long conversations with assistants; the profiles pointed to slowiness in WrapMap (and indeed there were some low hanging fruits that we picked up in https://github.com/zed-industries/zed/pull/16761). That however did not fully resolve the issue, as WrapMap still cracked through in profiles; basically, the speedup I've landed has just moved the post elsewhere. The higher level issue is that we were trying to refresh message headers for all messages, irrespective of whether they've actually needed to be updated. This PR fixes that by using `replace_blocks` API where possible. Release Notes: - Improved performance of Assistant Panel with long conversations.
This commit is contained in:
parent
2c541aee24
commit
aaddb73b28
2 changed files with 211 additions and 164 deletions
|
@ -330,11 +330,22 @@ pub struct MessageCacheMetadata {
|
|||
pub struct MessageMetadata {
|
||||
pub role: Role,
|
||||
pub status: MessageStatus,
|
||||
timestamp: clock::Lamport,
|
||||
pub(crate) timestamp: clock::Lamport,
|
||||
#[serde(skip)]
|
||||
pub cache: Option<MessageCacheMetadata>,
|
||||
}
|
||||
|
||||
impl From<&Message> for MessageMetadata {
|
||||
fn from(message: &Message) -> Self {
|
||||
Self {
|
||||
role: message.role,
|
||||
status: message.status.clone(),
|
||||
timestamp: message.id.0,
|
||||
cache: message.cache.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MessageMetadata {
|
||||
pub fn is_cache_valid(&self, buffer: &BufferSnapshot, range: &Range<usize>) -> bool {
|
||||
let result = match &self.cache {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue