Defer child replay accounting and reuse verified macro aliases
This commit is contained in:
1 parent
64adf51b20
commit
d98d7b44c1
10 files changed
+364
-33
No files matched your search
@@ -9,7 +9,7 @@ use std::{
|
||||
path::Path,
|
||||
};
|
||||
use texrra_tex_core::{
|
||||
execution::{CheckpointDecision, CheckpointSource, EntryCheckpoint},
|
||||
execution::{CheckpointDecision, CheckpointReplayError, CheckpointSource, EntryCheckpoint},
|
||||
resources::{ResourceKind, ResourceLookup, ResourceReadRange},
|
||||
};
|
||||
#[cfg(test)]
|
||||
@@ -582,6 +582,7 @@ impl PublishedCheckpoints {
|
||||
cache: &FormatCache,
|
||||
cancellation: &Cancellation,
|
||||
evidence: &mut AttemptEvidence,
|
||||
allow_deferred: bool,
|
||||
) -> Result<(SelectedCheckpoint, PreparedJob), CompileError> {
|
||||
let project = request
|
||||
.project
|
||||
@@ -597,6 +598,7 @@ impl PublishedCheckpoints {
|
||||
candidate: ExecutionCandidate::Completed(result.clone()),
|
||||
}
|
||||
}))
|
||||
.filter(|candidate| candidate.can_resume_accounting(allow_deferred))
|
||||
.collect();
|
||||
candidates.sort_by_key(|candidate| std::cmp::Reverse(candidate.completed_steps()));
|
||||
let mut candidates = VecDeque::from(candidates);
|
||||
@@ -777,6 +779,14 @@ impl CachedCheckpoint {
|
||||
}
|
||||
|
||||
impl SelectedCheckpoint {
|
||||
fn can_resume_accounting(&self, allow_deferred: bool) -> bool {
|
||||
match &self.candidate {
|
||||
ExecutionCandidate::Boundary(index) =>
|
||||
self.set.entries[*index].entry.can_resume_accounting(allow_deferred),
|
||||
ExecutionCandidate::Completed(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
fn completed_steps(&self) -> usize {
|
||||
match &self.candidate {
|
||||
ExecutionCandidate::Boundary(index) => self.set.entries[*index].entry.completed_steps(),
|
||||
@@ -924,7 +934,7 @@ impl SelectedCheckpoint {
|
||||
|slots, entry, host| {
|
||||
let entry = Arc::new(entry);
|
||||
captures.capture(slots, entry.clone(), host);
|
||||
if 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()
|
||||
&& Arc::ptr_eq(¤t.entry, &entry)
|
||||
&& let Some((advanced, slots)) = self.set.advance_child(current)
|
||||
@@ -975,7 +985,14 @@ impl SelectedCheckpoint {
|
||||
CheckpointDecision::Reuse(Box::new(execution))
|
||||
},
|
||||
)
|
||||
.map_err(CompileError::Host)?
|
||||
.map_err(|error| match error {
|
||||
CheckpointReplayError::Host(error) => CompileError::Host(error),
|
||||
CheckpointReplayError::Accounting { steps } => {
|
||||
let message = "child continuation accounting differs".to_owned();
|
||||
*suffix_failure = Some((message.clone(), steps.saturating_sub(work.reused_steps)));
|
||||
CompileError::Host(message)
|
||||
}
|
||||
})?
|
||||
.ok_or_else(changed_prefix)?;
|
||||
let next = result.as_ref().ok().and_then(|result| {
|
||||
captures.finish(recording, true, result)
|
||||
|
||||
Reference in new issue
Block a user