Preserve read evidence and box accounting in settled suffix reuse
This commit is contained in:
1 parent
473b3beace
commit
f78aff25c5
12 files changed
+381
-46
No files matched your search
@@ -10,7 +10,7 @@ use std::{
|
||||
time::Instant,
|
||||
};
|
||||
use texrra_tex_core::{
|
||||
execution::{CheckpointDecision, CheckpointSource, EntryCheckpoint, RelocatedShipoutSuffix},
|
||||
execution::{CheckpointDecision, CheckpointSource, EntryCheckpoint, Event, RelocatedShipoutSuffix, StatisticsPhase, StatisticsReport},
|
||||
resources::{ResourceKind, ResourceLookup, ResourceReadRange},
|
||||
};
|
||||
#[cfg(test)]
|
||||
@@ -416,6 +416,7 @@ impl<'a> CapturedEntries<'a> {
|
||||
current: &EntryCheckpoint,
|
||||
prior: &SettledCheckpoint,
|
||||
completed: &CompletedExecution,
|
||||
end_statistics: Option<&StatisticsReport>,
|
||||
host: &mut RecordingHost,
|
||||
cancellation: &Cancellation,
|
||||
) -> Result<(), String> {
|
||||
@@ -423,15 +424,11 @@ impl<'a> CapturedEntries<'a> {
|
||||
let path = &completed.guard.entry;
|
||||
let bytes = project.file(path).expect("settled entry").data.len();
|
||||
let previous_bytes = completed.guard.project.file(path).expect("prior settled entry").data.len();
|
||||
let resize = (previous_bytes != bytes).then_some((previous_bytes, bytes));
|
||||
let stride = bytes.div_ceil(SOURCE_INTERVALS).max(1);
|
||||
let offset = texrra_tex_core::execution::StepOffset::new(
|
||||
prior.entry.completed_steps(), current.completed_steps(),
|
||||
);
|
||||
let mut later = [const { None }; SOURCE_INTERVALS];
|
||||
// Untranslated live continuations and their source intervals still
|
||||
// refer to the old entry when its length changed.
|
||||
if resize.is_none()
|
||||
if previous_bytes == bytes
|
||||
&& let Some(mut rebase) = current.prepare_suffix_rebase(&prior.entry, &completed.result.execution)
|
||||
{
|
||||
// Keep the deepest compatible settled continuation per source interval.
|
||||
@@ -454,7 +451,7 @@ impl<'a> CapturedEntries<'a> {
|
||||
let Some(calls) = completed.calls.get(replayed..anchor.call_count) else {
|
||||
continue;
|
||||
};
|
||||
host.replay_suffix(calls, offset, None, cancellation)?;
|
||||
host.replay_suffix(calls, end_statistics, cancellation)?;
|
||||
replayed = anchor.call_count;
|
||||
if anchor.host == host.files().replay_boundary() {
|
||||
let regular = CaptureSlots {
|
||||
@@ -467,7 +464,7 @@ impl<'a> CapturedEntries<'a> {
|
||||
self.capture(Capture::Settled { page, regular: Some(regular) }, Arc::new(entry), host);
|
||||
}
|
||||
}
|
||||
host.replay_suffix(&completed.calls[replayed..], offset, resize, cancellation)?;
|
||||
host.replay_suffix(&completed.calls[replayed..], end_statistics, cancellation)?;
|
||||
completed.guard.verify_replayed_inputs(host.files(), project).map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
@@ -1020,8 +1017,15 @@ impl SelectedCheckpoint {
|
||||
return CheckpointDecision::Continue;
|
||||
};
|
||||
let calls = &completed.calls[old.call_count..];
|
||||
let end_statistics = execution.events.last().and_then(|event| match event {
|
||||
Event::Statistics(report) if matches!(report.phase, StatisticsPhase::End { .. }) =>
|
||||
Some(report.as_ref()),
|
||||
_ => None,
|
||||
});
|
||||
let replayed = measure(&mut timings.suffix_host_replay, timed, || {
|
||||
captures.replay_settled_suffix(page, &entry, old, completed, host, &cancellation)
|
||||
captures.replay_settled_suffix(
|
||||
page, &entry, old, completed, end_statistics, host, &cancellation,
|
||||
)
|
||||
});
|
||||
if let Err(error) = replayed {
|
||||
let discarded = entry.completed_steps().saturating_sub(work.reused_steps);
|
||||
|
||||
Reference in new issue
Block a user