Maintain command source bounds across checkpoint revisions

This commit is contained in:
gloamxun committed 2026-12-02 02:38:43 +08:00
1 parent c8f7a0cbe6
commit 65bf302f5f
3 files changed
+70 -21

No files matched your search

+10 -12
View File
@@ -810,20 +810,20 @@ type CommandEntries = HashMap<Arc<CommandName>, Meaning, RandomState>;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
struct CommandShard { struct CommandShard {
entries: CommandEntries, entries: CommandEntries,
// Bounds may retain ranges of replaced or removed entries. Their only // Keep conservative bounds as each meaning is installed. Checkpoints
// use is to prove that every surviving token is before an edit. // share the bounds along with the entries, so proving a source move does
source_bounds: OnceLock<BTreeMap<usize, Option<usize>>>, // not have to discover them from every macro body in each donor.
// Replacing or removing an entry may retain its bound.
source_bounds: BTreeMap<usize, Option<usize>>,
} }
impl CommandShard { impl CommandShard {
fn new(entries: CommandEntries) -> Self { fn new(hasher: RandomState) -> Self {
Self { entries, source_bounds: OnceLock::new() } Self { entries: CommandEntries::with_hasher(hasher), source_bounds: BTreeMap::new() }
} }
fn insert(&mut self, name: Arc<CommandName>, meaning: Meaning) -> Option<Meaning> { fn insert(&mut self, name: Arc<CommandName>, meaning: Meaning) -> Option<Meaning> {
if let Some(bounds) = self.source_bounds.get_mut() { source_relocation::include_meaning_bounds(&mut self.source_bounds, &meaning);
source_relocation::include_meaning_bounds(bounds, &meaning);
}
self.entries.insert(name, meaning) self.entries.insert(name, meaning)
} }
@@ -831,9 +831,7 @@ impl CommandShard {
let hashbrown::hash_map::Entry::Vacant(entry) = self.entries.entry(name) else { let hashbrown::hash_map::Entry::Vacant(entry) = self.entries.entry(name) else {
return false; return false;
}; };
if let Some(bounds) = self.source_bounds.get_mut() { source_relocation::include_meaning_bounds(&mut self.source_bounds, &meaning);
source_relocation::include_meaning_bounds(bounds, &meaning);
}
entry.insert(meaning); entry.insert(meaning);
true true
} }
@@ -869,7 +867,7 @@ impl Default for CommandBindings {
let hasher = command_hasher(); let hasher = command_hasher();
Self { Self {
shards: std::array::from_fn(|_| { shards: std::array::from_fn(|_| {
Arc::new(CommandShard::new(CommandEntries::with_hasher(hasher.clone()))) Arc::new(CommandShard::new(hasher.clone()))
}), }),
revisions: [0; COMMAND_SHARDS], revisions: [0; COMMAND_SHARDS],
ordered_names: Arc::default(), ordered_names: Arc::default(),
@@ -104,14 +104,7 @@ impl State {
impl CommandShard { impl CommandShard {
fn preserves_source_spans(&self, relocation: &SourceRelocation) -> bool { fn preserves_source_spans(&self, relocation: &SourceRelocation) -> bool {
let bounds = self.source_bounds.get_or_init(|| { self.source_bounds.get(&relocation.source()).is_none_or(|end| {
let mut bounds = BTreeMap::<usize, Option<usize>>::new();
for meaning in self.entries.values() {
include_meaning_bounds(&mut bounds, meaning);
}
bounds
});
bounds.get(&relocation.source()).is_none_or(|end| {
end.is_some_and(|end| relocation.preserves_prefix_through(end)) end.is_some_and(|end| relocation.preserves_prefix_through(end))
}) })
} }
@@ -170,10 +163,13 @@ fn command_bounds_track_redefinitions_and_invocation_origins() {
let mut state = State::default(); let mut state = State::default();
state.define(name.clone(), meaning(None), true); state.define(name.clone(), meaning(None), true);
state.relocate_source(&mut EventRelocation::new(&map)).unwrap(); let shard = CommandBindings::shard_index(command_hasher().hash_one(&name));
assert_eq!(state.commands.shards[shard].source_bounds[&0], Some(1));
let before = state.clone(); let before = state.clone();
let token_span = Span { source: 0, start: 8, end: 9 }; let token_span = Span { source: 0, start: 8, end: 9 };
state.define(name.clone(), meaning(Some(token_span)), true); state.define(name.clone(), meaning(Some(token_span)), true);
assert_eq!(state.commands.shards[shard].source_bounds[&0], Some(9));
state.relocate_source(&mut EventRelocation::new(&map)).unwrap(); state.relocate_source(&mut EventRelocation::new(&map)).unwrap();
let mapped = map.relocate_span(token_span).unwrap(); let mapped = map.relocate_span(token_span).unwrap();
assert_ne!(mapped, token_span); assert_ne!(mapped, token_span);
+55
View File
@@ -299,6 +299,61 @@ Edge 的网络记录匹配全部 60 次请求,全部复用连接。发完请
条件仍开放。完整输入、输出与时序在 条件仍开放。完整输入、输出与时序在
`target/p4-a4-shared-accounting-release/edge-a4-6tx6u3sb/`。 `target/p4-a4-shared-accounting-release/edge-a4-6tx6u3sb/`。
## 2026-12-02 A4 状态核对与浏览器等待的拆分
`ccb278f` 的同一 Opt3 原生执行器在三次 A4 子文件编辑中
通过独立全量核验,后两次各跳过 20,618 步。硬件计数器测得成功
接缝的状态核对 CPU 时间分别为 26.40、25.31 ms,保留记账为
20.94、19.77 ms。状态核对的 16 条采样栈中有 10 条首次遍历
宏替换文本以建立分片的来源范围,另外 6 条在精确比较中查找命令名。
组装也观察到首次建立范围。采样表与调用栈位于
`target/p4-a4-shared-accounting-release/a4-child-only/cpu-profile/`。
项目 Web 用同一二进制诊断主、子文件各六次。12 次的 PDF、SVG、
变更页和来源映射与上一轮同输入一致。响应完成到 JSON 可用的中位数
为 3.85 / 3.35 ms,SVG 解码为 17.30 / 14.60 ms,替换 DOM 后到
首帧为 14.90 / 14.20 ms。本轮未再观察到上一轮约 300 ms 的响应
后等待。分段样本保存在 `target/p4-browser-presentation-attribution/`。
隔离 HTTP 对照在同一个 Windows Edge 轮流请求 Windows 和 WSL
本地端点,已在两种路径上复现浏览器响应头残差。Windows 本地边界
对照用 24 次连接复用请求,测试 GET 和 JSON POST,每种各有六次
开启 CDP 网络事件、六次关闭。JSON POST 的中位残差分别为
39.64 和 34.96 ms,服务器收到请求头到取得正文耗时 8.08 和
8.87 ms,回复就绪到浏览器记录响应头为 31.43 和 23.42 ms。
两组 GET 发送相同长度的回复正文,残差为 18.22 和 21.89 ms。
这些时间没有经过原生编译,直接定位浏览器请求等待,不参与
100 ms 的页面验收。原始脚本和样本在
`target/p4-browser-timing-attribution/`。
将命令分片的保守来源范围随绑定安装维护。格式反序列化、重定义、
分组恢复和换算后的宏都经过相同路径。移除的绑定可以保留旧上界,
因此无法证明不移动时仍会检查实际内容。排序、格式、指纹及宏
分配别名保持按原逻辑核对。
同配置 Opt3 前后各三次子文件编辑与独立全量一致,前后指纹、
读轨迹、PDF、SVG 和 aux 逐项相同,两次成功接缝各跳过 20,618 步。
成功接缝的状态核对从 27.76 / 27.01 ms 降至 11.44 / 10.10 ms,
总内核核验从 74.01 / 61.19 ms 降至 38.79 / 38.62 ms。新增的
可选诊断显示两次实际来源换算分别为 0.07、0.03 ms,剩下的精确
状态比较为 11.01、9.91 ms。恢复时执行器克隆约 1 ms,每次热
编辑的六次捕获克隆合计 5.21–7.68 ms。全程 I/O 等待偏高,
每版一次的最初编译为 3.25 与 3.83 s,这组数据不能判定完整
冷启动影响。另用同一格式在各三个新进程单独测解码,扣除输入
读取后,线程 CPU 中位数由 1,097.83 升至 1,115.83 ms,
墙钟中位数由 1,104.56 升至 1,118.32 ms。三项核心测试和四项
管线测试通过,覆盖宏来源、别名、重读子文件、拒绝草稿后的恢复
和 XeTeX UTF-16 整行编辑。配对证据在
`target/p4-a4-checkpoint-attribution/`。
Windows 全部本地的另一轮对照使用同样的 682 字节请求及
145,000 字节回复,分别以 HTTP POST 和一条已建立的 WebSocket
交替收取完整回复。每种等待配置各四对。扣除实际服务耗时,
无等待组的中位残差从 34.25 降到 5.89 ms,80 ms 等待组从
50.55 降到 18.71 ms。该结果用于选择传输试验,项目 Web 的页面
呈现门槛仍开放。回执为
`target/p4-browser-timing-attribution/websocket-vs-post-report.json`。
## 2026-12-02 XeTeX 整行编辑复用 ## 2026-12-02 XeTeX 整行编辑复用
XeTeX 扫描器保留已读物理行采用的分行规则。UTF-8、Bytes 及其他 XeTeX 扫描器保留已读物理行采用的分行规则。UTF-8、Bytes 及其他