Repository navigation
fix: lazy-parse the learning resource to stay inside the memory budget - #231
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
show_wubi_learning=true时私有已提交 30.5–32.9 MiB(门禁 30)→ FAIL;关闭时为 28.8–28.9 MiB,差值就是一次性解析 3,000 条的开销。改成按需解析:常驻原始字节(~120 KB)+ 字→行区间索引,命中时解析单行并缓存最近 64 条;测试断言加载时零解析、单次查询只解析一条。
验证:
make verifyPASS、离线 62 文件 / 328 例 PASS、test-wubi-learning通过。