Repository navigation
Description
Is there an existing issue for performance?
- I have checked the existing issues.
#24097 is the broad query-execution performance umbrella. This issue tracks the four concrete column-container improvements in PR #30160. No dedicated issue for that PR was found.
Environment
- Baseline:
a53390c57de48ac280249ff0e88831e502e20fb0. - Implementation: PR perf(container): optimize appends, validity ranges and typed reads #30160, current head
ef9ba664d8a0573b9310b1d770e31e64a7a6564a. - Local benchmarks: Apple M1, macOS 26.6.2 arm64, Go 1.27.1,
GOMAXPROCS=1.
Details of Performance
Existing column-container paths perform unnecessary per-row work:
vector.AppendFixedListassigns each fixed-width value individually even for disjoint, all-valid batches with sufficient capacity.vector.AppendBytesList/AppendStringListrepeatedly grow non-inline payload storage for fresh raw varbinary and legacy varchar vectors.- Borrowed Arrow validity
Nulls.CountRange/InitBorrowedWindowscan individual bits when masked boundary bytes and word population counts can preserve the same result. GetFixedAtNoTypeCheck/Vector.GetBytesAtrepeat const/flat class decisions during row reads.
PR #30160 implements typed bulk copy and one-time payload reservation for the eligible append cases, word-based borrowed-validity range counting, and a single class decision in typed getters. Small, nullable, overlapping, reused/borrowed or validation-sensitive inputs retain the applicable original paths.
Representative local API benchmark medians (2048 rows/bits; ns/op, lower is better):
| Scenario | Before | After | Speedup |
|---|---|---|---|
| Fixed int64 append, no NULL, retained capacity | 1373 | 238.45 | 5.76× |
| Fresh varbinary append, 64-byte values | 175504 | 68542.5 | 2.56× |
| Borrowed validity range count, mixed NULL | 1917 | 48.335 | 39.66× |
| Typed int64 read, flat | 8134.5 | 5593.5 | 1.45× |
Append measurements compare a53390c57d with 44e4b676fe; range/read measurements compare 44e4b676fe with 56c4323011. ABBA order, six 250 ms samples per variant/case; 59 cases and 708 samples in total. Speedups are independent and must not be multiplied. They do not establish SQL throughput or cross-version compatibility. Byte-getter benchmarks consume length and first byte rather than all content. The later head change only repairs an isolated CI test.
Compatibility and acceptance criteria
- Preserve public signatures, NULL/metadata, overlap behavior, short-mask errors and error precedence.
- Preserve allocation accounting, rollback, borrowed backing lifetime, getter bounds/type guards and returned byte aliases.
- Verify serialization byte equality / round-trips and relevant boundary cases.
- Pass complete nulls/vector/batch/aggexec/group unit tests, nulls/vector race tests, typed-read tests with
typecheck, and incremental static checks locally. - Complete required hosted CI/BVT for the latest PR head before merge.
No on-disk or wire-format change is intended. Real SQL workload gains and cross-version node tests remain outside the measured local evidence; no such claim is made.
Additional information
Implementation and detailed validation: #30160. Related umbrella: #24097; this dedicated issue does not close the umbrella.
The PR also repairs TestAutoIDCacheRestartAndDisabledNode: each running cluster generation receives the original 3-minute SQL budget after startup, preventing restart admission from consuming the next generation's budget. Existing persistence, disabled-node rejection, ID and metadata assertions remain unchanged. A deterministic expired-context probe fails on verified main and passes with the fix; the original test, complete owning isolated package, focused adaptive race and incremental lint pass locally.
Hosted validation: MatrixOne ALL CI, attempt 2 completed successfully on ef9ba664d8a0573b9310b1d770e31e64a7a6564a, including the CI Required gate. Upgrade jobs were skipped; this is not cross-version upgrade proof. PR #30160 is ready for review; any CI triggered by the readiness event is tracked separately on the PR.
Performance regression follow-up (2026-10-15)
A focused main-to-current-head ABBA comparison (11 cases, six samples per variant/case) found a downside in fresh all-inline 8-byte values: 2048-row varbinary append takes 24843.5 -> 26402.5 ns/op (+6.28%); 128 rows are +4.73%. The pregrow path scans lengths although no non-inline payload needs reservation. The original three small varchar median slowdowns did not reproduce their previous magnitude (-1.92%, -0.82%, +0.49%). Long-value positive controls retain their gains.
- Tighten eligibility to avoid unnecessary all-inline scanning and remeasure, or explicitly accept the measured tradeoff in review before merge.
No production code changed in this diagnostic follow-up. These local API results do not establish SQL workload regression or universal non-regression. Passing CI does not close this performance concern; see PR #30160 for the disclosure.
Owner decision (2026-10-15): retain the implementation and accept the disclosed small, local all-inline API tradeoff; no extra performance change is requested for these cases. Measurements and the SQL-workload limitation remain documented. This acceptance does not waive correctness/compatibility checks or materially different performance regressions.
Activity
perf(container): optimize appends, validity ranges and typed reads (#…
XuPeng-SH commentedon Oct 16, 2026
转测 @Ariznawlll:#30160 的功能、race、typecheck 验证之外,已补齐关键性能路径的独立对照。
验证提交:main
97415db10bdb3d6ffdf53ff1810a7e80bd78ee11。对照为同一提交中仅通过 Go overlay 撤回 #30160 在 vector.go、nulls.go、borrowed_validity.go 的性能改动,其他代码及基准输入保持一致;不是整个旧提交对比。撤回对照的相关功能检查通过。使用 control/main/main/control 顺序、每轮 3 个样本、每个样本 150ms、单 CPU 基准,以下为每侧 6 个样本的 ns/op 中位数:
这些是限定输入上的本地微基准,不能外推完整 SQL/BigData 吞吐,也不关闭性能 umbrella #24097。请测试侧结合目标工作负载验收,保持 OPEN。
Ariznawlll commentedon Oct 20, 2026
测试版本
main7c146f4adbf068dd0c06b377157cfb7d7698b1eb(本轮测试时的官方 main,隔离、干净的工作树)7c61f67e5dc46b0b8e591fe957219308b078bfa4;GitHub compare 显示该提交是上述 main 的祖先(ahead 94、behind 0)。原问题验证
本 issue 的验收对象是固定列/变长列批量追加、借用 Arrow validity 的区间统计和 typed getter 四类列容器热路径,不要求把 API 微基准外推为整条 SQL 的性能。上述修复在本轮 main 上的相应功能用例各重复 3 次均通过。以
GOMAXPROCS=1、-benchtime=200ms -count=3 -benchmem重新测量,固定int642048 行追加为 248.9/240.3/252.1 ns/op(中位数 248.9,0 alloc/op);新建varbinary2048 行、64-byte 值追加为 53017/50306/50357 ns/op(中位数 50357);8192 行混合 NULL 的 borrowed validityCountRange为 103.6/118.5/104.3 ns/op(中位数 104.3,0 alloc/op)。2048 行 typed read 的 flatint64三次为 5615/4682/4630 ns/op(中位数 4682,0 alloc/op)。这些是本机新测的修复版绝对值,没有拿不同机器/日期的数值直接计算加速比。修复前后同代码基底、仅回退相关性能改动的 ABBA 对照及六样本中位数已由研发在交接评论给出:固定列 1333.5→281.85、变长列 207597→98947、借用 validity 混合 NULL 7602.5→170.4 ns/op;本轮结果方向一致,但不冒充同机 A/B 或 SQL 端到端增益。
Happy Path 覆盖
pkg/container/{nulls,vector,batch}与pkg/sql/colexec/{aggexec,group}五个完整 Go 包-count=3均 PASS;固定列和变长列结果、NULL/元数据、typed read 数值和 byte alias、借用 validity 的计数及序列化/往返用例均在其中。-count=3PASS;同组-race -count=3PASS;vector-tags typecheck -count=3PASS。int64 const、bool flat、bytes inline/area2048 行 typed read,三次均完成且 0 alloc/op。Unhappy Path 覆盖
-count=3内通过;错误/边界路径未通过放宽断言来换取 PASS。白盒验证
本轮本地完整包 3 次、定向 race 3 次、typecheck 3 次均 PASS。当前修复不改磁盘/协议格式;本轮未做跨版本节点升级测试。
回归测试
回归已随 #30160 合入产品仓库,覆盖
append_list_fastpath_test.go、append_varlen_pregrow_test.go、borrowed_validity_range_test.go、typed_read_test.go及对应基准。该问题是容器内部 API/性能路径,现有 Go UT/race/基准直接覆盖原路径,按当前约定不重复增加 MOTR SQL 用例。#30160 提交前的 MatrixOne ALL CI attempt 2 已成功;另一个合并后 TKE job 在 Docker Hub 基础镜像 metadata HEAD 超时,测试前失败,不能视为产品失败或 TKE 通过。测试证据
go test ./pkg/container/nulls ./pkg/container/vector ./pkg/container/batch ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/group -count=3 -timeout=20m,五包均ok;vector/nulls 定向-race -count=3和 vector-tags typecheck -count=3均ok。GOMAXPROCS=1 go test ./pkg/container/vector ./pkg/container/nulls -run '^$' -bench 'BenchmarkAppendFixedListReuse/flat_2048$|BenchmarkAppendVarlenList/bytes_varbinary_cold_2048$|BenchmarkBorrowedValidityRange/count_mixed_8192$|BenchmarkVectorTypedRead' -benchtime=200ms -count=3 -benchmem;具体数值如上。测试结论
测试通过。