Advance replay checkpoints through completed entry lines
This commit is contained in:
1 parent
d249ec7eba
commit
51db480b34
5 files changed
+175
-14
No files matched your search
@@ -96,6 +96,7 @@ struct CaptureSchedule {
|
||||
next_page: usize,
|
||||
fixed_frontier: Option<usize>,
|
||||
pending_edit_frontier: Option<usize>,
|
||||
pending_line_end: Option<(usize, usize, usize)>,
|
||||
settled_page: usize,
|
||||
}
|
||||
|
||||
@@ -114,6 +115,7 @@ const NESTED_INTERVALS: usize = 2;
|
||||
#[derive(Clone, Copy)]
|
||||
enum Capture {
|
||||
Entry(CaptureSlots),
|
||||
LineEnd { interval: usize },
|
||||
Nested { file: usize, interval: usize },
|
||||
Settled { page: usize, regular: Option<CaptureSlots> },
|
||||
}
|
||||
@@ -164,19 +166,36 @@ impl CaptureSchedule {
|
||||
next_page: 1,
|
||||
fixed_frontier,
|
||||
pending_edit_frontier: edit_frontier,
|
||||
pending_line_end: None,
|
||||
settled_page: 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn select_source(&mut self, source: CheckpointSource<'_>, pages: usize) -> Option<Capture> {
|
||||
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) {
|
||||
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 {
|
||||
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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if self.fixed_frontier.is_none() && source.output_returned
|
||||
&& pages > self.settled_page && pages <= 8
|
||||
{
|
||||
self.settled_page = pages;
|
||||
return Some(Capture::Settled { page: pages, regular });
|
||||
}
|
||||
regular.map(Capture::Entry)
|
||||
regular.map(Capture::Entry).or(line_end)
|
||||
}
|
||||
|
||||
fn take_edit_frontier(&mut self, frontier: usize, ordinary_capture: bool) -> bool {
|
||||
@@ -286,7 +305,9 @@ impl<'a> CapturedEntries<'a> {
|
||||
fn retain(&mut self, slots: Capture, checkpoint: Arc<CachedCheckpoint>) {
|
||||
let slots = match slots {
|
||||
Capture::Entry(slots) => slots,
|
||||
Capture::Settled { .. } => unreachable!("settled observation is handled before retention"),
|
||||
Capture::LineEnd { .. } | Capture::Settled { .. } => {
|
||||
unreachable!("observation is handled before retention")
|
||||
}
|
||||
Capture::Nested { file, interval } => {
|
||||
self.nested[file][interval] = Some(checkpoint);
|
||||
return;
|
||||
@@ -304,19 +325,32 @@ impl<'a> CapturedEntries<'a> {
|
||||
}
|
||||
|
||||
fn capture(&mut self, slots: Capture, entry: Arc<EntryCheckpoint>, host: &RecordingHost) {
|
||||
let slots = if let Capture::Settled { page, regular } = slots {
|
||||
if let Some((_, calls)) = host.prefix() {
|
||||
self.settled.insert(page, SettledCheckpoint {
|
||||
entry: entry.clone(),
|
||||
host: host.files().replay_boundary(),
|
||||
call_count: calls.len(),
|
||||
});
|
||||
self.changed = true;
|
||||
let slots = match slots {
|
||||
Capture::Settled { page, regular } => {
|
||||
if let Some((_, calls)) = host.prefix() {
|
||||
self.settled.insert(page, SettledCheckpoint {
|
||||
entry: entry.clone(),
|
||||
host: host.files().replay_boundary(),
|
||||
call_count: calls.len(),
|
||||
});
|
||||
self.changed = true;
|
||||
}
|
||||
let Some(regular) = regular else { return; };
|
||||
Capture::Entry(regular)
|
||||
}
|
||||
let Some(regular) = regular else { return; };
|
||||
Capture::Entry(regular)
|
||||
} else {
|
||||
slots
|
||||
Capture::LineEnd { interval } => {
|
||||
let Some(earlier) = &self.early[interval] 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)
|
||||
|| !entry.can_advance_entry_anchor(&earlier.entry)
|
||||
{
|
||||
return;
|
||||
}
|
||||
let Capture::Entry(slots) = earlier.slots else { unreachable!() };
|
||||
Capture::Entry(CaptureSlots { page: false, ..slots })
|
||||
}
|
||||
other => other,
|
||||
};
|
||||
let (Some((trace, calls)), Some(path), Some(initial)) = (
|
||||
host.prefix(),
|
||||
|
||||
Reference in new issue
Block a user