Promote edit-only entry checkpoints to proven line ends
This commit is contained in:
1 parent
e05ad41a66
commit
8f4ad600ef
1 file changed
+37
-9
@@ -126,7 +126,7 @@ struct CaptureSchedule {
|
||||
next_page: usize,
|
||||
fixed_frontier: Option<usize>,
|
||||
pending_edit_frontier: Option<usize>,
|
||||
pending_line_end: Option<(usize, usize, usize)>,
|
||||
pending_line_end: Option<(usize, CaptureSlots, usize)>,
|
||||
settled_page: usize,
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ const NESTED_INTERVALS: usize = 2;
|
||||
#[derive(Clone, Copy)]
|
||||
enum Capture {
|
||||
Entry(CaptureSlots),
|
||||
LineEnd { interval: usize },
|
||||
LineEnd { slots: CaptureSlots },
|
||||
Nested { file: usize, interval: usize },
|
||||
Settled { page: usize, regular: Option<CaptureSlots> },
|
||||
}
|
||||
@@ -205,16 +205,16 @@ impl CaptureSchedule {
|
||||
let regular = self.select(source.frontier, pages);
|
||||
let mut line_end = None;
|
||||
if self.fixed_frontier.is_none() {
|
||||
if let Some(slots) = regular.filter(|slots| slots.early) {
|
||||
if let Some(slots) = regular.filter(|slots| slots.early || slots.edit) {
|
||||
self.pending_line_end = (!source.line_consumed)
|
||||
.then_some((source.frontier, slots.interval, pages));
|
||||
} else if let Some((frontier, interval, before_pages)) = self.pending_line_end {
|
||||
.then_some((source.frontier, slots, pages));
|
||||
} else if let Some((frontier, slots, before_pages)) = self.pending_line_end {
|
||||
if frontier != source.frontier {
|
||||
self.pending_line_end = None;
|
||||
} else if source.line_consumed {
|
||||
self.pending_line_end = None;
|
||||
if pages == before_pages {
|
||||
line_end = Some(Capture::LineEnd { interval });
|
||||
line_end = Some(Capture::LineEnd { slots });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,8 +374,9 @@ impl<'a> CapturedEntries<'a> {
|
||||
let Some(regular) = regular else { return; };
|
||||
Capture::Entry(regular)
|
||||
}
|
||||
Capture::LineEnd { interval } => {
|
||||
let Some(earlier) = &self.early[interval] else { return; };
|
||||
Capture::LineEnd { slots } => {
|
||||
let earlier = if slots.edit { &self.edit } else { &self.early[slots.interval] };
|
||||
let Some(earlier) = earlier else { return; };
|
||||
// With the same host prefix, finishing an already loaded
|
||||
// line narrows no resource dependency or replay opportunity.
|
||||
if !host.prefix().is_some_and(|(_, calls)| calls.len() == earlier.replay_count)
|
||||
@@ -383,7 +384,6 @@ impl<'a> CapturedEntries<'a> {
|
||||
{
|
||||
return;
|
||||
}
|
||||
let Capture::Entry(slots) = earlier.slots else { unreachable!() };
|
||||
Capture::Entry(CaptureSlots { page: false, ..slots })
|
||||
}
|
||||
other => other,
|
||||
@@ -2434,6 +2434,34 @@ fn immutable_file_creation_and_removal_replay_real_lookup_results() {
|
||||
assert_eq!(pdfs.values().collect::<BTreeSet<_>>().len(), 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn edit_only_entry_checkpoint_advances_to_its_line_end() {
|
||||
let mut schedule = CaptureSchedule::new(400, None, Some(290));
|
||||
let source = |frontier, line_consumed| CheckpointSource {
|
||||
id: 0,
|
||||
name: "main.tex",
|
||||
bytes: 400,
|
||||
frontier,
|
||||
is_entry: true,
|
||||
line_consumed,
|
||||
output_returned: true,
|
||||
};
|
||||
assert!(matches!(
|
||||
schedule.select_source(source(215, true), 0),
|
||||
Some(Capture::Entry(CaptureSlots { early: true, .. }))
|
||||
));
|
||||
assert!(matches!(
|
||||
schedule.select_source(source(290, false), 0),
|
||||
Some(Capture::Entry(CaptureSlots { early: false, edit: true, .. }))
|
||||
));
|
||||
assert!(schedule.select_source(source(290, false), 0).is_none());
|
||||
assert!(matches!(
|
||||
schedule.select_source(source(290, true), 0),
|
||||
Some(Capture::LineEnd { slots: CaptureSlots { early: false, edit: true, .. } })
|
||||
));
|
||||
assert!(schedule.select_source(source(290, true), 0).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn automatic_checkpoints_refresh_the_previous_edit_line_after_a_child_edit() {
|
||||
let mut schedule = CaptureSchedule::new(400, None, Some(290));
|
||||
|
||||
Reference in new issue
Block a user