Reuse unchanged shipout drawing lists after checkpoint resume
This commit is contained in:
1 parent
e7ab132520
commit
6939ff71ff
5 files changed
+88
-7
No files matched your search
@@ -66,6 +66,21 @@ fn pdf_resource_entries_empty(entries: &Arc<[u8]>) -> bool {
|
||||
}
|
||||
|
||||
impl NativeShipout {
|
||||
/// The checkpoint and its resumed execution share actual TeX lists.
|
||||
/// Check that identity first, then compare the rest of the shipout snapshot.
|
||||
pub fn shares_local_layout_with(&self, prior: &Self) -> bool {
|
||||
let shared = match (&self.box_node.content, &prior.box_node.content) {
|
||||
(BoxContent::Horizontal(current), BoxContent::Horizontal(previous)) => {
|
||||
Arc::ptr_eq(current, previous)
|
||||
}
|
||||
(BoxContent::Vertical(current), BoxContent::Vertical(previous)) => {
|
||||
Arc::ptr_eq(current, previous)
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
shared && self == prior
|
||||
}
|
||||
|
||||
pub fn display_list(&self) -> Result<crate::render::DisplayList, String> {
|
||||
self.display_list_prefix(None)
|
||||
}
|
||||
|
||||
@@ -778,6 +778,15 @@ impl Execution {
|
||||
/// Paint actual shipped boxes using their captured device state. No
|
||||
/// pagination or application of the job's final device settings.
|
||||
pub fn shipout_display_lists(&self) -> Result<Vec<crate::render::DisplayList>, Error> {
|
||||
self.shipout_display_lists_with(NativeShipout::display_list)
|
||||
}
|
||||
|
||||
/// Lower shipped boxes, optionally reusing their immutable local layout.
|
||||
/// The current revision still resolves all deferred and document-wide PDF data.
|
||||
pub fn shipout_display_lists_with(
|
||||
&self,
|
||||
mut lower: impl FnMut(&NativeShipout) -> Result<crate::render::DisplayList, String>,
|
||||
) -> Result<Vec<crate::render::DisplayList>, Error> {
|
||||
if self.native_page.is_none() {
|
||||
return Err(Error::at(
|
||||
&self.sources,
|
||||
@@ -803,7 +812,7 @@ impl Execution {
|
||||
});
|
||||
}
|
||||
if let Event::Shipout(b) = e {
|
||||
pages.push(b.display_list().map_err(|message| {
|
||||
pages.push(lower(b).map_err(|message| {
|
||||
Error::at(
|
||||
&self.sources,
|
||||
self.state.input_profile(),
|
||||
|
||||
@@ -18,6 +18,27 @@
|
||||
| W6 会话 | 实施中 | 共享库/CLI 与当前原生文字/数学/规则来源进入公共结果;真实 A4 副本九类/27 revision 与独立干净作业页面/PDF/aux/映射一致,新增数学场景独立参考通过;详细失败/捕获重放及宿主/离线/CLI观察已通过;原子项目版本/已知生成初态及TeX流记录已接通;完整副作用/恢复契约、旧来源和性能仍缺 |
|
||||
| W7 总验收 | 未满足 | 原有和新增测试、原样项目、格式与会话门禁全部通过才能结项 |
|
||||
|
||||
## 2026-11-28 已出页盒的增量绘制复用
|
||||
|
||||
检查点恢复后按页比对上次发布的出页快照。实际盒列表共享同一份存储,
|
||||
且捕获的设备、位置和内容相等时,复用局部绘制列表,跳过该页的盒遍历。
|
||||
引用文档级 PDF 对象、解析资源、选择字体、生成 PDF 和来源映射都基于当前
|
||||
修订。库结果的 shipout_layout_work 分别统计本轮新转换和复用的页数。
|
||||
开启检查点的会话保存每页一份未解析的局部列表供下次修订使用。
|
||||
|
||||
原样 longtable、booktabs 和 amsmath 跨页表格的末行编辑只刷新第 3 页。
|
||||
双栏样例中脚注附近的文字编辑只刷新第 1 页。两种文档各有三个成功修订,
|
||||
以及一次未定义控制序列失败。成功修订的 PDF、绘制列表、来源映射、组装后
|
||||
的 SVG、aux 与日志都与同初态独立全量一致。失败保留上次 PDF、aux 和预览。
|
||||
长表格两次后续修订各复用 1,897,646 步,双栏各复用 1,714,261 步。
|
||||
|
||||
编辑长表格之后的结语时,复用前两页的局部绘制列表,只转换并刷新第 3 页。
|
||||
三个成功修订各复用 1,986,815 个执行步。现有十页检查点回归也核对实际
|
||||
绘制复用与独立全量一致。后续按实际开销推进资源和导出复用。完整模板矩阵、
|
||||
正式可见时延及内存采样按总门禁统一验收。
|
||||
|
||||
本地证据在 target/p3-combined-layout/。
|
||||
|
||||
## 2026-11-28 XeLaTeX 旧 TFM 与复合 Type 1
|
||||
|
||||
旧 TFM 可以通过 Unicode、Identity-H/V 和命名 CMap 选中原版 Type 1
|
||||
|
||||
+37
-6
@@ -233,6 +233,8 @@ pub struct CompiledDocument {
|
||||
pub format_preparation: Option<FormatPreparation>,
|
||||
/// Actual paragraph search performed or reused in this revision.
|
||||
pub line_break_work: texrra_tex_core::execution::LineBreakWork,
|
||||
/// Work converting shipped boxes to local drawing lists before resolving PDF resources.
|
||||
pub shipout_layout_work: ShipoutLayoutWork,
|
||||
/// Original measurements with actual resolved font programs.
|
||||
pub pages: Vec<DisplayList>,
|
||||
/// Revision-local measured paint and source versions. `unmapped` explicitly
|
||||
@@ -250,6 +252,13 @@ pub struct CompiledDocument {
|
||||
pub dvi: Option<Arc<[u8]>>,
|
||||
pub output: Option<ResourceVersion>,
|
||||
preview: PreviewState,
|
||||
shipout_layouts: Vec<Arc<DisplayList>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub struct ShipoutLayoutWork {
|
||||
pub lowered_pages: usize,
|
||||
pub reused_pages: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
@@ -1114,15 +1123,35 @@ impl CompileJob {
|
||||
notify(&request, revision, CompileStage::Executed, &cancellation)?;
|
||||
evidence.phase = AttemptPhase::Layout;
|
||||
let e = &execution.execution;
|
||||
let prior_layout = (entry_checkpoint_work.reused_steps > 0)
|
||||
.then(|| self.compiler.latest())
|
||||
.flatten();
|
||||
let mut shipout_layout_work = ShipoutLayoutWork::default();
|
||||
let mut shipout_layouts = Vec::new();
|
||||
let (mut pages, paper_width, paper_height, origin) = if request.target
|
||||
== Target::Shipouts
|
||||
{
|
||||
(
|
||||
e.shipout_display_lists().map_err(|e| e.to_string())?,
|
||||
0,
|
||||
0,
|
||||
texrra_tex_core::pdf::PageOrigin::default(),
|
||||
)
|
||||
use texrra_tex_core::execution::Event;
|
||||
let mut old = prior_layout.as_deref().into_iter().flat_map(|prior| {
|
||||
prior.execution.execution.events.iter().filter_map(|event| {
|
||||
if let Event::Shipout(page) = event { Some(page.as_ref()) } else { None }
|
||||
}).zip(&prior.shipout_layouts)
|
||||
});
|
||||
let pages = e.shipout_display_lists_with(|page| {
|
||||
let shared = old.next().filter(|(prior, _)| page.shares_local_layout_with(prior));
|
||||
if let Some((_, layout)) = shared {
|
||||
shipout_layout_work.reused_pages += 1;
|
||||
shipout_layouts.push(layout.clone());
|
||||
return Ok((**layout).clone());
|
||||
}
|
||||
let layout = page.display_list()?;
|
||||
shipout_layout_work.lowered_pages += 1;
|
||||
if checkpoints.is_some() {
|
||||
shipout_layouts.push(Arc::new(layout.clone()));
|
||||
}
|
||||
Ok(layout)
|
||||
}).map_err(|e| e.to_string())?;
|
||||
(pages, 0, 0, texrra_tex_core::pdf::PageOrigin::default())
|
||||
} else {
|
||||
let document = e.document().map_err(|e| e.to_string())?;
|
||||
let engine = texrra_tex_core::Engine::layout_paged(&document)
|
||||
@@ -1299,6 +1328,7 @@ impl CompileJob {
|
||||
format_preparation,
|
||||
entry_checkpoint_work,
|
||||
line_break_work,
|
||||
shipout_layout_work,
|
||||
execution,
|
||||
pages,
|
||||
source_map,
|
||||
@@ -1311,6 +1341,7 @@ impl CompileJob {
|
||||
dvi: dvi.map(Arc::from),
|
||||
output: receipt,
|
||||
preview,
|
||||
shipout_layouts,
|
||||
});
|
||||
evidence.phase = AttemptPhase::ReadyToPublish;
|
||||
notify(
|
||||
|
||||
@@ -1834,6 +1834,11 @@ fn automatic_checkpoints_follow_successive_edits_at_different_frontiers() {
|
||||
let second_request = request.clone().with_project(second_project.clone());
|
||||
let second = compiler.compile(second_request.clone()).unwrap();
|
||||
let second_full = NativeCompiler::default().compile(second_request).unwrap();
|
||||
let layout = second.shipout_layout_work;
|
||||
assert!(layout.reused_pages > 0, "{layout:?}");
|
||||
assert_eq!(layout.reused_pages + layout.lowered_pages, second.pages.len());
|
||||
assert_eq!(second_full.shipout_layout_work.reused_pages, 0);
|
||||
assert_eq!(second_full.shipout_layout_work.lowered_pages, second_full.pages.len());
|
||||
let second_work = &second.entry_checkpoint_work;
|
||||
assert!(second_work.reused_frontier.unwrap() > original.find("width10pt").unwrap());
|
||||
assert!(second_work.reused_steps > first_work.reused_steps);
|
||||
|
||||
Reference in new issue
Block a user