Repository navigation
perf(query): use Stile for per-candidate filtering on sealed IPC segments - #925
Open
luoxiaojian wants to merge 11 commits into
Open
luoxiaojian wants to merge 11 commits into
luoxiaojian wants to merge 11 commits into
Conversation
luoxiaojian
requested review from
JalinWang,
feihongxu0824 and
zhourrr
as code owners
November 23, 2026 06:22
Embed the Stile v0.1.0 interpreter and use it for single-stage candidate filtering over owning forward views. Keep the Arrow evaluator when a predicate is unsupported or exceeds the Stile compilation budget. Cover Arrow parity, virtual row IDs, independent chunk layouts, and fallback in the forward filter regression suite.
补齐生产后端选择、整表达式回退、错误恢复、差分语义及已编译谓词生命周期回归;固定来源与 Arrow 21 适配边界,增加可复用生产查询基准。 验证:九组 174 项本机测试通过,限定范围 ASan 75 项通过;Stile 通过 ASan/UBSan。与 PR905 精确基线完成三轮比较及五轮 bitmap 对照复测。全 DB UBSan 仍被既有倒排编码对齐问题阻断。
统一 Stile 源文件归属及兼容性提示,移除独立第三方项目声明,保留 Apache Arrow 来源。新增模块 README,说明 API、示例、回退策略、生命周期与生产接入边界。 验证:README 示例编译运行成功;三组相关回归测试全部通过;格式与 diff 检查通过。
Keep each immutable column index with its forward column snapshot. Synchronize the first successful build, allow retries after errors, and reuse the index across queries and projections. Compare both batch evaluation APIs with Arrow and cover concurrent preparation, DDL replacement, and index lifetime.
luoxiaojian
force-pushed
the
codex/stile-interpreter-main
branch
from
November 24, 2026 03:22
507217c to
7789d91
Compare
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.
改动
本 PR 优化向量和全文召回中的逐候选正排过滤。当规划器把一个 segment 的过滤条件从全部倒排转为全部正排时,召回过程会逐个检查候选行。对于能提供
ForwardReadView的已封存 IPC segment,DocFilter将绑定后的 Arrow 布尔表达式编译成 Stile 的只读求值树。Stile 按候选行号直接读取 Arrow 列缓冲区,省去逐行构造Scalar、ExecBatch和调用ExecuteScalarExpression的开销。ForwardColumn首次用于 Stile 时构建一份ColumnIndex。后续查询共享索引元数据,命中时无需获取构建锁。列值复用原有缓冲区,谓词仍按查询编译。DDL 换列后,已准备的查询继续持有原索引。LIKE,保留 TRUE、FALSE、NULL 三值逻辑。遇到不支持的子表达式或超过编译预算时,整条谓词回退到 Arrow。绑定和数据校验错误继续上报。性能
测试使用 1,000 万行只读 sealed IPC 数据,62 维 COSINE HNSW、INT8 量化,
ef=300、topk=21。过滤条件dataTime > 536870911命中 7,497,998 行(74.98%)。吞吐按 PythonCollection.query的端到端 QPS 计算,返回字段包含pid、mail和dataTime。相同逐候选计划下的吞吐
规划器按 segment 的估计命中比例决定是否把这个范围谓词从倒排转为正排。实验保留
dataTime的范围倒排索引,设置enable_range_optimization=True、invert_to_forward_scan_ratio=0,使三个版本均走逐候选过滤。每个平台在同一张 HNSW 图上交替运行三个提交,表中为四轮 QPS 中位数。ea1519a0)c21b4f93)3947ce89)在 Stile 已经直接读取列缓冲区的基础上,跨查询复用列索引又使 Linux 的 1、8 客户端 QPS 分别提高 20.5% 和 21.9%,macOS 两种并发度均提高 19.7%。
与 Gandiva JIT 的逐候选过滤对比
在共同基线
a26f8abe上,对比 Stile(7789d910)与从 #913 移植的 Gandiva JIT(c5774890)。两版在每个平台共用同一张 HNSW 图,所有谓词均包含dataTime > 536870911。表中为预热后的端到端 QPS 中位数(Linux 4 轮、macOS 6 轮),JIT 已在计时前完成编译。增幅按两版中位数之比计算。JIT 对照实现 #913pid >= 3333333(双列)dataTime < 1610612736(同列)单比较在两端的每一轮均是 Stile 更快。Linux 双列 AND 在 8 客户端时差距最小,四轮中有一轮 Stile 略低于 JIT。每条谓词的 1,024 个查询均在本机得到一致的有序 Top‑21。
首次单比较查询的耗时中位数(JIT → Stile)在 Linux 为 114.34 → 59.77 ms(打开集合后直接查询),在 macOS 为 17.85 → 1.06 ms(先用无过滤查询预热 HNSW)。两端测得的 JIT 编译耗时分别约为 53 ms 和 16 ms。
表中增幅适用于双方原生支持的数值谓词。多段
LIKE在逐候选执行时可能使 #925 回退 Arrow。同一谓词的两条 bitset 对照路径
这两条路径都在召回前生成 bitset。第一行保留原复现脚本的切换阈值
0.9,第二行使用移除了dataTime索引的同图副本。下表为 macOS 上ea1519a0→c21b4f93的四轮 QPS 中位数。dataTime范围倒排索引invert_to_forward_scan_ratio0.90复杂数值谓词下的过滤性能
沿用共同基线
a26f8abe和 10M × 62 维 HNSW 数据,用AND/OR组合dataTime和pid的 4、10、22 个范围比较,三组命中率均约 50%。在 Linux 和 macOS 的单客户端、8 客户端测试中,Stile 的端到端 QPS 中位数至少是三条对照路径中最快者的 11 倍(倒排 bitset、正排 Acero bitset、旧 Arrow 逐候选)。Stile 与热态 Gandiva JIT 的吞吐接近,相对 JIT 的差异在单客户端下为 −8.5% 至 +8.9%,在 8 客户端下为 +4.3% 至 +12.6%。
下表为 22 个范围比较时的 QPS 中位数,每格依次为 1 客户端 / 8 客户端(Linux 4 轮,macOS 5 轮)。JIT 在计时前完成编译。
验证
ENABLE_NATIVE=OFF,zvec 查询线程数固定为 8。上述 Arrow/Stile 三提交对比每客户端预热 256 次,每进程计时 4,096 次,每个平台共计时 98,304 次查询。