Description
Is there an existing issue for the same bug?
- Checked open and closed Issues by perf(exec): consume selected scan batches through expressions and operators #32492, COM_QUERY, non-prepared, allocation and regression.
This is a narrow follow-up to #32840, not a claim of a second introducing PR. #32840's measured 129 workload uses prepared execution; the local mitigation being evaluated restores reuse only for prepared TP. This Issue preserves the independently measured text-protocol range-count residual so it is not accidentally declared fixed by that mitigation.
#32818 separately tracks per-statement Statfs. The range-count control already performs Statfs in the parent because it has a Group operator. A text point-select control also exercises the known #32818 path; its unprofiled throughput delta was inconclusive and is NOT reported here as another confirmed regression.
Branch Name
main
Commit ID
- Exact parent:
f70c37b16e2d2378dd6d48775df0f29c610dce6b. - Exact child:
49d552e16cfb7fb9160210d19f2874dc4a71272c(perf(exec): consume selected scan batches through expressions and operators #32492). - Later unmodified base also measured:
e1160015bb5895c1677d5fc1496c4bee440592b3. - Upstream main advanced to
43addc16ba30c3e5a0feb11447078092a5fc3953during review. That later head is NOT claimed executed here.
Other Environment Information
- Apple M2 Pro, 16 GiB RAM, Darwin 24.0.0 arm64. This host is not dedicated.
- Same Go 1.27.1/native build inputs; all binaries built with the same
GOEXPERIMENT_OPT=override. No claim of equivalence to CI's SIMD-enabled Linux binaries. - Local single-process LOG/TN/CN, local DISK-V2 FileServices,
GOMAXPROCS=4,GOMEMLIMIT=3GiB; no external shared cluster modified. - 1,000 rows, 8 pinned SQL connections, 1,000 warm-up queries (125 per connection), 15-second scored interval per case.
- A cleanly stopped parent-produced seed was copied before every process start; every seed file was SHA256-verified before start. Pre/post row count and independent ID/k/v sums matched. Every returned COUNT was checked against 100; zero query errors and zero wrong results.
- Version order and case order were reversed. No build/test workload ran alongside the measured suite. One separate suite collected CPU profiles; one suite ran without profiling. Do not combine them into one statistical sample or extrapolate to 129's 100M rows/1,000 threads.
Actual Behavior
SQL uses COM_QUERY, not bound arguments and not implicit driver Prepare:
SELECT count(k) FROM t WHERE k BETWEEN 0 AND 9;
-- Change lower bound deterministically over 0..90; upper bound = lower + 9.Unprofiled suite, version order parent -> child -> local prepared-only candidate -> candidate -> child -> parent:
| Version | Run 1 QPS | Run 2 QPS | Mean QPS | Relative to parent |
|---|---|---|---|---|
| Exact parent | 15,104.42 | 14,762.34 | 14,933.38 | baseline |
| Exact child | 14,563.83 | 13,818.20 | 14,191.01 | -4.97% |
| Local prepared-only candidate on e116 | 14,016.45 | 14,516.56 | 14,266.50 | -4.47% |
Separate profile-instrumented suite, parent -> child -> e116 -> candidate -> candidate -> e116 -> child -> parent:
| Version | Run 1 QPS | Run 2 QPS | Mean QPS | Relative to parent |
|---|---|---|---|---|
| Exact parent | 15,403.15 | 14,910.23 | 15,156.69 | baseline |
| Exact child | 13,956.38 | 13,955.62 | 13,956.00 | -7.92% |
| Unmodified e116 | 14,154.77 | 14,108.05 | 14,131.41 | -6.76% |
| Local prepared-only candidate | 14,129.22 | 14,494.64 | 14,311.93 | -5.57% |
The local candidate deliberately does not change COM_QUERY ownership. Its prepared range-count control recovers to about 98-99% of parent; that improvement must not be applied to the text results above.
Expected Behavior
Retain original SQL correctness, memory admission, ownership and cleanup guarantees while avoiding an execution-cost regression for non-prepared TP. Do not expand a prepared-only exemption to all TP merely to hide the cost. Validate any follow-up with parent/candidate text and prepared controls and a Linux/original-scale run before claiming general recovery.
Steps to Reproduce
- Build the exact parent and child with identical toolchain/native options.
- Create a fresh test database and this table on the parent:
CREATE TABLE t (
id INT PRIMARY KEY,
k INT,
c VARCHAR(80),
v INT,
KEY idx_k(k)
);Insert rows for integer i=0..999: (i, i % 100, CONCAT('row', i), 0). Cleanly stop and save the complete data directory. Before each measured process start, restore that same seed and verify file hashes.
- Use eight fixed connections. Send literal SQL with
lo=(iteration*17+worker_id)%91andhi=lo+9. With go-sql-driver/mysql, callconn.QueryRowContext(ctx, formattedSQL)without arguments, neverPrepareorQueryRow(sql,args...). Expect exactly one COUNT value of 100 for every request. - Warm up, measure for 15 seconds, consume every result, then stop. Repeat parent/child in reverse order. Profile in a separate paired suite.
Additional Information
Established: repeated local parent/child throughput loss with unchanged data/protocol, zero errors, and a stable uncovered text range-count residual after prepared-only gating. This is smaller than the original 129 prepared regression, not a new 35% COM_QUERY claim.
Code changes relevant to the remaining cost:
- TableScan.SetAllocationAccount adds statement-account-backed expression/output allocation.
- prepareReaderFilter may schedule all columns and reader-side filtering when OutputAllocation is installed.
- Expression construction uses the allocation-aware path. Non-prepared execution reconstructs a Compile regardless of the mitigation; eliminating prepared Reset->Free does not address these costs.
One paired text-range profile has parent/child Statfs cumulative samples 13.23s / 11.99s for roughly 10s sampling windows at 15,403 / 13,956 QPS. Normalized by whole-interval QPS, the approximate per-query Statfs cost is unchanged (~86us); these are estimates, not exact counters for requests inside the profile window. This argues against attributing all text-range residual to a newly introduced disk-budget sample. TableScan.Call cumulative samples increase from 0.95s to 1.64s in that pair. Do not add nested CPU percentages or equate this observation with a fully isolated mechanism.
Not established: exact division between account/pointer-metadata work, reader filtering, dictionary consumers, or other #32492 changes; original-scale Linux impact; a safe general non-prepared fix. Keep these as investigation work rather than widening the prepared mitigation.
Raw results, 24 profiles, exact executable hashes, test validation and the runnable bounded harness are retained in the review evidence. All owned processes were stopped normally; no production environment was changed.
Activity
fix(compile): preserve prepared TP expression reuse (#32862)
perf(exec): reduce accounted work on short index range scans (#32895)
XuPeng-SH commentedon Nov 19, 2026
转测:main 短索引范围扫描开销优化
#32895 已于 2026-11-19 02:02 UTC 合入 main,merge SHA
ae9e665f3093094ba3286e72bf1af8e111463180,最终 headac8200937b0ab36bd12b30fe7b1960a1128db62f,base035af996806917b23d9428695e0295b65cb16356。完整 issue 评论、PR 会话、评审及最终补丁已核;旧版 replay admission/read-ahead findings 已通过撤掉 gather 路径解决,未见当前适用的已验证反例或必要未完成开发 follow-up。交 QA @Ariznawlll,保持 open。转测不是性能恢复或验收通过。最终实际范围:
prefix_between复用既有非空 Boolean 结果路径;NULL 输入仍保留 NULL 语义。证据与版本边界:
7fb22c67e430110d7f4abf71097c4af161fb80c2,不是最终 headac820093...。评审实际执行 prefix validity、reader selection、上述 7/23/24-byte admission、reader ownership 和完整 colexec/table_scan 检查;冻结 CI 记录 x86 UT 与 multi-CN BVT 成功。最终合并队列报告 CI Required 成功,这不等于原问题端到端性能验收。891ff4655f7cf688aa359c3413dea86240a2a023对比87c44445...执行每版 1,228 个自定义断言及投影检查;两个 text range-count 短跑为 +1.61% / +1.70%。该版本后来仍被评审发现 replay admission/read-ahead 问题,并被继续修改;这些旧版通过项和吞吐数字不能作为最终 head 的通过证明或性能恢复结论。请 QA 固定包含 merge 的 main 版本,按本 issue 原 COM_QUERY(无绑定参数/无隐式 Prepare)1000 行、8 固定连接、逐条 COUNT=100 的同数据同资源反序配对方法复测,并独立记录 prepared range-count / text point-select 控制组。验证 NULL、partial/all-match、apply-only、DML/rollback、取消后可用性、内存拒绝和释放;原规模 Linux 100M 行 / 1000 sessions、重启/持久化与最终 head 吞吐仍属未测边界。若仍有残余性能退化,记录精确版本和对照证据,不用旧候选版结果覆盖。未自动 backport 或部署。
Ariznawlll commentedon Nov 20, 2026
QA 阶段性性能测量(2026-11-20,尚不能认定恢复)
固定完整构建版本:parent
f70c37b16e2d2378dd6d48775df0f29c610dce6b、#32492 child49d552e16cfb7fb9160210d19f2874dc4a71272c、包含 #32895 的 finalb543648d99395492918ce0a5a3c08a7de952042d。每轮启动均核对git_version()、完整 1000 行冻结数据及逐文件 SHA256;三版二进制哈希也已保存。环境为 macOS 独立单 CN,
GOMAXPROCS=4、GOMEMLIMIT=3GiB、独立数据目录和端口。8 固定连接,每连接 125 次预热;每轮 15 秒计分并逐条消费结果。range-count 必须返回 100,点查返回 0;prepared 控制组逐次更新绑定参数。执行顺序 parent→child→final→final→child→parent。18 个计分结果均 0 SQL 错误、0 错结果,六轮服务均正常退出。后半段三个版本的吞吐均明显上升,存在显著时间漂移;两轮均值也不能消除该影响。因此不能挑选某一轮宣布恢复,也不能用另一轮宣称普遍残余 33% 退化。本机 1000 行数据不能外推为 Linux 原始 100M 行 / 1000 sessions 或生产性能结论。
已排除误连其他版本、RPC/SQL 端口冲突、共享 LogService、prepared 固定参数及并发资源干扰的结果,不将其混入上述配对。原始规模 Linux 性能、最终 head 的持久化/重启及完整边界尚未完成;issue 保持 OPEN,不标性能验收通过。
Ariznawlll commentedon Dec 1, 2026
结论
未完成验收,保持开放。 本轮补做 Linux 上原 1,000 行/8 固定连接协议的六轮反序对照,累计 1,923,929 次计分查询,0 SQL 错误、0 错结果。目标 COM_QUERY range-count 的三轮平均 QPS 与原始父提交基本相同(-0.055%);但不能据此宣布普遍性能恢复:当前是共享主机小数据短跑,物理种子跨版本不兼容,且 text point-select 控制组均值仍低约 7.44%,大规模门槛未完成。
关键证据
版本和运行配置
f70c37b16e2d2378dd6d48775df0f29c610dce6b。ec945a6323d4e505a8445bfd129f02a70073c301,包含修复 perf(exec): reduce accounted work on short index range scans #32895。所有进程启动均实际核对完整git_version(),二进制 SHA256 单独保存。数据种子的兼容限制
最初尝试把父提交正常关闭后的完整冻结目录直接交给最新 main。main 启动时返回:
该尝试未进入 main 的性能计分,未把它当作 range-count 回退或本 Issue 的失败。随后重新开始完整对照,两个版本各自建全新库,使用相同逻辑行:
i=0..999、k=i%100、c='row'+i、v=0。每个版本正常停止并冻结自己的种子,每次启动前逐文件 SHA256 核对该版本的拷贝。因此,本轮证明的是同逻辑用户数据、每版本内部冻结种子,不是跨版本物理文件完全相同。最初只有父版本的一轮数据没有混进下表。
协议与执行方法
lo=(iteration*17+worker)%91、hi=lo+9,逐次结果必须为 100;未调用 Prepare,也未把它隐式改为带参数查询。目标 text_range 的均值 P=6511.11、M=6507.54;三轮样本变异系数分别约 1.18% 和 4.52%。这里没有临时自定“5%以内就通过”的阈值,也没有用 prepared 控制的提升抵消 point 控制的下降。
计分共 18 组 / 1,923,929 次请求,错误与错结果均为 0。性能脚本保存了各组 p50/p95/p99 和原始 QPS;本次只报告观察,不把 15 秒共享主机结果解释为稳定业务 SLA。
证据与回归状态
128 目录
/root/qa-32857-20261202:bench.go:固定连接、原协议、预热、逐条结果断言。run_logical.py:版本种子、SHA校验、六轮顺序、服务清理与原任务恢复。logical/summary.json、各round-*/bench.jsonl、seed-hashes-*.json、binary-hashes.json:原始运行证据。run.log保留最初跨版本目录不兼容的尝试,与后续logical.log分开。本轮是独立验收探针,尚未宣称接入每日大数据回归;不把已有小 SQL 用例或此处短跑当作 100M/1,000 sessions 的回归覆盖。全部自有计分实例已停止,原来的自有测试 MO 已恢复。
待解决点
需继续按交接要求完成专用资源上的大规模 Linux/100M 行/1,000 sessions 验收,并补齐完整边界的对应回归。text_point 控制组的下降需要独立配对/profile 归因,不能只凭这次共享主机短跑就另判一个已确认新产品 Bug或将其归因于 #32895。当前目标 range-count 在本次小数据测量中未见稳定残余损失,但不足以关闭完整性能验收。
最终结论:未完成验收。 已完成 Linux 小数据六轮原协议对照,目标 range-count 均值接近基线且所有查询正确;未完成项:大规模与专用资源性能验收、控制组下降的独立分析及完整专项回归,因此保持开放、不转回研发。