feat(profiling): add runtime diagnostics and external benchmark baseline - #5
feat(profiling): add runtime diagnostics and external benchmark baseline#5Eric-Song-Nop wants to merge 21 commits into
Conversation
|
本 PR 及关联 issue #4 的结果总结,补充后续 CPU 调查。 / Results for this PR and tracking issue #4, including the follow-up CPU investigation. Benchmark 与 profiling 结果 / Benchmark and profiling results — 2026-09-09已完成 benchmark 基线、工作负载隔离、CPU 采样和定向计数。主要优化候选是属性名重复 intern、普通对象提前执行数组键处理、通用数值转换、引用清理检查和 Context 布局初始化。本轮尚未实施或验证算法优化。 The benchmark baseline, workload isolation, CPU sampling and targeted counters are complete. Main optimization candidates are repeated property-key interning, array-key work on ordinary objects, generic numeric conversion, reference-cleanup checks and Context layout initialization. No algorithm optimization has been implemented or measured yet. 1. 测量环境 / Measurement environment所有构建与测量在同一 PocketLab 机器串行执行:Ryzen 7 7840HS、Linux 6.18.44-1-lts、Rust 1.94.1 release 构建,对照 QuickJS 2026-06-04;外部 benchmark 固定为 Builds and measurements ran serially on the same PocketLab machine: Ryzen 7 7840HS, Linux 6.18.44-1-lts, Rust 1.94.1 release builds, against QuickJS 2026-06-04, using 2. Benchmark 基线 / Benchmark baseline同计时器微基准 / Matched-clock microbench
30 次运行全部成功。表格是三次 harness 最小 ns/op 估计的中位数;两引擎均验证使用 All 30 runs passed. Values are medians of three harness-reported minimum ns/op estimates; both engines verified the 固定工作量对照 / Fixed-workload comparison
这是后续实验,去掉自校准 harness,执行相同固定函数体。数字为三次完整进程墙钟时间的中位数,包含启动、编译和收尾,不能与上表混为同一次 ns/op 测量。 This follow-up removes the adaptive harness and executes identical fixed function bodies. Values are median whole-process wall times over three runs, including startup, compilation and teardown; they are a separate experiment from the ns/op table. V8 v7 独立子测试 / Isolated V8 v7 suites
分数越高越好。Oxide 的四项成功子测试、QuickJS 的所有子测试均成功 3/3 次。不生成缺项总分,不从超时推断精确倍率、死循环或语法不支持。本轮没有对四个超时子测试采样。 Higher scores are better. The four successful Oxide suites and every QuickJS suite completed 3/3 runs. No incomplete aggregate score is reported; timeouts do not establish a precise ratio, infinite loop or unsupported syntax. The four timed-out suites were not CPU-profiled in this follow-up. 3. 内存、生命周期和诊断开销 / Memory, lifecycle and diagnostic overhead
Dump 的观测中位时间高 7.6%,包括输出 I/O;其他模式的范围重叠,不能承诺零开销。内存数字只覆盖部分拥有的存储,排除嵌套分配与 allocator 开销;总内存、峰值和 RSS 不可用。Trace 是 Vec 存储变化,不是物理 malloc/realloc 追踪;Runtime 销毁后 arena 容量归零。Context drop 仅测量该 API 边界,保留的 realm 环在 Runtime drop 清理。QuickJS 生命周期使用不同类型时钟,未计算跨时钟倍率。 Dump's observed median was 7.6% higher, including output I/O; overlapping ranges for other modes do not establish zero overhead. Memory accounting covers only partial owned storage, excluding nested allocations and allocator overhead; total memory, peak and RSS are unavailable. Trace records Vec storage transitions, not physical malloc/realloc calls; arena capacity reached zero after Runtime destruction. Context drop measures only that API boundary; retained realm cycles are cleaned up during Runtime drop. No ratio is computed against QuickJS lifecycle measurements using a different clock type. 4. CPU 热点与计数 / CPU hotspots and counters使用未加诊断探针的源码构建,release + frame pointers, CPU samples used release builds from source without diagnostic probes, with frame pointers and
补充:固定属性读取约构造 8,000 万个 UTF-16 迭代器,输入全部为平坦字符串,rope 为零;迭代器析构 self 7.97%。先减少重复 intern,再重新判断字符串迭代/哈希特化的必要性。 Additionally, fixed property reads constructed about 80 million UTF-16 iterators, all for flat strings, with zero rope inputs; iterator destruction was 7.97% self time. Re-measure after reducing redundant interning before deciding on further string-iteration/hash specialization. 原始 Richards harness 的粗阶段中位时间:Context 2.842 ms、编译 13.426 ms、执行 9,675.615 ms,主要成本在执行。执行边界仍包含 warmup、harness 和输出,不是纯 steady-state。原自校准空循环 harness 还带入了循环体本身没有的属性访问,因此增加固定工作量实验来减少干扰。 Original Richards harness coarse phase medians: Context 2.842 ms, compilation 13.426 ms, execution 9,675.615 ms: execution dominates. That boundary includes warmup, harness and output, not pure steady state. The adaptive empty-loop harness introduced property accesses absent from the loop body, motivating fixed-workload measurements. 5. 限制、验证和后续 / Limits, validation and next steps
6. 报告和证据 / Reports and evidence
以上链接固定到报告提交 Links are pinned to report commit SHA-256:
|
Adds opt-in memory snapshots, bounded arena backing-storage tracing, lifecycle timing, and reproducible external benchmark runners. CLI supports
-d,-T,-q -dand JSONL output, with explicit partial accounting and unavailable values. External benchmark sources and generated bundles stay outside this repository.Depends on #2 (
refact/clean-up-structure, 9fa0e9d). This draft targets upstreammain, so its current diff also includes the changes from #2. Keep this PR unmerged until #2 lands, then update this branch to leave only the profiler changes. Implements the profiling plan introduced in #2. See docs/profiling.md and docs/reports/profiler-baseline.md / .json for usage, exact revisions, hashes, all measurements and limitations.Validation ran on eric-83am / PocketLab: 2,993 Rust tests pass, one existing ignored; pinned Rust 1.88 strict Clippy, CLI feature tests, source gates and six Python runner tests pass. All 102,037 Test262 outcome rows match PR #2; the frozen full-file checksum gate still fails because the source fingerprint changes the header. No baseline was silently updated.
All five selected matched-clock microbench cases pass. Four of eight isolated V8 v7 suites complete all three repetitions in Oxide; Crypto, Earley-Boyer, RegExp and Navier-Stokes time out at 90 seconds in every repetition. Native QuickJS completes all suites. No incomplete aggregate score is reported. The first mixed-clock microbench experiment is explicitly excluded. Profiler coverage is partial arena storage, not a full allocator or CPU sampler.
Raw evidence archive SHA-256: 19120bc1f848dc1f7c17347de4efab5aba7c3d56e0246c864a48a4a302444e06. Numerical evidence is tracked in the report JSON; the raw archive is retained in the local and remote workspace target directories.