Comprehension macros are O(n²) in cel-rust 0.14.5; upstream fix for `map` is on master
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
调研方向
等待 cel-rust 0.14.6 或 0.15,然后升级它并重新运行 #45 原型的 bench.py 中的 cs/c 用例。检查上游对 map 的修复是否也涵盖 filter、all、exists 和 exists_one;在 tests/test_performance_verification.py 中添加包含 10,000 个元素的性能检查,如果大型列表推导仍然很慢,则更新标准库参考。
由索引模型根据 Issue 内容生成。
描述
Found while benchmarking for #45. Executing items.filter(i, i % 3 == 0).map(i, i * i).size() against a Context holding an int list scales quadratically with the list length (release build, min of repeats):
| elements | time per execute |
|---|---|
| 1,000 | 17 ms |
| 2,000 | 66 ms |
| 4,000 | 251 ms |
| 8,000 | 940 ms |
| 20,000 | 5.8 s |
Each doubling costs ~4×. cel-rust 0.14.5's comprehension macros rebuild the accumulator list on every append (Value::List is an Arc<Vec<_>>, so appending clones the vector), which makes map/filter over anything beyond a few thousand elements unusable. Nothing in this wrapper contributes; a dict context and a Context behave identically.
Upstream already has the fix for map on master, unreleased: cel-rust/cel-rust#341 "perf(macros): map mutates List in place" (merged 2026-09-13, on top of "perf(map): Added mutable List used in map"). It is not clear from the PR title whether filter, all, exists and exists_one got the same treatment.
To do
- When the next cel-rust release (0.14.6 or 0.15) ships, bump and re-run the table above; add a test in
tests/test_performance_verification.pythat pins a comprehension over a 10,000-element list under a generous bound (say 200 ms) so a regression is caught. - If
filteris still quadratic after the bump, raise it upstream with the numbers. - Until then the standard-library reference should say that comprehensions over large lists are slow in the current cel-rust, since policy engines routinely filter lists of thousands of records.
Benchmark script: the cs/c cases in the #45 prototype's bench.py (measured on 4 cores).
- 主要语言
- Python
- 星标
- 43
- 派生
- 4
- 平均合并
- 12 小时 37 分钟
- 30 天内合并 PR
- 11
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
hardbyte/python-common-expression-language 的其他 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 5/5 一周以上 新手友好度 35/100
-
enhancement
难度 4/5 3-5 天 新手友好度 48/100
-
enhancement
难度 5/5 一周以上 新手友好度 45/100
-
enhancement
难度 4/5 3-5 天 新手友好度 48/100
查看 hardbyte/python-common-expression-language 的全部 Issue
相似的 Issue
-
agent-ready documentation needs-triage
难度 1/5 1-3 小时 新手友好度 88/100
-
documentation
难度 1/5 1 小时以内 新手友好度 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
-
instance instance add
难度 1/5 1 小时以内 新手友好度 72/100
searxng/searx-instances#939 · 1 条评论 ·
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100