Dispatch isolated editor edits promptly and measure browser paints

This commit is contained in:
gloamxun committed 2026-12-02 00:23:48 +08:00
1 parent bf42a88dff
commit 473b3beace
6 files changed
+91 -32

No files matched your search

@@ -1,7 +1,7 @@
//! Measured native storage and execution resources, not invented TeX arena words. //! Measured native storage and execution resources, not invented TeX arena words.
use super::*; use super::*;
use std::{ use std::{
collections::{BTreeMap, BTreeSet}, collections::{BTreeMap, BTreeSet, HashSet},
sync::Arc, sync::Arc,
}; };
@@ -352,7 +352,8 @@ impl AliasVisits {
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub(super) struct Collector { pub(super) struct Collector {
pub usage: ResourceUsage, pub usage: ResourceUsage,
macros: BTreeSet<usize>, // Alias visits keep traversal order separately from this membership index.
macros: HashSet<usize>,
token_lists: BTreeSet<(usize, usize)>, token_lists: BTreeSet<(usize, usize)>,
shared_lists: Option<BTreeSet<usize>>, shared_lists: Option<BTreeSet<usize>>,
aliases: Option<AliasVisits>, aliases: Option<AliasVisits>,
+3 -3
View File
@@ -70,9 +70,9 @@ python3 target/local-beta/native-beta.py resume /path/to/saved-project --web-dir
~~~ ~~~
Tab 输入两个空格或缩进所选行,Shift+Tab 将焦点移到上一个控件。 Tab 输入两个空格或缩进所选行,Shift+Tab 将焦点移到上一个控件。
切换文件会记住各自的光标、选区和滚动位置。输入法确认文字后才提交预览, 切换文件会记住各自的光标、选区和滚动位置。停顿后的首次编辑和输入法
连续输入时在短暂停顿后提交最新修改。编译出错时可继续查看上一次成功的预览, 确认立即发起编译,连续输入的后续修改在短暂停顿后合并提交。编译出错时
修正后页面会自动更新。 可继续查看上一次成功的预览,修正后页面会自动更新。
## 保存和重新打开 ## 保存和重新打开
+7
View File
@@ -2,6 +2,13 @@
本文件记录用户重申的最终目标,是短期 goal、实现优先级和验收标准的上位约束。 本文件记录用户重申的最终目标,是短期 goal、实现优先级和验收标准的上位约束。
## 2026-12-02 当前开发目标的收尾条件
用户要求先完成 XeTeX 整行编辑复用和浏览器 100 ms 可见时延。
两项都用实际编译和页面交付验证后,可以结束当前开发目标。
后续模板由用户补充,按实际项目出现的兼容问题继续适配。
下方记录正式版的长期能力范围和原来的统一验收条件。
## Beta 优先交付 ## Beta 优先交付
先交付可试用的 Route-D 本地编辑器和原生 CLI。试用范围列明已实际对照的 先交付可试用的 Route-D 本地编辑器和原生 CLI。试用范围列明已实际对照的
+25
View File
@@ -18,6 +18,31 @@
| W6 会话 | 实施中 | 共享库/CLI 与当前原生文字/数学/规则来源进入公共结果;真实 A4 副本九类/27 revision 与独立干净作业页面/PDF/aux/映射一致,新增数学场景独立参考通过;详细失败/捕获重放及宿主/离线/CLI观察已通过;原子项目版本/已知生成初态及TeX流记录已接通;原样 12 页 NeurIPS 的中部编辑与恢复已验证前后缀复用、仅更新一页,且与独立全量一致。全部副作用/交叉编辑、旧来源与正式性能门禁仍待闭合 | | W6 会话 | 实施中 | 共享库/CLI 与当前原生文字/数学/规则来源进入公共结果;真实 A4 副本九类/27 revision 与独立干净作业页面/PDF/aux/映射一致,新增数学场景独立参考通过;详细失败/捕获重放及宿主/离线/CLI观察已通过;原子项目版本/已知生成初态及TeX流记录已接通;原样 12 页 NeurIPS 的中部编辑与恢复已验证前后缀复用、仅更新一页,且与独立全量一致。全部副作用/交叉编辑、旧来源与正式性能门禁仍待闭合 |
| W7 总验收 | 未满足 | 原有和新增测试、原样项目、格式与会话门禁全部通过才能结项 | | 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 整行编辑复用 ## 2026-12-02 XeTeX 整行编辑复用
XeTeX 扫描器保留已读物理行采用的分行规则。UTF-8、Bytes 及其他 XeTeX 扫描器保留已读物理行采用的分行规则。UTF-8、Bytes 及其他
+18 -12
View File
@@ -22,7 +22,8 @@ let publishedRevision = null;
let draft = null; let draft = null;
let composing = false; let composing = false;
let compileTimer; let compileTimer;
let frame; let lastTypingAt = -Infinity;
let promptCompilePending = false;
const projectPrefix = location.pathname.startsWith("/p/") ? location.pathname.slice(0, -1) : ""; const projectPrefix = location.pathname.startsWith("/p/") ? location.pathname.slice(0, -1) : "";
const previewDraft = new URLSearchParams(location.hash.slice(1)).get("preview") !== "published"; const previewDraft = new URLSearchParams(location.hash.slice(1)).get("preview") !== "published";
@@ -63,7 +64,7 @@ function selectFile(filename) {
source.blur(); source.blur();
if (composing) { if (composing) {
composing = false; composing = false;
queueCompile(); queueCompile(true);
} }
} }
fileViews.set(activeFile, { fileViews.set(activeFile, {
@@ -244,27 +245,32 @@ async function compile(edit, submitted, changes) {
function invalidatePreview() { function invalidatePreview() {
++sequence; ++sequence;
clearTimeout(compileTimer); clearTimeout(compileTimer);
cancelAnimationFrame(frame); compileTimer = undefined;
promptCompilePending = false;
restorePublishedPages(); restorePublishedPages();
} }
function queueCompile(delay = EDIT_IDLE_MS) { function queueCompile(immediate = false) {
invalidatePreview();
const edit = sequence;
const submitted = performance.now(); 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 = "正在编译"; if (status.textContent !== "正在编译") status.textContent = "正在编译";
const submit = () => { compileTimer = setTimeout(() => {
if (edit !== sequence || composing) return; if (edit !== sequence || composing) return;
compileTimer = undefined;
promptCompilePending = false;
compile(edit, submitted, Object.fromEntries(edits)); compile(edit, submitted, Object.fromEntries(edits));
}; }, prompt ? 0 : EDIT_IDLE_MS);
if (delay) compileTimer = setTimeout(submit, delay);
else frame = requestAnimationFrame(submit);
} }
function recordEdit(forceCompile = false) { function recordEdit(forceCompile = false) {
const changed = source.value !== (edits.get(activeFile) ?? files.get(activeFile)); const changed = source.value !== (edits.get(activeFile) ?? files.get(activeFile));
if (changed) edits.set(activeFile, source.value); if (changed) edits.set(activeFile, source.value);
if (changed || forceCompile) queueCompile(); if (changed || forceCompile) queueCompile(forceCompile);
} }
function replaceSourceRange(text, start, end, selectionStart, selectionEnd, direction) { function replaceSourceRange(text, start, end, selectionStart, selectionEnd, direction) {
@@ -415,7 +421,7 @@ async function openProject() {
event.preventDefault(); event.preventDefault();
indentSource(); indentSource();
}); });
queueCompile(0); queueCompile(true);
} catch (failure) { } catch (failure) {
showError(failure.message); showError(failure.message);
} }
+35 -15
View File
@@ -716,23 +716,30 @@ impl PublishedCheckpoints {
cancellation, cancellation,
&mut attempt, &mut attempt,
Some(Box::new(|world, preparation| { Some(Box::new(|world, preparation| {
let mut rejection = None; // Only the first candidate passed the immutable project
let remaining = std::iter::from_fn(|| candidates.pop_front()); // and entry-prefix checks before arriving at this host.
for candidate in std::iter::once(first).chain(remaining) { let guard = first.guard();
match candidate 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) .accept_entry(project)
.and_then(|()| candidate.guard().verify(request, world, preparation)) .and_then(|()| candidate.guard().verify(request, world, preparation))
.is_ok()
{ {
Ok(()) => { selected = Some(candidate);
selected = Some(candidate); return Ok(());
return Ok(());
}
Err(error) => {
rejection.get_or_insert(error);
}
} }
} }
Err(rejection.unwrap_or_else(|| "no entry checkpoint retained".into())) Err(rejection)
})), })),
EffectMode::Draft, EffectMode::Draft,
KernelPreparation::Resume, KernelPreparation::Resume,
@@ -1358,6 +1365,11 @@ impl PrefixInputGuard {
)); ));
} }
} }
self.verify_clock_environment()?;
Ok(current)
}
fn verify_clock_environment(&self) -> Result<(), String> {
if self if self
.clock_environment .clock_environment
.as_ref() .as_ref()
@@ -1365,7 +1377,7 @@ impl PrefixInputGuard {
{ {
return Err("checkpoint file-date environment changed".into()); return Err("checkpoint file-date environment changed".into());
} }
Ok(current) Ok(())
} }
fn verify_replayed_inputs(&self, files: &Files, current: &ProjectSnapshot) -> Result<(), CompileError> { fn verify_replayed_inputs(&self, files: &Files, current: &ProjectSnapshot) -> Result<(), CompileError> {
@@ -1397,11 +1409,19 @@ impl PrefixInputGuard {
world: &FileWorld, world: &FileWorld,
preparation: &HostPreparation, preparation: &HostPreparation,
) -> Result<(), String> { ) -> 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 { if self.format_input_bindings != world.trace().format_input_bindings {
return Err("checkpoint format input bindings changed".into()); 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()); return Err("checkpoint entry resolved to a different path".into());
} }
let current = preparation let current = preparation