Reuse native checkpoints before source length changes

This commit is contained in:
gloamxun committed 2026-12-01 21:42:04 +08:00
1 parent 465a574124
commit 6acd82dbfa
8 files changed
+222 -4

No files matched your search

+24 -3
View File
@@ -366,8 +366,8 @@ impl EntryCheckpoint {
&& self.executor.sources[self.entry].name == earlier.executor.sources[earlier.entry].name
&& self.source_mouth(self.entry)
.same_loaded_prefix_constraint(earlier.source_mouth(earlier.entry))
&& (!self.executor.reads.observed_statistics()
|| (earlier.executor.reads.observed_statistics()
&& (self.can_resize_entry()
|| (!earlier.can_resize_entry()
&& self.executor.sources[self.entry].data.len()
== earlier.executor.sources[earlier.entry].data.len()))
}
@@ -380,7 +380,20 @@ impl EntryCheckpoint {
let entry = &self.executor.sources[self.entry];
// A suspended scanner may only accept unchanged bytes when its
// boundary cannot be authenticated as a physical line.
entry.name == name && (entry.data == data || self.matches_scanned_source(self.entry, data))
entry.name == name
&& (entry.data == data
|| ((entry.data.len() == data.len() || self.can_resize_entry())
&& self.source_mouth(self.entry).matches_loaded_prefix(data)))
}
fn can_resize_entry(&self) -> bool {
// At each retained shipout, the original entry is still the bottom
// source frame. Reject ambiguous accounting if it also opened as
// another source before this checkpoint.
!self.executor.reads.observed_statistics()
|| self.executor.sources.iter().filter(|source| {
source.name == self.executor.sources[self.entry].name
}).take(2).count() == 1
}
pub fn entry_frontier(&self) -> usize {
@@ -487,6 +500,14 @@ impl EntryCheckpoint {
}
let mut executor = self.executor.clone().with_cancellation(cancellation);
executor.line_break_cache = line_break_cache;
let previous_len = self.executor.sources[self.entry].data.len();
let current_len = source.data.len();
if previous_len != current_len
&& self.executor.reads.observed_statistics()
&& executor.resize_entry_statistics(previous_len, current_len, files.replayed_entry_bytes()).is_none()
{
return Ok(None);
}
executor.rebind_checkpoint_source(self.entry, source);
if let Some(nested) = nested {
executor.rebind_checkpoint_source(self.active_source, nested);