Translate logical step counts when replaying native suffixes

This commit is contained in:
gloamxun committed 2026-12-01 21:16:41 +08:00
1 parent 9a6c162b46
commit 465a574124
8 files changed
+337 -86

No files matched your search

@@ -197,8 +197,10 @@ impl Executor {
let mut old_history = collector();
Self::collect_event_usage(self.events.iter(), &mut history);
Self::collect_event_usage(old.events.iter(), &mut old_history);
let live = self.collect_live_usage(None, None, collector().tracking_aliases());
let mut live = self.collect_live_usage(None, None, collector().tracking_aliases());
let old_live = old.collect_live_usage(None, None, collector().tracking_aliases());
// The splice translates steps separately and checks the job limit.
live.usage.steps = old_live.usage.steps;
live.has_equivalent_history(&old_live, &history, &old_history)
})
}
@@ -229,20 +231,9 @@ impl Executor {
.resource_usage()
.map_err(|e| self.error(e, self.current))?;
let after = self.resource_usage(None, host);
let text = format!(
"Route-D resources at shipout: active records {} -> {}; retained records {} -> {}; token cells {} -> {}; retained pages {}.\n",
before.active_material.records(),
after.active_material.records(),
before.retained_material.records(),
after.retained_material.records(),
before.macro_token_cells + before.token_list_cells,
after.macro_token_cells + after.token_list_cells,
after.retained_shipouts
);
self.emit_statistics(
StatisticsPhase::Shipout { before, after },
WriteDestination::TerminalAndLog,
text,
files,
)
}
@@ -259,46 +250,9 @@ impl Executor {
.resource_usage()
.map_err(|e| self.error(e, self.current))?;
let usage = self.resource_usage(None, host);
let mut text = format!(
"Route-D resource usage at core execution end ({}):\n {} steps out of {}\n {} source files, {} source payload bytes, {} active mouth payload bytes\n {} command entries, {} control-name bytes\n {} macro bindings, {} unique macro bodies, {} macro token cells\n {} token-list cells, {} saved entries\n {} active material records, {} retained material records, {} retained pages\n {} font instances, {} font parameter cells, {} TFM resources / {} source bytes\n {} hyphenation exceptions\n stack peaks: {} input, {} group, {} box, {} math, {} conditional, {} scanner, {} expansion\n",
if success { "success" } else { "failure" },
usage.steps,
usage.step_limit,
usage.source_files,
usage.source_payload_bytes,
usage.mouth_payload_bytes,
usage.state.command_entries,
usage.state.control_name_bytes,
usage.state.macro_bindings,
usage.unique_macro_bodies,
usage.macro_token_cells,
usage.token_list_cells,
usage.state.save_entries,
usage.active_material.records(),
usage.retained_material.records(),
usage.retained_shipouts,
usage.state.font_instances,
usage.state.font_parameter_cells,
usage.state.tfm_resources,
usage.state.tfm_resource_bytes,
usage.state.hyphenation_exceptions,
usage.stack_peaks.input_frames,
usage.stack_peaks.groups,
usage.stack_peaks.box_frames,
usage.stack_peaks.math_frames,
usage.stack_peaks.conditionals,
usage.stack_peaks.scanner_depth,
usage.stack_peaks.expansion_depth
);
if let Some(h) = &usage.host {
text.push_str(&format!(" host resources: {} reads / {} bytes; {} lookups / {} misses / {} errors; {} stream reads / {} bytes\n",h.resource_reads,h.resource_bytes_read,h.lookups,h.negative_lookups,h.failed_lookups,h.stream_read_calls,h.stream_bytes_read));
} else {
text.push_str(" host resource telemetry unavailable\n");
}
self.emit_statistics(
StatisticsPhase::End { success, usage },
WriteDestination::Log,
text,
files,
)
}
@@ -306,23 +260,17 @@ impl Executor {
&mut self,
phase: StatisticsPhase,
destination: WriteDestination,
text: String,
files: &mut impl SourceProvider,
) -> Result<(), Error> {
self.diagnostic_bytes = self.diagnostic_bytes.saturating_add(text.len());
let report = StatisticsReport::new(phase, destination, self.current);
self.diagnostic_bytes = self.diagnostic_bytes.saturating_add(report.text.len());
if self.diagnostic_bytes > self.limits.tokens {
return self.fail("native diagnostic output limit exceeded");
}
files
.observe_diagnostic(destination, &text)
.observe_statistics(&report)
.map_err(|e| self.error(e, self.current))?;
self.events
.push(Event::Statistics(Box::new(StatisticsReport {
phase,
destination,
text,
span: self.current,
})));
self.events.push(Event::Statistics(Box::new(report)));
Ok(())
}
}