diff --git a/crates/texrra-tex-core/src/execution/statistics.rs b/crates/texrra-tex-core/src/execution/statistics.rs index ac110eb..c54cb54 100644 --- a/crates/texrra-tex-core/src/execution/statistics.rs +++ b/crates/texrra-tex-core/src/execution/statistics.rs @@ -1,7 +1,7 @@ //! Measured native storage and execution resources, not invented TeX arena words. use super::*; use std::{ - collections::{BTreeMap, BTreeSet}, + collections::{BTreeMap, BTreeSet, HashSet}, sync::Arc, }; @@ -352,7 +352,8 @@ impl AliasVisits { #[derive(Clone, Default)] pub(super) struct Collector { pub usage: ResourceUsage, - macros: BTreeSet, + // Alias visits keep traversal order separately from this membership index. + macros: HashSet, token_lists: BTreeSet<(usize, usize)>, shared_lists: Option>, aliases: Option, diff --git a/docs/NATIVE_BETA.md b/docs/NATIVE_BETA.md index 854c386..fda097b 100644 --- a/docs/NATIVE_BETA.md +++ b/docs/NATIVE_BETA.md @@ -70,9 +70,9 @@ python3 target/local-beta/native-beta.py resume /path/to/saved-project --web-dir ~~~ Tab 输入两个空格或缩进所选行,Shift+Tab 将焦点移到上一个控件。 -切换文件会记住各自的光标、选区和滚动位置。输入法确认文字后才提交预览, -连续输入时在短暂停顿后提交最新修改。编译出错时可继续查看上一次成功的预览, -修正后页面会自动更新。 +切换文件会记住各自的光标、选区和滚动位置。停顿后的首次编辑和输入法 +确认立即发起编译,连续输入的后续修改在短暂停顿后合并提交。编译出错时 +可继续查看上一次成功的预览,修正后页面会自动更新。 ## 保存和重新打开 diff --git a/docs/NATIVE_PRODUCT_GOAL.md b/docs/NATIVE_PRODUCT_GOAL.md index 50fb1f4..359b142 100644 --- a/docs/NATIVE_PRODUCT_GOAL.md +++ b/docs/NATIVE_PRODUCT_GOAL.md @@ -2,6 +2,13 @@ 本文件记录用户重申的最终目标,是短期 goal、实现优先级和验收标准的上位约束。 +## 2026-12-02 当前开发目标的收尾条件 + +用户要求先完成 XeTeX 整行编辑复用和浏览器 100 ms 可见时延。 +两项都用实际编译和页面交付验证后,可以结束当前开发目标。 +后续模板由用户补充,按实际项目出现的兼容问题继续适配。 +下方记录正式版的长期能力范围和原来的统一验收条件。 + ## Beta 优先交付 先交付可试用的 Route-D 本地编辑器和原生 CLI。试用范围列明已实际对照的 diff --git a/docs/P2_M1_PROGRESS.md b/docs/P2_M1_PROGRESS.md index f5e26f5..4363979 100644 --- a/docs/P2_M1_PROGRESS.md +++ b/docs/P2_M1_PROGRESS.md @@ -18,6 +18,31 @@ | W6 会话 | 实施中 | 共享库/CLI 与当前原生文字/数学/规则来源进入公共结果;真实 A4 副本九类/27 revision 与独立干净作业页面/PDF/aux/映射一致,新增数学场景独立参考通过;详细失败/捕获重放及宿主/离线/CLI观察已通过;原子项目版本/已知生成初态及TeX流记录已接通;原样 12 页 NeurIPS 的中部编辑与恢复已验证前后缀复用、仅更新一页,且与独立全量一致。全部副作用/交叉编辑、旧来源与正式性能门禁仍待闭合 | | W7 总验收 | 未满足 | 原有和新增测试、原样项目、格式与会话门禁全部通过才能结项 | +## 2026-12-02 浏览器可见时延试测 + +空闲后的首次编辑和输入法确认立即发起编译,连续输入的后续请求 +保留合并。计时仍包括接收响应、SVG 解码、实际页面替换和绘制。 +检查点准备阶段去除对已通过的首候选的重复快照遍历,保留实时 +文件状态与效果重放校验。宏分配使用地址哈希集合去重,报告 +访问顺序和计数保持一致,七项统计专项通过。 + +本机 Edge 对冻结格式和资源下的原样 A4 执行 60 次不同的正文修改, +主文件和子文件各 30 次,均更新实际显示页并核对 PDF 和来源。 +构建使用 release,内核和引擎包为 opt-level 1。性能二进制在 XeTeX +无换行符末行补丁前启动构建,本次 A4 两个文件都有行终止符。 + +| A4 热编辑 | 输入到发请求 p50 | 执行 p50 | 编辑到可见 p50 / p95 | +| --- | ---: | ---: | ---: | +| 主文件正文 | 1.5 ms | 140.6 ms | 242.0 / 370.0 ms | +| 子文件正文 | 1.5 ms | 96.0 ms | 192.8 / 272.9 ms | + +服务进程峰值 RSS 602,592 KiB。浏览器可见时延仍高于 100 ms。 +等待已缩短,主要剩余成本为实际执行、请求响应和页面绘制。 +主文件的独立诊断表明,输出例程结束后能取得会合候选,但变动 +后的读依赖集合和累计节点计数可能拒绝复用。后续要补齐可验证的 +依赖和计数换算,再用相同样例对照独立全量。 +原始样本、阶段用时和构建指纹位于 `target/p4-browser-visible-progress/`。 + ## 2026-12-02 XeTeX 整行编辑复用 XeTeX 扫描器保留已读物理行采用的分行规则。UTF-8、Bytes 及其他 diff --git a/examples/native_editor/app.js b/examples/native_editor/app.js index 3acbf0a..88fab7c 100644 --- a/examples/native_editor/app.js +++ b/examples/native_editor/app.js @@ -22,7 +22,8 @@ let publishedRevision = null; let draft = null; let composing = false; let compileTimer; -let frame; +let lastTypingAt = -Infinity; +let promptCompilePending = false; const projectPrefix = location.pathname.startsWith("/p/") ? location.pathname.slice(0, -1) : ""; const previewDraft = new URLSearchParams(location.hash.slice(1)).get("preview") !== "published"; @@ -63,7 +64,7 @@ function selectFile(filename) { source.blur(); if (composing) { composing = false; - queueCompile(); + queueCompile(true); } } fileViews.set(activeFile, { @@ -244,27 +245,32 @@ async function compile(edit, submitted, changes) { function invalidatePreview() { ++sequence; clearTimeout(compileTimer); - cancelAnimationFrame(frame); + compileTimer = undefined; + promptCompilePending = false; restorePublishedPages(); } -function queueCompile(delay = EDIT_IDLE_MS) { - invalidatePreview(); - const edit = sequence; +function queueCompile(immediate = false) { const submitted = performance.now(); + // Edits arriving before the first dispatch share its prompt submission. + const prompt = immediate || promptCompilePending || submitted - lastTypingAt >= EDIT_IDLE_MS; + invalidatePreview(); + if (!immediate) lastTypingAt = submitted; + promptCompilePending = prompt; + const edit = sequence; if (status.textContent !== "正在编译") status.textContent = "正在编译"; - const submit = () => { + compileTimer = setTimeout(() => { if (edit !== sequence || composing) return; + compileTimer = undefined; + promptCompilePending = false; compile(edit, submitted, Object.fromEntries(edits)); - }; - if (delay) compileTimer = setTimeout(submit, delay); - else frame = requestAnimationFrame(submit); + }, prompt ? 0 : EDIT_IDLE_MS); } function recordEdit(forceCompile = false) { const changed = source.value !== (edits.get(activeFile) ?? files.get(activeFile)); if (changed) edits.set(activeFile, source.value); - if (changed || forceCompile) queueCompile(); + if (changed || forceCompile) queueCompile(forceCompile); } function replaceSourceRange(text, start, end, selectionStart, selectionEnd, direction) { @@ -415,7 +421,7 @@ async function openProject() { event.preventDefault(); indentSource(); }); - queueCompile(0); + queueCompile(true); } catch (failure) { showError(failure.message); } diff --git a/src/native_checkpoint_guard.rs b/src/native_checkpoint_guard.rs index cf956ea..3b5b454 100644 --- a/src/native_checkpoint_guard.rs +++ b/src/native_checkpoint_guard.rs @@ -716,23 +716,30 @@ impl PublishedCheckpoints { cancellation, &mut attempt, Some(Box::new(|world, preparation| { - let mut rejection = None; - let remaining = std::iter::from_fn(|| candidates.pop_front()); - for candidate in std::iter::once(first).chain(remaining) { - match candidate + // Only the first candidate passed the immutable project + // and entry-prefix checks before arriving at this host. + let guard = first.guard(); + let rejection = match guard + .verify_clock_environment() + .and_then(|()| guard.verify_host(project, world, preparation)) + { + Ok(()) => { + selected = Some(first); + return Ok(()); + } + Err(error) => error, + }; + for candidate in std::iter::from_fn(|| candidates.pop_front()) { + if candidate .accept_entry(project) .and_then(|()| candidate.guard().verify(request, world, preparation)) + .is_ok() { - Ok(()) => { - selected = Some(candidate); - return Ok(()); - } - Err(error) => { - rejection.get_or_insert(error); - } + selected = Some(candidate); + return Ok(()); } } - Err(rejection.unwrap_or_else(|| "no entry checkpoint retained".into())) + Err(rejection) })), EffectMode::Draft, KernelPreparation::Resume, @@ -1358,6 +1365,11 @@ impl PrefixInputGuard { )); } } + self.verify_clock_environment()?; + Ok(current) + } + + fn verify_clock_environment(&self) -> Result<(), String> { if self .clock_environment .as_ref() @@ -1365,7 +1377,7 @@ impl PrefixInputGuard { { return Err("checkpoint file-date environment changed".into()); } - Ok(current) + Ok(()) } fn verify_replayed_inputs(&self, files: &Files, current: &ProjectSnapshot) -> Result<(), CompileError> { @@ -1397,11 +1409,19 @@ impl PrefixInputGuard { world: &FileWorld, preparation: &HostPreparation, ) -> Result<(), String> { - let current = self.verify_project(request)?; + self.verify_host(self.verify_project(request)?, world, preparation) + } + + fn verify_host( + &self, + project: &ProjectSnapshot, + world: &FileWorld, + preparation: &HostPreparation, + ) -> Result<(), String> { if self.format_input_bindings != world.trace().format_input_bindings { return Err("checkpoint format input bindings changed".into()); } - if world.trace().reads.first() != current.file(&self.entry).map(|file| &file.version) { + if world.trace().reads.first() != project.file(&self.entry).map(|file| &file.version) { return Err("checkpoint entry resolved to a different path".into()); } let current = preparation