Expose optional checkpoint clone and suffix proof timings

This commit is contained in:
gloamxun committed 2026-12-02 02:38:43 +08:00
1 parent 67396827a9
commit c8f7a0cbe6
7 files changed
+170 -27

No files matched your search

+20 -1
View File
@@ -33,7 +33,8 @@ pub use texrra_tex_core::resources::{ProjectDefinition, ProjectSnapshot, Project
pub use texrra_tex_core::resources::{WorldFailure, WorldObservation};
use texrra_tex_core::{
execution::{
Cancellation, ExecutionFailure, Executor, FormatImage, InputProfile, JobTime, Limits,
Cancellation, CheckpointCloneTimings, ExecutionFailure, Executor, FormatImage, InputProfile,
JobTime, Limits,
NativeSession, Profile, RevisionError, RevisionExecution, RevisionFailure, RevisionJob, SourceFile,
SourceProvider, State, SuffixKernelTimings, WriteDestination,
},
@@ -102,6 +103,8 @@ pub struct CheckpointTimings {
/// Restoring the executor, running new commands, observing checkpoints,
/// and finishing the revision's kernel result.
pub resume: Duration,
/// Executor clone times within resume, including captures rejected by the host.
pub clones: CheckpointCloneTimings,
pub capture: Duration,
pub suffix_host_validation: Duration,
pub suffix_kernel_validation: Duration,
@@ -121,6 +124,22 @@ pub trait CompileObserver: Send + Sync {
/// Observe the work of a resumed native revision before layout begins.
fn checkpoint_timings(&self, _revision: u64, _timings: CheckpointTimings) {}
/// Opt in to executor clone timings and individual suffix candidate observations.
fn wants_checkpoint_details(&self) -> bool {
false
}
/// Observe one candidate that reached the kernel. Donors are numbered in
/// the order considered, starting at zero. Acceptance here precedes replay.
fn suffix_candidate_timing(
&self,
_revision: u64,
_page: usize,
_donor_index: usize,
_accepted: bool,
_timings: SuffixKernelTimings,
) {}
/// Called for a completed native draft before its staged files are synced
/// and installed. The caller can display these pages provisionally. The
/// compile result determines whether this revision actually published.
+22 -6
View File
@@ -982,15 +982,19 @@ impl SelectedCheckpoint {
let mut suffix_base = None;
let mut reused_layouts = None;
let mut timings = CheckpointTimings::default();
let timed = request.observer.is_some();
let observer = request.observer.as_deref();
let timed = observer.is_some();
let detailed_observer = observer.filter(|observer| observer.wants_checkpoint_details());
let mut clones = CheckpointCloneTimings::default();
let resume_started = timed.then(Instant::now);
let result = job
.resume_deciding_suffix(
.resume_deciding_suffix_observed(
&checkpoint.entry,
source,
nested_source,
&mut recording,
line_break_cache,
detailed_observer.is_some().then_some(&mut clones),
|source, pages| {
if source.is_entry {
// The loaded entry line can be shared by several shipouts.
@@ -1016,7 +1020,7 @@ impl SelectedCheckpoint {
let Some(new) = captures.settled.get(&page).filter(|_| allow_suffix) else {
return CheckpointDecision::Continue;
};
let Some((completed, old, execution, layout, closed_source)) = suffixes.clone().find_map(|completed| {
let Some((completed, old, execution, layout, closed_source)) = suffixes.clone().enumerate().find_map(|(donor_index, completed)| {
let old = completed.settled.get(&page)?;
let closed_source = measure(&mut timings.suffix_host_validation, timed, || {
if old.call_count != new.call_count {
@@ -1031,8 +1035,12 @@ impl SelectedCheckpoint {
prove_closed_source_suffix(change, old, new, completed, request, host)
.map(Some)
})?;
let kernel_timings = timed.then_some(&mut timings.suffix_kernel);
let (execution, layout) = measure(&mut timings.suffix_kernel_validation, timed, || {
let mut attempt = detailed_observer.map(|_| SuffixKernelTimings {
state_proof: Some(Default::default()),
..SuffixKernelTimings::default()
});
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,
@@ -1046,7 +1054,14 @@ impl SelectedCheckpoint {
&old.entry, &completed.result.execution, kernel_timings,
)
}
})?;
});
if let Some((observer, attempt)) = detailed_observer.zip(attempt) {
timings.suffix_kernel += attempt;
observer.suffix_candidate_timing(
job.revision(), page, donor_index, result.is_some(), attempt,
);
}
let (execution, layout) = result?;
Some((completed, old, execution, layout, closed_source))
}) else {
return CheckpointDecision::Continue;
@@ -1089,6 +1104,7 @@ impl SelectedCheckpoint {
.ok_or_else(changed_prefix)?;
if let Some(started) = resume_started {
timings.resume = started.elapsed();
timings.clones = clones;
}
let next = measure(&mut timings.retain, timed, || {
result.as_ref().ok().and_then(|result| captures.finish(recording, true, result, suffix_base))