Peak memory is 2× QuickJS: arena reservation, startup floor and representation

未关闭
#158 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
rust

调研方向

Start by reviewing the heap reservation and collection logic, then measure the empty-script RSS floor and object-heavy benchmark cases named in the issue. The issue gives no file paths or test commands, so first locate the arena and startup allocation code and reproduce the reported measurements. Done means peak RSS is within 1.3× QuickJS across the 37 programs while runtime stays within 2% of today's.

由索引模型根据 Issue 内容生成。

描述

Peak RSS of 0.3.0 is about twice QuickJS 2026-06-04's on the 37 fixed-work programs (median of 3, Ryzen 7 7840HS):

Suite Peak RSS, oxide / QuickJS
V8 v7 (8) 2.09
Octane 2.0 (15) 1.83
AWFY (14) 2.19
all 37 2.02

Time on the same programs is 1.03× QuickJS's, so the two together are the trade to improve. (CodeLoad, 9.6×, is a separate leak: #156.)

The collection threshold is not the cause

Halving --min-heap-mib from 4 (default) to 2, same binary, interleaved, 2 runs per program:

Suite time, 2 MiB / 4 MiB peak RSS, 2 MiB / 4 MiB RSS vs QuickJS at 2 MiB
V8 v7 1.006 0.979 2.04
Octane 0.985 0.958 1.75
AWFY 1.002 0.906 2.00
all 37 0.996 0.942 1.90

Time does not change (largest: NBody +4%); memory drops only 6%.

Where it goes: AWFY Bounce

Live data is 215 KiB. QuickJS peaks at 4.4 MiB.

--min-heap-mib collections heap reserved peak RSS
4 2 7,948 KiB 12.4 MiB
2 4 4,090 KiB 10.3 MiB
1 9 2,161 KiB 9.1 MiB
  1. Reserved is twice the threshold. At the 4 MiB threshold the heap reserves 7.9 MiB: object slots have 3.3× the capacity of the live count at the peak and value slots 3.3× (--memory-report: objects 20,679 live of 68,725, values 107,607 of 358,320). The threshold counts used bytes; the arenas grow by more than that, and the free slots are split by size class.
  2. About 7 MiB outside the heap even at a 1 MiB threshold: the empty-script floor is 5.1 MiB against QuickJS's 3.3 MiB (binary pages touched, the realm's builtins, atoms), plus compiler allocations (the stack-code intermediate of #154) that malloc keeps.
  3. Object representation in object-heavy programs: Splay 264.6 vs 144.0 MiB, Earley-Boyer 24.9 vs 14.6 MiB.

Direction

  • Count reserved bytes, not used bytes, toward the threshold, and grow arenas in steps bounded by it; return empty arena chunks after a collection.
  • Measure and cut the startup floor (lazy builtins, atom table sizing).
  • Release compile-time allocations (follows from #154).

Acceptance: peak RSS within 1.3× of QuickJS over the 37 programs (geometric mean) with time within 2% of today's.

主要语言
Rust
星标
61
派生
2
PR 合并指标
30 天内没有已合并 PR

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pocket-stack/quickjs-oxide 的其他 Issue

查看 pocket-stack/quickjs-oxide 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。