Retain recent checkpoints for alternating body edits
This commit is contained in:
1 parent
d587405d2e
commit
75d156f0cf
3 files changed
+139
-12
No files matched your search
@@ -266,6 +266,30 @@ SHA-256 为 `47cb200c753e1f05270fa83f2d0f87d67a58f01292876f326990b2577d83215d`
|
||||
A3 日志 SHA-256 为 `99e2e14be446aaa2b8cf823b1f764881a4bdc22fa9f947e0a6a5da2d38cc6fb0`。
|
||||
下一组浏览器比较需单独测量这两项改动的延迟和内存。
|
||||
|
||||
### 往返编辑的检查点保留
|
||||
|
||||
早段改动跨过首次发页所依赖的输入时,额外保留此前最多两处有实际发页记录的
|
||||
检查点。每处保留原有的版本校验和宿主调用序列。后续编辑选取当前输入允许
|
||||
跳过最多执行步骤的位置。只有真实成功发布才更新这组状态。库和原生工作流
|
||||
62项定向回归通过。日志 `target/p4-checkpoint-branch-retention/directed.log`
|
||||
的 SHA-256 为 `f0d36792148fbb208d6880513be9d728451cd6244db02bc943f49170d7961199`。
|
||||
|
||||
使用含续跑断行和事件共享的主线作为基线,在同一真实格式和 Edge 上重跑两类
|
||||
各30次。正文往返编辑从0次复用有效步骤变为29次复用794269或794348步,后页
|
||||
所有30次仍复用约79.4万步。两端实际变更页、节点保留、PDF、SVG 和最终 aux
|
||||
一致。
|
||||
|
||||
| 编辑范围 | 基线 p50 / p95 | 候选 p50 / p95 |
|
||||
| --- | ---: | ---: |
|
||||
| 正文往返编辑 | 3082.8 / 4191.1 ms | 2416.7 / 3859.9 ms |
|
||||
| 第7页编辑 | 1540.3 / 2090.8 ms | 1341.1 / 2532.9 ms |
|
||||
|
||||
峰值 RSS 为1029020和1021868 KiB,均在该语料的1 GiB 门槛内。正文执行阶段
|
||||
p95 为978.5和193.0 ms。后页端到端 p95 回退,同时该组封存与发布阶段 p95
|
||||
为1731.6和2180.1 ms。运行前后 WSL I/O pressure avg10 为18.19%和38.52%。
|
||||
100 ms 门槛仍待达到。回执 `target/p4-checkpoint-branch-retention/edge-mixed/run-1/receipt.json`
|
||||
SHA-256 为 `81d06fae9f6c1ba2fabb7ef0e3dece25cdeab538c4b41a3ebedd3b9d4db34783`。
|
||||
|
||||
### schema27 与主线兼容性
|
||||
|
||||
合并了真实重复盒及 PDF 书签布局,并保留主线的宏参数分隔符和流式失败报告。
|
||||
|
||||
+1
-1
@@ -1170,7 +1170,7 @@ impl CompileJob {
|
||||
.seal_draft(prepared)
|
||||
.and_then(|draft| {
|
||||
draft.publish_current(&self.compiler.session, result.revision(), || {
|
||||
cache.set(next_checkpoint);
|
||||
cache.set(next_checkpoint, &request);
|
||||
expose();
|
||||
})
|
||||
});
|
||||
|
||||
+114
-11
@@ -12,6 +12,7 @@ use texrra_tex_core::{execution::HostResourceUsage, resources::InputPolicy};
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct EntryCheckpointWork {
|
||||
pub captured_frontier: Option<usize>,
|
||||
/// Checkpoints in the selected or freshly captured set.
|
||||
pub retained_checkpoints: usize,
|
||||
pub reused_frontier: Option<usize>,
|
||||
pub reused_steps: usize,
|
||||
@@ -21,7 +22,12 @@ pub struct EntryCheckpointWork {
|
||||
|
||||
pub(super) struct CheckpointCache {
|
||||
minimum_frontier: Option<usize>,
|
||||
published: Mutex<Option<Arc<CheckpointSet>>>,
|
||||
published: Mutex<Option<Arc<PublishedCheckpoints>>>,
|
||||
}
|
||||
|
||||
pub(super) struct PublishedCheckpoints {
|
||||
current: Arc<CheckpointSet>,
|
||||
previous_body: Option<Arc<CheckpointSet>>,
|
||||
}
|
||||
|
||||
struct CachedCheckpoint {
|
||||
@@ -220,18 +226,50 @@ impl CheckpointCache {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn current(&self) -> Option<Arc<CheckpointSet>> {
|
||||
pub(super) fn current(&self) -> Option<Arc<PublishedCheckpoints>> {
|
||||
self.published
|
||||
.lock()
|
||||
.expect("native entry checkpoint cache poisoned")
|
||||
.clone()
|
||||
}
|
||||
|
||||
pub(super) fn set(&self, checkpoint: Option<Arc<CheckpointSet>>) {
|
||||
*self
|
||||
pub(super) fn set(&self, next: Option<Arc<CheckpointSet>>, request: &CompileRequest) {
|
||||
let mut published = self
|
||||
.published
|
||||
.lock()
|
||||
.expect("native entry checkpoint cache poisoned") = checkpoint;
|
||||
.expect("native entry checkpoint cache poisoned");
|
||||
let Some(next) = next else {
|
||||
*published = None;
|
||||
return;
|
||||
};
|
||||
if published
|
||||
.as_ref()
|
||||
.and_then(|set| set.previous_body.as_ref())
|
||||
.is_some_and(|previous| Arc::ptr_eq(previous, &next))
|
||||
{
|
||||
return;
|
||||
}
|
||||
let previous_body = published.as_ref().and_then(|published| {
|
||||
if next.refresh_on_resume
|
||||
&& let Some(project) = request.project.as_deref()
|
||||
&& published
|
||||
.current
|
||||
.entries
|
||||
.iter()
|
||||
.find(|entry| entry.slots.page)
|
||||
.is_some_and(|entry| entry.accept_entry(project).is_err())
|
||||
{
|
||||
// Keep useful continuations from before a change to the first
|
||||
// shipped prefix. Later edits keep that same reserve.
|
||||
published.current.reserve_body()
|
||||
} else {
|
||||
published.previous_body.clone()
|
||||
}
|
||||
});
|
||||
*published = Some(Arc::new(PublishedCheckpoints {
|
||||
current: next,
|
||||
previous_body,
|
||||
}));
|
||||
}
|
||||
|
||||
pub(super) fn capture(
|
||||
@@ -264,7 +302,49 @@ impl CheckpointCache {
|
||||
}
|
||||
}
|
||||
|
||||
impl PublishedCheckpoints {
|
||||
pub(super) fn select(&self, request: &CompileRequest) -> Result<SelectedCheckpoint, String> {
|
||||
let current = self.current.clone().select(request);
|
||||
let Some(previous) = &self.previous_body else {
|
||||
return current;
|
||||
};
|
||||
let completed = current
|
||||
.as_ref()
|
||||
.map_or(0, SelectedCheckpoint::completed_steps);
|
||||
if previous
|
||||
.entries
|
||||
.last()
|
||||
.is_some_and(|entry| entry.entry.completed_steps() > completed)
|
||||
&& let Ok(previous) = previous.clone().select(request)
|
||||
&& previous.completed_steps() > completed
|
||||
{
|
||||
return Ok(previous);
|
||||
}
|
||||
current
|
||||
}
|
||||
}
|
||||
|
||||
impl CheckpointSet {
|
||||
fn reserve_body(&self) -> Option<Arc<Self>> {
|
||||
// The reserve holds only recent shipped checkpoints and the host
|
||||
// call prefix they independently require.
|
||||
let mut entries: Vec<_> = self
|
||||
.entries
|
||||
.iter()
|
||||
.rev()
|
||||
.filter(|entry| entry.slots.page)
|
||||
.take(2)
|
||||
.cloned()
|
||||
.collect();
|
||||
entries.reverse();
|
||||
let replay_count = entries.last()?.replay_count;
|
||||
Some(Arc::new(Self {
|
||||
entries,
|
||||
calls: self.calls[..replay_count].to_vec(),
|
||||
refresh_on_resume: self.refresh_on_resume,
|
||||
}))
|
||||
}
|
||||
|
||||
pub(super) fn report_capture(&self, work: &mut EntryCheckpointWork) {
|
||||
work.retained_checkpoints = self.entries.len();
|
||||
work.captured_frontier = self.entries.last().map(|entry| entry.entry.frontier());
|
||||
@@ -310,6 +390,10 @@ impl CachedCheckpoint {
|
||||
}
|
||||
|
||||
impl SelectedCheckpoint {
|
||||
fn completed_steps(&self) -> usize {
|
||||
self.set.entries[self.index].entry.completed_steps()
|
||||
}
|
||||
|
||||
pub(super) fn prepare(
|
||||
&self,
|
||||
request: &CompileRequest,
|
||||
@@ -1134,7 +1218,7 @@ fn automatic_checkpoints_follow_successive_edits_at_different_frontiers() {
|
||||
let original_result = compiler.compile(request.clone()).unwrap();
|
||||
assert_eq!(original_result.pages.len(), 10);
|
||||
|
||||
let first_edit = original.replace("width12pt", "width22pt");
|
||||
let first_edit = original.replace("width10pt", "width22pt");
|
||||
let edited_project = project
|
||||
.with_file_edits(
|
||||
2,
|
||||
@@ -1153,18 +1237,18 @@ fn automatic_checkpoints_follow_successive_edits_at_different_frontiers() {
|
||||
assert_eq!(first.source_map.pages, first_full.source_map.pages);
|
||||
assert_eq!(fs::read_to_string(&aux).unwrap(), stable_aux);
|
||||
|
||||
let second_edit = first_edit.replace("width17pt", "width27pt");
|
||||
let second_edit = first_edit.replace("width19pt", "width29pt");
|
||||
let second_project = edited_project
|
||||
.with_file_edits(
|
||||
3,
|
||||
BTreeMap::from([(entry, Arc::from(second_edit.as_bytes()))]),
|
||||
BTreeMap::from([(entry.clone(), Arc::from(second_edit.as_bytes()))]),
|
||||
)
|
||||
.unwrap();
|
||||
let second_request = request.with_project(second_project);
|
||||
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 second_work = &second.entry_checkpoint_work;
|
||||
assert!(second_work.reused_frontier.unwrap() > original.find("width12pt").unwrap());
|
||||
assert!(second_work.reused_frontier.unwrap() > original.find("width10pt").unwrap());
|
||||
assert!(second_work.reused_steps > first_work.reused_steps);
|
||||
assert!(second_work.replayed_calls > first_work.replayed_calls);
|
||||
assert!((2..=2 * SOURCE_INTERVALS).contains(&second_work.retained_checkpoints));
|
||||
@@ -1189,8 +1273,27 @@ fn automatic_checkpoints_follow_successive_edits_at_different_frontiers() {
|
||||
.iter()
|
||||
.map(|page| page.index)
|
||||
.collect::<Vec<_>>(),
|
||||
[7],
|
||||
[9],
|
||||
);
|
||||
|
||||
let reverted = original.replace("width19pt", "width29pt");
|
||||
let third_project = second_project
|
||||
.with_file_edits(
|
||||
4,
|
||||
BTreeMap::from([(entry, Arc::from(reverted.into_bytes()))]),
|
||||
)
|
||||
.unwrap();
|
||||
let third_request = request.with_project(third_project);
|
||||
let third = compiler.compile(third_request.clone()).unwrap();
|
||||
let third_full = NativeCompiler::default().compile(third_request).unwrap();
|
||||
assert!(
|
||||
third.entry_checkpoint_work.reused_steps > first_work.reused_steps,
|
||||
"{:?}",
|
||||
third.entry_checkpoint_work
|
||||
);
|
||||
assert_eq!(third.pdf, third_full.pdf);
|
||||
assert_eq!(third.source_map.pages, third_full.source_map.pages);
|
||||
assert_eq!(fs::read_to_string(&aux).unwrap(), stable_aux);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user