Share native format and checkpoint source bytes
This commit is contained in:
1 parent
11c8ad1eaa
commit
c09d545da6
7 files changed
+44
-23
No files matched your search
@@ -208,7 +208,7 @@ pub struct Executor {
|
||||
line_break_cache: Option<std::sync::Arc<super::LineBreakCache>>,
|
||||
interaction_mode: u8,
|
||||
inputs: Vec<InputFrame>,
|
||||
sources: Vec<SourceFile>,
|
||||
sources: Vec<Arc<SourceFile>>,
|
||||
stream_sources: BTreeSet<usize>,
|
||||
generated_inputs: std::collections::BTreeMap<usize, GeneratedInput>,
|
||||
reads: BTreeSet<Dependency>,
|
||||
@@ -362,7 +362,7 @@ impl EntryCheckpoint {
|
||||
unreachable!("entry checkpoints start with the physical source frame");
|
||||
};
|
||||
mouth.rebind_loaded_prefix(source.data.clone());
|
||||
executor.sources[self.entry] = source;
|
||||
executor.sources[self.entry] = Arc::new(source);
|
||||
let result = executor
|
||||
.check_cancellation()
|
||||
.and_then(|_| executor.run_active_input(self.initial_depth, files, capture_boundary));
|
||||
@@ -472,7 +472,7 @@ impl Executor {
|
||||
executor.fresh_job = false;
|
||||
executor.job_name = execution.job_name;
|
||||
executor.interaction_mode = execution.interaction_mode;
|
||||
executor.sources = execution.sources;
|
||||
executor.sources = execution.sources.into_iter().map(Arc::new).collect();
|
||||
executor.stream_sources = execution.stream_sources;
|
||||
executor.generated_inputs = execution.generated_inputs;
|
||||
executor.split_discards = execution.split_discards;
|
||||
@@ -483,7 +483,7 @@ impl Executor {
|
||||
}
|
||||
pub(super) fn new_format_job(
|
||||
state: State,
|
||||
sources: Vec<SourceFile>,
|
||||
sources: Vec<Arc<SourceFile>>,
|
||||
stream_sources: BTreeSet<usize>,
|
||||
generated_inputs: std::collections::BTreeMap<usize, GeneratedInput>,
|
||||
limits: Limits,
|
||||
@@ -605,7 +605,7 @@ impl Executor {
|
||||
let mouth = Mouth::with_encoding(
|
||||
source, file.data.clone(), profile, &self.state.xe_default_encoding,
|
||||
);
|
||||
self.sources.push(file);
|
||||
self.sources.push(Arc::new(file));
|
||||
self.reads.insert(Dependency::Source(source));
|
||||
self.inputs.push(InputFrame::Source {
|
||||
source,
|
||||
@@ -2900,10 +2900,10 @@ impl Executor {
|
||||
.map_err(|e| self.error(e, self.current))?
|
||||
{
|
||||
let source = self.sources.len();
|
||||
self.sources.push(SourceFile {
|
||||
self.sources.push(Arc::new(SourceFile {
|
||||
name,
|
||||
data: Vec::new(),
|
||||
});
|
||||
}));
|
||||
self.stream_sources.insert(source);
|
||||
let xe_encoding = (self.state.input_profile() == InputProfile::XeTeX).then(|| {
|
||||
self.reads.insert(Dependency::XeDefaultInputEncoding);
|
||||
@@ -2968,7 +2968,7 @@ impl Executor {
|
||||
}
|
||||
let base = self.sources[source].data.len();
|
||||
let line = line.unwrap_or_default();
|
||||
self.sources[source].data.extend_from_slice(&line);
|
||||
Arc::make_mut(&mut self.sources[source]).data.extend_from_slice(&line);
|
||||
let end = self.sources[source].data.len();
|
||||
self.reads.insert(Dependency::EndLineChar);
|
||||
if readline {
|
||||
@@ -3306,7 +3306,7 @@ impl Executor {
|
||||
} else {
|
||||
ParagraphMode::Vertical
|
||||
},
|
||||
sources: self.sources,
|
||||
sources: self.sources.into_iter().map(Arc::unwrap_or_clone).collect(),
|
||||
stream_sources: self.stream_sources,
|
||||
generated_inputs: self.generated_inputs,
|
||||
reads: self.reads,
|
||||
@@ -3740,7 +3740,7 @@ impl Executor {
|
||||
})
|
||||
.collect();
|
||||
let evidence = ExecutionEvidence {
|
||||
sources: self.sources,
|
||||
sources: self.sources.into_iter().map(Arc::unwrap_or_clone).collect(),
|
||||
source_versions,
|
||||
stream_sources: self.stream_sources,
|
||||
generated_inputs: self.generated_inputs,
|
||||
@@ -3784,7 +3784,7 @@ impl Executor {
|
||||
io: self.io,
|
||||
input_position: self.input_position,
|
||||
paragraph_mode: ParagraphMode::Vertical,
|
||||
sources: self.sources,
|
||||
sources: self.sources.into_iter().map(Arc::unwrap_or_clone).collect(),
|
||||
stream_sources: self.stream_sources,
|
||||
generated_inputs: self.generated_inputs,
|
||||
reads: self.reads,
|
||||
|
||||
@@ -206,7 +206,7 @@ impl Executor {
|
||||
stream.xe_skip_lf =
|
||||
terminator == Some(13) && bom + length + framing.unit_width() == line.len();
|
||||
if empty_after_bom || skipped_lf {
|
||||
self.sources[source].data.extend_from_slice(&line);
|
||||
Arc::make_mut(&mut self.sources[source]).data.extend_from_slice(&line);
|
||||
} else {
|
||||
return Ok((Some(line), Some(encoding)));
|
||||
}
|
||||
@@ -350,10 +350,10 @@ impl Executor {
|
||||
let traced = self.read_parameter(Parameter::Tracingscantokens).width() > 0;
|
||||
let source = self.sources.len();
|
||||
let mouth = Mouth::generated(source, bytes.clone(), profile, separator);
|
||||
self.sources.push(SourceFile {
|
||||
self.sources.push(Arc::new(SourceFile {
|
||||
name: "<scantokens>".into(),
|
||||
data: bytes,
|
||||
});
|
||||
}));
|
||||
self.generated_inputs
|
||||
.insert(source, GeneratedInput { origin, separator });
|
||||
self.reads.insert(Dependency::Source(source));
|
||||
|
||||
@@ -27,7 +27,7 @@ pub struct FormatImage {
|
||||
schema: u32,
|
||||
engine: String,
|
||||
state: State,
|
||||
sources: Vec<SourceFile>,
|
||||
sources: Vec<Arc<SourceFile>>,
|
||||
#[serde(default)]
|
||||
stream_sources: BTreeSet<usize>,
|
||||
generated_inputs: BTreeMap<usize, GeneratedInput>,
|
||||
@@ -114,7 +114,7 @@ impl FormatImage {
|
||||
schema: SCHEMA,
|
||||
engine: ENGINE.into(),
|
||||
state,
|
||||
sources: execution.sources,
|
||||
sources: execution.sources.into_iter().map(Arc::new).collect(),
|
||||
stream_sources: execution.stream_sources,
|
||||
generated_inputs: execution.generated_inputs,
|
||||
resources,
|
||||
|
||||
@@ -138,7 +138,7 @@ impl FormatImage {
|
||||
if !self.generated_inputs.contains_key(&id)
|
||||
&& let Some(path) = bindings.get(Path::new(&source.name))
|
||||
{
|
||||
source.name = path.to_string_lossy().into_owned();
|
||||
Arc::make_mut(source).name = path.to_string_lossy().into_owned();
|
||||
}
|
||||
}
|
||||
for resource in &mut self.resources {
|
||||
|
||||
@@ -718,12 +718,12 @@ pub struct ExecutionFailure {
|
||||
|
||||
impl Error {
|
||||
fn at(
|
||||
sources: &[SourceFile],
|
||||
sources: &[impl std::borrow::Borrow<SourceFile>],
|
||||
profile: InputProfile,
|
||||
message: impl Into<String>,
|
||||
span: Span,
|
||||
) -> Self {
|
||||
let source = sources.get(span.source);
|
||||
let source = sources.get(span.source).map(std::borrow::Borrow::borrow);
|
||||
let name = source.map_or("<input>", |s| s.name.as_str()).to_owned();
|
||||
let prefix = source.map_or(&[][..], |s| &s.data[..span.start.min(s.data.len())]);
|
||||
let (mut line, mut column, mut carriage_return) = (1, 1, false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::{CatCode, CommandName, Dependency, Span, State, Token, TokenKind};
|
||||
use std::collections::BTreeSet;
|
||||
use std::{collections::BTreeSet, sync::Arc};
|
||||
|
||||
use super::xe_encoding::{Character, Encoding};
|
||||
|
||||
@@ -282,7 +282,7 @@ enum LineBreaks {
|
||||
#[derive(Clone)]
|
||||
pub(super) struct Mouth {
|
||||
source: usize,
|
||||
data: Vec<u8>,
|
||||
data: Arc<Vec<u8>>,
|
||||
profile: super::InputProfile,
|
||||
offset: usize,
|
||||
line: Vec<Character>,
|
||||
@@ -321,7 +321,7 @@ impl Mouth {
|
||||
}
|
||||
pub(super) fn rebind_loaded_prefix(&mut self, data: Vec<u8>) {
|
||||
debug_assert!(self.matches_loaded_prefix(&data));
|
||||
self.data = data;
|
||||
self.data = Arc::new(data);
|
||||
}
|
||||
pub(super) fn payload_bytes(&self) -> usize {
|
||||
self.data.len()
|
||||
@@ -351,7 +351,7 @@ impl Mouth {
|
||||
};
|
||||
Self {
|
||||
source,
|
||||
data,
|
||||
data: Arc::new(data),
|
||||
profile,
|
||||
offset,
|
||||
line: Vec::new(),
|
||||
|
||||
@@ -18,6 +18,27 @@
|
||||
| W6 会话 | 实施中 | 共享库/CLI 与当前原生文字/数学/规则来源进入公共结果;真实 A4 副本九类/27 revision 与独立干净作业页面/PDF/aux/映射一致,新增数学场景独立参考通过;详细失败/捕获重放及宿主/离线/CLI观察已通过;原子项目版本/已知生成初态及TeX流记录已接通;完整副作用/恢复契约、旧来源和性能仍缺 |
|
||||
| W7 总验收 | 未满足 | 原有和新增测试、原样项目、格式与会话门禁全部通过才能结项 |
|
||||
|
||||
## 2026-11-28 格式来源与检查点共享字节
|
||||
|
||||
格式镜像、从镜像创建的作业和检查点共享已有来源字节。输入游标为各次
|
||||
执行保留自己的位置及已解码行,共享尚在使用的输入缓冲。流追加和重新绑定
|
||||
格式路径时由修改方取得独立值。输入复验依然执行。来源索引、对外 SourceFile
|
||||
结构和格式序列化沿用既有契约,发布结果继续交付拥有的字节副本。
|
||||
|
||||
真实 schema104 格式含 54 份来源,共 5,172,047 字节。两版加载真实
|
||||
资源并重新编码,SHA-256 一致。调试构建各采五次,从格式创建作业的总
|
||||
分配量由 15,977,515 降至 10,799,961 字节,复制执行状态的总分配量由
|
||||
7,834,696 降至 2,657,142 字节。探针覆盖这两步的分配量。扫描和格式专项
|
||||
覆盖原始字节范围、活跃行、UTF-16 前瞻、恢复重绑、迁移后的文件身份与
|
||||
已消耗流范围。十三项定向检查通过。
|
||||
|
||||
原样 A4 主文件和子文件各一次连续编辑。两次都只刷新第 1 页,PDF、SVG、
|
||||
实际来源字节及指纹、来源映射、aux 和资源读取版本与独立全量一致。
|
||||
下一批定位发布时来源字节副本及完整字节比较的开销。
|
||||
|
||||
本地证据见 target/p4-shared-format-sources/。
|
||||
正式编辑到页面可见的时延和峰值内存按冻结版及原预算验收。
|
||||
|
||||
## 2026-11-28 Type 1 字形测量与 PDF 字体子集复用
|
||||
|
||||
Type 1 的实际轮廓和宽度按已校验的字体程序与变换跨修订复用。pdfTeX 的
|
||||
|
||||
Reference in new issue
Block a user