Skip to content

fix: lazy-parse the learning resource to stay inside the memory budget - #231

Merged
wangzhizhou merged 2 commits into
mainfrom
dev
Nov 7, 2026
Merged

wangzhizhou merged 2 commits into
mainfrom
dev

Conversation

@wangzhizhou

Copy link
Copy Markdown
Contributor

show_wubi_learning=true 时私有已提交 30.5–32.9 MiB(门禁 30)→ FAIL;关闭时为 28.8–28.9 MiB,差值就是一次性解析 3,000 条的开销。

改成按需解析:常驻原始字节(~120 KB)+ 字→行区间索引,命中时解析单行并缓存最近 64 条;测试断言加载时零解析、单次查询只解析一条。

验证:make verify PASS、离线 62 文件 / 328 例 PASS、test-wubi-learning 通过。

Diagnostic logging shows the controller receiving the chord, matching it, switching the learning
preference and never passing the event to inputText, so consumption works. The leak came from
Ghostty, which maps option chords to characters itself and does not honour the input method having
consumed the key; TextEdit and Terminal behave correctly. One press in nineteen failed to match as
the very first key after activation, which is noted as a separate small issue.

Signed-off-by: wangzhizhou <824219521@qq.com>
With the learning area enabled the host used two to four megabytes more private memory than the
budget allows, because the resource was decoded into three thousand structures on load. The store now
keeps the raw bytes and a character to line range index, parses a line only when that character is
looked up, and caches the most recent sixty four.

The learning test asserts the index covers three thousand characters while nothing is parsed at load,
and that a single lookup materialises exactly one entry.

Signed-off-by: wangzhizhou <824219521@qq.com>
@wangzhizhou
wangzhizhou merged commit e08402a into main Nov 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant