Reuse exact final fingerprints of distinct published states
This commit is contained in:
1 parent
af8f38bb78
commit
841198615a
5 files changed
+104
-29
No files matched your search
@@ -10,7 +10,7 @@ use std::{
|
||||
time::Instant,
|
||||
};
|
||||
use texrra_tex_core::{
|
||||
execution::{CheckpointDecision, CheckpointSource, ClosedSourceChange, EntryCheckpoint, Event, RelocatedShipoutSuffix, StatisticsPhase, StatisticsReport},
|
||||
execution::{CheckpointDecision, CheckpointSource, ClosedSourceChange, EntryCheckpoint, Event, RelocatedShipoutSuffix, RetainedStateFingerprint, StatisticsPhase, StatisticsReport},
|
||||
resources::{ResourceKind, ResourceLookup, ResourceReadRange},
|
||||
};
|
||||
#[cfg(test)]
|
||||
@@ -45,6 +45,7 @@ pub(super) struct PublishedCheckpoints {
|
||||
current: Arc<CheckpointSet>,
|
||||
previous_body: Option<Arc<CheckpointSet>>,
|
||||
previous_completion: Option<Arc<CompletedExecution>>,
|
||||
previous_fingerprint: Option<Arc<RetainedStateFingerprint>>,
|
||||
}
|
||||
|
||||
struct CachedCheckpoint {
|
||||
@@ -90,6 +91,7 @@ pub(super) struct CheckpointSet {
|
||||
pub(super) struct SelectedCheckpoint {
|
||||
set: Arc<CheckpointSet>,
|
||||
candidate: ExecutionCandidate,
|
||||
previous_fingerprint: Option<Arc<RetainedStateFingerprint>>,
|
||||
}
|
||||
|
||||
pub(super) struct ReusedShipoutLayouts {
|
||||
@@ -627,10 +629,23 @@ impl CheckpointCache {
|
||||
let previous_completion = published.as_ref().and_then(|published| {
|
||||
published.current.completion.clone().or_else(|| published.previous_completion.clone())
|
||||
});
|
||||
let previous_fingerprint = published.as_ref().and_then(|published| {
|
||||
if let Some((before, after)) = published.current.completion.as_ref().zip(next.completion.as_ref()) {
|
||||
let before = &before.result.execution;
|
||||
let after = &after.result.execution;
|
||||
// Equal results should not evict the other distinct state.
|
||||
// A hash mismatch proves distinctness, but a match does not prove equality.
|
||||
if before.outgoing_state != after.outgoing_state || before.state != after.state {
|
||||
return Some(Arc::new(before.retain_final_state_fingerprint()));
|
||||
}
|
||||
}
|
||||
published.previous_fingerprint.clone()
|
||||
});
|
||||
*published = Some(Arc::new(PublishedCheckpoints {
|
||||
current: next,
|
||||
previous_body,
|
||||
previous_completion,
|
||||
previous_fingerprint,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -692,6 +707,7 @@ impl PublishedCheckpoints {
|
||||
SelectedCheckpoint {
|
||||
set: self.current.clone(),
|
||||
candidate: ExecutionCandidate::Completed(result.clone()),
|
||||
previous_fingerprint: None,
|
||||
}
|
||||
}))
|
||||
.collect();
|
||||
@@ -761,7 +777,7 @@ impl PublishedCheckpoints {
|
||||
EffectMode::Draft,
|
||||
KernelPreparation::Resume,
|
||||
)?;
|
||||
let selected = selected.expect("resume preparation chose a verified checkpoint");
|
||||
let mut selected = selected.expect("resume preparation chose a verified checkpoint");
|
||||
let guard = selected.guard();
|
||||
let partial_source = guard.nested_source.as_ref()
|
||||
.and_then(|source| project.file(&source.path)).map(|file| &file.version);
|
||||
@@ -783,6 +799,7 @@ impl PublishedCheckpoints {
|
||||
continue;
|
||||
}
|
||||
*evidence = attempt;
|
||||
selected.previous_fingerprint = self.previous_fingerprint.clone();
|
||||
return Ok((selected, prepared));
|
||||
}
|
||||
}
|
||||
@@ -825,6 +842,7 @@ impl CheckpointSet {
|
||||
.map(|index| SelectedCheckpoint {
|
||||
set: Arc::clone(self),
|
||||
candidate: ExecutionCandidate::Boundary(index),
|
||||
previous_fingerprint: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1041,19 +1059,13 @@ impl SelectedCheckpoint {
|
||||
});
|
||||
let result = measure(&mut timings.suffix_kernel_validation, timed, || {
|
||||
let kernel_timings = attempt.as_mut().or(timed.then_some(&mut timings.suffix_kernel));
|
||||
if let Some(child) = &closed_source {
|
||||
entry.splice_settled_closed_source_suffix_observed(
|
||||
&old.entry,
|
||||
&completed.result.execution,
|
||||
child.source_id,
|
||||
child.prefix_resource_reads,
|
||||
kernel_timings,
|
||||
)
|
||||
} else {
|
||||
entry.splice_settled_suffix_observed(
|
||||
&old.entry, &completed.result.execution, kernel_timings,
|
||||
)
|
||||
}
|
||||
entry.splice_settled_suffix_with_fingerprint(
|
||||
&old.entry,
|
||||
&completed.result.execution,
|
||||
closed_source.as_ref().map(|child| (child.source_id, child.prefix_resource_reads)),
|
||||
self.previous_fingerprint.as_deref(),
|
||||
kernel_timings,
|
||||
)
|
||||
});
|
||||
if let Some((observer, attempt)) = detailed_observer.zip(attempt) {
|
||||
timings.suffix_kernel += attempt;
|
||||
|
||||
Reference in new issue
Block a user