Count shared command shards once during suffix verification
This commit is contained in:
1 parent
7981493caf
commit
ccb278fceb
3 files changed
+86
-21
No files matched your search
@@ -276,9 +276,9 @@ impl Executor {
|
|||||||
}
|
}
|
||||||
let (history, old_history) =
|
let (history, old_history) =
|
||||||
Self::collect_event_usage_pair(&self.events, &old.events, collector());
|
Self::collect_event_usage_pair(&self.events, &old.events, collector());
|
||||||
let mut live = collector().tracking_aliases();
|
let (live, old_live) = self.state.collect_compared_statistics(
|
||||||
let mut old_live = collector().tracking_aliases();
|
&old.state, collector().tracking_aliases(),
|
||||||
self.state.collect_compared_statistics(&old.state, &mut live, &mut old_live)?;
|
)?;
|
||||||
let mut live = self.collect_live_usage(None, None, live);
|
let mut live = self.collect_live_usage(None, None, live);
|
||||||
let old_live = old.collect_live_usage(None, None, old_live);
|
let old_live = old.collect_live_usage(None, None, old_live);
|
||||||
// The splice translates the cumulative counters separately.
|
// The splice translates the cumulative counters separately.
|
||||||
|
|||||||
@@ -1192,6 +1192,50 @@ fn cached_macro_fingerprint_preserves_aliases_mutations_and_uncached_hashes() {
|
|||||||
assert_eq!(state.fingerprint(), uncached);
|
assert_eq!(state.fingerprint(), uncached);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn paired_statistics_keep_aliases_from_changed_to_shared_command_shards() {
|
||||||
|
use super::statistics::Collector;
|
||||||
|
|
||||||
|
let body = Arc::new(Macro {
|
||||||
|
prefix: Vec::new(),
|
||||||
|
parameters: Vec::new(),
|
||||||
|
parameter_chars: Vec::new(),
|
||||||
|
replacement: Vec::new(),
|
||||||
|
long: false,
|
||||||
|
outer: false,
|
||||||
|
protected: false,
|
||||||
|
});
|
||||||
|
let independent = Arc::new(body.as_ref().clone());
|
||||||
|
let first = CommandName::Control("common-definition".into());
|
||||||
|
let second = CommandName::Control("other-common-definition".into());
|
||||||
|
let shard = |name: &CommandName| CommandBindings::shard_index(command_hasher().hash_one(name));
|
||||||
|
let shared_shards = [shard(&first), shard(&second)];
|
||||||
|
let edited = (0..128)
|
||||||
|
.map(|index| CommandName::Control(format!("edited-alias-{index}")))
|
||||||
|
.find(|name| !shared_shards.contains(&shard(name)))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let mut prior = State::default();
|
||||||
|
prior.define(first, Meaning::Macro(body.clone()), true);
|
||||||
|
prior.define(second, Meaning::Macro(independent.clone()), true);
|
||||||
|
prior.define(edited.clone(), Meaning::Macro(body), true);
|
||||||
|
let mut current = prior.clone();
|
||||||
|
current.define(edited, Meaning::Macro(independent), true);
|
||||||
|
assert_eq!(current, prior);
|
||||||
|
|
||||||
|
let history = Collector::default();
|
||||||
|
let (new_counts, old_counts) = current
|
||||||
|
.collect_compared_statistics(&prior, Collector::default().tracking_aliases())
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(new_counts.usage, old_counts.usage);
|
||||||
|
assert!(!new_counts.has_equivalent_history(&old_counts, &history, &history));
|
||||||
|
|
||||||
|
let (same, old_counts) = prior
|
||||||
|
.collect_compared_statistics(&prior, Collector::default().tracking_aliases())
|
||||||
|
.unwrap();
|
||||||
|
assert!(same.has_equivalent_history(&old_counts, &history, &history));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command_snapshots_share_unmodified_shards_and_keep_ordered_identity() {
|
fn command_snapshots_share_unmodified_shards_and_keep_ordered_identity() {
|
||||||
let mut state = State::initex().with_etex();
|
let mut state = State::initex().with_etex();
|
||||||
@@ -1718,31 +1762,42 @@ impl State {
|
|||||||
pub(super) fn collect_compared_statistics(
|
pub(super) fn collect_compared_statistics(
|
||||||
&self,
|
&self,
|
||||||
old: &Self,
|
old: &Self,
|
||||||
current_usage: &mut super::statistics::Collector,
|
mut current_usage: super::statistics::Collector,
|
||||||
old_usage: &mut super::statistics::Collector,
|
) -> Option<(super::statistics::Collector, super::statistics::Collector)> {
|
||||||
) -> Option<()> {
|
let mut old_usage = if current_usage.material_only() {
|
||||||
if !current_usage.material_only() {
|
current_usage.clone()
|
||||||
let entries = old.commands.len();
|
} else {
|
||||||
current_usage.usage.state.command_entries = entries;
|
let pairs = self.commands.shards.iter().zip(&old.commands.shards);
|
||||||
old_usage.usage.state.command_entries = entries;
|
current_usage.usage.state.command_entries = old.commands.len();
|
||||||
// The alias proof needs corresponding visits, so both sides
|
for (current, prior) in pairs.clone() {
|
||||||
// walk the donor's binding order. Hashing and serialization
|
|
||||||
// still use the independent, sorted command order.
|
|
||||||
for (current, prior) in self.commands.shards.iter().zip(&old.commands.shards) {
|
|
||||||
if current.entries.len() != prior.entries.len() {
|
if current.entries.len() != prior.entries.len() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let shared = Arc::ptr_eq(current, prior);
|
if Arc::ptr_eq(current, prior) {
|
||||||
|
for (name, meaning) in &prior.entries {
|
||||||
|
Self::collect_command_statistics(&mut current_usage, name, meaning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Both alias walks start with the exact same live allocations.
|
||||||
|
// Copy their ordinals before counting the remaining bindings so
|
||||||
|
// a later alias to a shared macro still has the original ordinal.
|
||||||
|
let mut old_usage = current_usage.clone();
|
||||||
|
for (current, prior) in pairs {
|
||||||
|
if !Arc::ptr_eq(current, prior) {
|
||||||
for (name, old_meaning) in &prior.entries {
|
for (name, old_meaning) in &prior.entries {
|
||||||
let meaning = if shared { old_meaning } else { current.entries.get(name)? };
|
let meaning = current.entries.get(name)?;
|
||||||
Self::collect_command_statistics(current_usage, name, meaning);
|
Self::collect_command_statistics(&mut current_usage, name, meaning);
|
||||||
Self::collect_command_statistics(old_usage, name, old_meaning);
|
Self::collect_command_statistics(&mut old_usage, name, old_meaning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.collect_state_storage(current_usage);
|
old_usage
|
||||||
old.collect_state_storage(old_usage);
|
};
|
||||||
Some(())
|
self.collect_state_storage(&mut current_usage);
|
||||||
|
old.collect_state_storage(&mut old_usage);
|
||||||
|
Some((current_usage, old_usage))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_command_statistics(
|
fn collect_command_statistics(
|
||||||
|
|||||||
@@ -262,6 +262,16 @@ Edge 的余量需继续按浏览器请求和响应调度分解。
|
|||||||
峰值 RSS 为 618,732 KiB。100 ms 门槛仍开放。
|
峰值 RSS 为 618,732 KiB。100 ms 门槛仍开放。
|
||||||
原始浏览器、构建和直连对照在 `target/p4-a4-child-release/`。
|
原始浏览器、构建和直连对照在 `target/p4-a4-child-release/`。
|
||||||
|
|
||||||
|
## 2026-12-02 共享命令分片的记账
|
||||||
|
|
||||||
|
事件历史与执行状态的跨接缝证明仍核对分配别名。两版共享同一
|
||||||
|
命令分片时只走一次已共享绑定,再从该遍历的别名序号出发分别
|
||||||
|
统计两版独立分片和活动状态。单测证明两版宏值及计数完全相等时,
|
||||||
|
跨分片别名指向另一个同值宏仍会拒绝复用。五项内核单测及五项管线
|
||||||
|
回归通过,覆盖重复子文件读取、盒计数、不同长度的事件历史、
|
||||||
|
连续检查点和 XeTeX UTF-16 整行编辑。验证原始记录在
|
||||||
|
`target/p4-shared-shard-accounting/`。浏览器时延待同配置发布构建实测。
|
||||||
|
|
||||||
## 2026-12-02 XeTeX 整行编辑复用
|
## 2026-12-02 XeTeX 整行编辑复用
|
||||||
|
|
||||||
XeTeX 扫描器保留已读物理行采用的分行规则。UTF-8、Bytes 及其他
|
XeTeX 扫描器保留已读物理行采用的分行规则。UTF-8、Bytes 及其他
|
||||||
|
|||||||
Reference in new issue
Block a user