Move the advanced child executor into the live job
This commit is contained in:
1 parent
d98d7b44c1
commit
f6f447dd59
4 files changed
+27
-31
No files matched your search
@@ -331,8 +331,8 @@ pub struct CheckpointSource<'a> {
|
|||||||
/// validated and replayed the previous suffix into this revision's draft.
|
/// validated and replayed the previous suffix into this revision's draft.
|
||||||
pub enum CheckpointDecision {
|
pub enum CheckpointDecision {
|
||||||
Continue,
|
Continue,
|
||||||
/// Move to a validated later command boundary in the same input.
|
/// Move to a validated later command boundary and select captures there.
|
||||||
Advance(Arc<EntryCheckpoint>),
|
Advance(Box<EntryCheckpoint>),
|
||||||
Reuse(Box<Execution>),
|
Reuse(Box<Execution>),
|
||||||
ReplayFailed(String),
|
ReplayFailed(String),
|
||||||
}
|
}
|
||||||
@@ -557,13 +557,16 @@ impl EntryCheckpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Executor {
|
impl Executor {
|
||||||
fn rebind_checkpoint_source(&mut self, id: usize, file: SourceFile) {
|
fn source_mouth_mut(&mut self, id: usize) -> &mut Mouth {
|
||||||
let mouth = self.inputs.iter_mut().rev().find_map(|frame| match frame {
|
self.inputs.iter_mut().rev().find_map(|frame| match frame {
|
||||||
InputFrame::Source { source, mouth, .. } if *source == id => Some(mouth),
|
InputFrame::Source { source, mouth, .. } if *source == id => Some(mouth),
|
||||||
_ => None,
|
_ => None,
|
||||||
}).expect("checkpoint retains the active scanner");
|
}).expect("checkpoint retains the source scanner")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rebind_checkpoint_source(&mut self, id: usize, file: SourceFile) {
|
||||||
if self.sources[id].as_ref() != &file {
|
if self.sources[id].as_ref() != &file {
|
||||||
mouth.rebind_loaded_prefix(file.data.clone());
|
self.source_mouth_mut(id).rebind_loaded_prefix(file.data.clone());
|
||||||
self.sources[id] = Arc::new(file);
|
self.sources[id] = Arc::new(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3976,7 +3979,7 @@ impl Executor {
|
|||||||
mut select: impl FnMut(CheckpointSource<'_>, usize) -> Option<S>,
|
mut select: impl FnMut(CheckpointSource<'_>, usize) -> Option<S>,
|
||||||
mut capture: impl FnMut(S, EntryCheckpoint, &mut F) -> CheckpointDecision,
|
mut capture: impl FnMut(S, EntryCheckpoint, &mut F) -> CheckpointDecision,
|
||||||
) -> impl FnMut(&mut Self, usize, bool, &mut F) -> CheckpointDecision {
|
) -> impl FnMut(&mut Self, usize, bool, &mut F) -> CheckpointDecision {
|
||||||
move |engine, initial_depth, pages_processed, files| {
|
move |engine, initial_depth, pages_processed, files| loop {
|
||||||
if engine.job_ended {
|
if engine.job_ended {
|
||||||
return CheckpointDecision::Continue;
|
return CheckpointDecision::Continue;
|
||||||
}
|
}
|
||||||
@@ -4031,14 +4034,13 @@ impl Executor {
|
|||||||
};
|
};
|
||||||
match capture(slot, checkpoint, files) {
|
match capture(slot, checkpoint, files) {
|
||||||
CheckpointDecision::Advance(checkpoint) => {
|
CheckpointDecision::Advance(checkpoint) => {
|
||||||
let cancellation = engine.cancellation.take();
|
debug_assert!(checkpoint.completed_steps() > engine.steps);
|
||||||
let line_break_cache = engine.line_break_cache.take();
|
let mut advanced = checkpoint.executor;
|
||||||
*engine = checkpoint.executor.clone();
|
advanced.cancellation = engine.cancellation.take();
|
||||||
engine.cancellation = cancellation;
|
advanced.line_break_cache = engine.line_break_cache.take();
|
||||||
engine.line_break_cache = line_break_cache;
|
*engine = advanced;
|
||||||
CheckpointDecision::Continue
|
|
||||||
}
|
}
|
||||||
decision => decision,
|
decision => return decision,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,8 @@ impl EntryCheckpoint {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut executor = later.executor.clone();
|
let mut executor = later.executor.clone();
|
||||||
executor.rebind_checkpoint_source(child, (**source).clone());
|
executor.source_mouth_mut(child).share_loaded_source(self.source_mouth(child));
|
||||||
|
executor.sources[child] = Arc::clone(source);
|
||||||
executor.deferred_accounting = Some(Arc::new(DeferredAccounting {
|
executor.deferred_accounting = Some(Arc::new(DeferredAccounting {
|
||||||
current: Arc::clone(self),
|
current: Arc::clone(self),
|
||||||
basis,
|
basis,
|
||||||
|
|||||||
@@ -350,6 +350,11 @@ impl Mouth {
|
|||||||
debug_assert!(self.matches_loaded_prefix(&data));
|
debug_assert!(self.matches_loaded_prefix(&data));
|
||||||
self.data = Arc::new(data);
|
self.data = Arc::new(data);
|
||||||
}
|
}
|
||||||
|
pub(super) fn share_loaded_source(&mut self, current: &Self) {
|
||||||
|
debug_assert!(self.matches_loaded_prefix(¤t.data));
|
||||||
|
self.data = Arc::clone(¤t.data);
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn payload_bytes(&self) -> usize {
|
pub(super) fn payload_bytes(&self) -> usize {
|
||||||
self.data.len()
|
self.data.len()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -687,10 +687,9 @@ impl PublishedCheckpoints {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CheckpointSet {
|
impl CheckpointSet {
|
||||||
fn advance_child(&self, current: &CachedCheckpoint) -> Option<(EntryCheckpoint, Option<Capture>)> {
|
fn advance_child(&self, current: &CachedCheckpoint) -> Option<EntryCheckpoint> {
|
||||||
let boundary = current.child_boundary.as_ref()?;
|
let boundary = current.child_boundary.as_ref()?;
|
||||||
let child = current.guard.nested_source.as_ref()?;
|
let child = current.guard.nested_source.as_ref()?;
|
||||||
let Capture::Nested { file, interval: 0 } = current.slots else { return None; };
|
|
||||||
let previous = self.entries.iter().find(|candidate| {
|
let previous = self.entries.iter().find(|candidate| {
|
||||||
matches!(candidate.slots, Capture::Nested { interval: 0, .. })
|
matches!(candidate.slots, Capture::Nested { interval: 0, .. })
|
||||||
&& candidate.entry.frontier() == current.entry.frontier()
|
&& candidate.entry.frontier() == current.entry.frontier()
|
||||||
@@ -707,14 +706,7 @@ impl CheckpointSet {
|
|||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let advanced = current.entry.advance_within_child(&previous.entry, &later.entry)?;
|
current.entry.advance_within_child(&previous.entry, &later.entry)
|
||||||
let bytes = usize::try_from(child.observed_size?).ok()?;
|
|
||||||
// A valid advance can land before the new midpoint. Leave the
|
|
||||||
// later slot available so the current run can capture it there.
|
|
||||||
let retain = (advanced.frontier() > bytes.div_ceil(NESTED_INTERVALS)
|
|
||||||
&& advanced.frontier() < bytes)
|
|
||||||
.then_some(Capture::Nested { file, interval: 1 });
|
|
||||||
Some((advanced, retain))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -937,16 +929,12 @@ impl SelectedCheckpoint {
|
|||||||
if allow_suffix && let Capture::Nested { file, interval: 0 } = slots
|
if allow_suffix && let Capture::Nested { file, interval: 0 } = slots
|
||||||
&& let Some(current) = captures.nested[file][0].as_ref()
|
&& let Some(current) = captures.nested[file][0].as_ref()
|
||||||
&& Arc::ptr_eq(¤t.entry, &entry)
|
&& Arc::ptr_eq(¤t.entry, &entry)
|
||||||
&& let Some((advanced, slots)) = self.set.advance_child(current)
|
&& let Some(advanced) = self.set.advance_child(current)
|
||||||
{
|
{
|
||||||
let advanced = Arc::new(advanced);
|
|
||||||
let reused = advanced.completed_steps() - entry.completed_steps();
|
let reused = advanced.completed_steps() - entry.completed_steps();
|
||||||
if let Some(slots) = slots {
|
|
||||||
captures.capture(slots, advanced.clone(), host);
|
|
||||||
}
|
|
||||||
work.reused_steps += reused;
|
work.reused_steps += reused;
|
||||||
work.reused_suffix_steps += reused;
|
work.reused_suffix_steps += reused;
|
||||||
return CheckpointDecision::Advance(advanced);
|
return CheckpointDecision::Advance(Box::new(advanced));
|
||||||
}
|
}
|
||||||
let Capture::Settled { page, .. } = slots else {
|
let Capture::Settled { page, .. } = slots else {
|
||||||
return CheckpointDecision::Continue;
|
return CheckpointDecision::Continue;
|
||||||
|
|||||||
Reference in new issue
Block a user