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);
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::fs;
|
||||
#[cfg(test)]
|
||||
use texrra_tex_core::source_map::SourceMap;
|
||||
use texrra_tex_core::{
|
||||
execution::{Error, HostResourceUsage, StatisticsPhase, StatisticsReport, StepOffset, WriteDestination},
|
||||
execution::{Error, HostResourceUsage, StatisticsPhase, StatisticsReport, WriteDestination},
|
||||
resources::{LoadedResource, ResourceKind, ResourceVersion},
|
||||
};
|
||||
|
||||
@@ -177,8 +177,7 @@ impl<'a> RecordingHost<'a> {
|
||||
pub(super) fn replay_suffix(
|
||||
&mut self,
|
||||
calls: &[Call],
|
||||
offset: StepOffset,
|
||||
resize: Option<(usize, usize)>,
|
||||
end_statistics: Option<&StatisticsReport>,
|
||||
cancellation: &Cancellation,
|
||||
) -> Result<(), String> {
|
||||
let recorded = self.calls.as_mut().ok_or("host calls are unavailable")?;
|
||||
@@ -188,15 +187,14 @@ impl<'a> RecordingHost<'a> {
|
||||
for call in calls {
|
||||
check(cancellation).map_err(|error| error.to_string())?;
|
||||
let call = match call {
|
||||
Call::EndStatistics(report) if !offset.is_identity() || resize.is_some() => {
|
||||
let report = report.with_step_offset(offset).ok_or("invalid replayed statistics")?;
|
||||
let report = if let Some((previous, current)) = resize {
|
||||
report.with_suffix_entry_resize(previous, current)
|
||||
.ok_or("invalid replayed entry size in statistics")?
|
||||
Call::EndStatistics(report) => {
|
||||
// The kernel has already checked and translated this report.
|
||||
let translated = end_statistics.ok_or("completed suffix is missing its final statistics")?;
|
||||
if report.as_ref() == translated {
|
||||
call.clone()
|
||||
} else {
|
||||
report
|
||||
};
|
||||
Call::EndStatistics(Arc::new(report))
|
||||
Call::EndStatistics(Arc::new(translated.clone()))
|
||||
}
|
||||
}
|
||||
call => call.clone(),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user