Reuse byte-verified source versions after checkpoint resume

This commit is contained in:
gloamxun committed 2026-11-20 13:02:50 +08:00
1 parent 0ff8597ab4
commit 592d1ef2a3
2 files changed
+43 -8

No files matched your search

@@ -41,13 +41,38 @@ impl RevisionExecution {
revision: u64, revision: u64,
execution: Execution, execution: Execution,
resources: Option<crate::resources::ResourceTrace>, resources: Option<crate::resources::ResourceTrace>,
) -> Self {
Self::with_previous_sources(revision, execution, resources, None)
}
fn with_previous_sources(
revision: u64,
execution: Execution,
resources: Option<crate::resources::ResourceTrace>,
previous: Option<&Self>,
) -> Self { ) -> Self {
let source_versions = execution let source_versions = execution
.sources .sources
.iter() .iter()
.map(|source| SourceVersion { .enumerate()
sha256: format!("{:x}", Sha256::digest(&source.data)), .map(|(id, source)| {
bytes: source.data.len() as u64, // The previous result was built by this session. Match the
// scanned bytes, including generated and stream input.
previous
.and_then(|old| {
old.execution
.sources
.get(id)
.zip(old.source_versions.get(id))
})
.filter(|(old_source, _)| *old_source == source)
.map_or_else(
|| SourceVersion {
sha256: format!("{:x}", Sha256::digest(&source.data)),
bytes: source.data.len() as u64,
},
|(_, version)| version.clone(),
)
}) })
.collect(); .collect();
Self { Self {
@@ -166,7 +191,7 @@ impl RevisionJob {
let executed = executor let executed = executor
.with_cancellation(self.cancellation.clone()) .with_cancellation(self.cancellation.clone())
.run_detailed(source, files); .run_detailed(source, files);
self.finish_execution(executed, files) self.finish_execution(executed, files, None)
} }
/// Capture selected entry continuations while running the full revision. /// Capture selected entry continuations while running the full revision.
@@ -181,7 +206,7 @@ impl RevisionJob {
let executed = executor let executed = executor
.with_cancellation(self.cancellation.clone()) .with_cancellation(self.cancellation.clone())
.run_capturing_entries(source, files, select, capture); .run_capturing_entries(source, files, select, capture);
self.finish_execution(executed, files) self.finish_execution(executed, files, None)
} }
/// Resume after the host has validated prefix dependencies and replayed /// Resume after the host has validated prefix dependencies and replayed
@@ -192,9 +217,10 @@ impl RevisionJob {
source: SourceFile, source: SourceFile,
files: &mut impl SourceProvider, files: &mut impl SourceProvider,
) -> Option<Result<Arc<RevisionExecution>, RevisionFailure>> { ) -> Option<Result<Arc<RevisionExecution>, RevisionFailure>> {
let previous = self.session.latest();
let executed = let executed =
checkpoint.resume_after_host_replay(source, files, self.cancellation.clone())?; checkpoint.resume_after_host_replay(source, files, self.cancellation.clone())?;
Some(self.finish_execution(executed, files)) Some(self.finish_execution(executed, files, previous.as_deref()))
} }
/// Resume a verified prefix and observe new boundaries in the executed suffix. /// Resume a verified prefix and observe new boundaries in the executed suffix.
@@ -217,22 +243,24 @@ impl RevisionJob {
select, select,
capture, capture,
)?; )?;
Some(self.finish_execution(executed, files)) Some(self.finish_execution(executed, files, previous.as_deref()))
} }
fn finish_execution( fn finish_execution(
self, self,
executed: Result<Execution, ExecutionFailure>, executed: Result<Execution, ExecutionFailure>,
files: &impl SourceProvider, files: &impl SourceProvider,
previous: Option<&RevisionExecution>,
) -> Result<Arc<RevisionExecution>, RevisionFailure> { ) -> Result<Arc<RevisionExecution>, RevisionFailure> {
// Host observations can themselves supersede the revision. Do not // Host observations can themselves supersede the revision. Do not
// invoke the host while holding the session publication lock. // invoke the host while holding the session publication lock.
let resources = files.execution_resource_trace().cloned(); let resources = files.execution_resource_trace().cloned();
let result = executed.map(|execution| { let result = executed.map(|execution| {
Arc::new(RevisionExecution::from_execution( Arc::new(RevisionExecution::with_previous_sources(
self.revision, self.revision,
execution, execution,
resources.clone(), resources.clone(),
previous,
)) ))
}); });
let mut state = self let mut state = self
+7
View File
@@ -905,6 +905,13 @@ PDF、SVG、来源和 aux 与各自的增量版本一致。
`full-equivalence-{1,2-resumed}/receipt.json` 的 SHA-256 均为 `full-equivalence-{1,2-resumed}/receipt.json` 的 SHA-256 均为
`ec72d40ee6d2ec74a45bcad39000c2c19a9f08024713b2f5fc35c8da49bac207`。 `ec72d40ee6d2ec74a45bcad39000c2c19a9f08024713b2f5fc35c8da49bac207`。
按原补丁合入源指纹复用。完整工作区1627项通过、零失败。
暂停前完成100个测试套件,恢复后以原工作区构建配置执行剩余9个
集成套件,四个文档测试套件亦通过。两个单独运行的原样 A3 已通过。
`target/p4-reuse-source-versions/workspace-exact-resumed/receipt.json`
保存113个套件的合计及剩余工作区测试程序的哈希,回执 SHA-256 为
`2999f65936487143cb23d6da87419934403de3d79d8a4b0cb92dacae545871c7`。
同一个候选和基线分别加载固定出版格式与官方 IEEE Transactions 同一个候选和基线分别加载固定出版格式与官方 IEEE Transactions
双栏期刊样例。原始 `bare_jrnl.tex`、`IEEEtran.cls` 和格式的指纹 双栏期刊样例。原始 `bare_jrnl.tex`、`IEEEtran.cls` 和格式的指纹
匹配出版矩阵。两次正文编辑分别覆盖同长替换和不同长度替换,每次 匹配出版矩阵。两次正文编辑分别覆盖同长替换和不同长度替换,每次