Repository navigation
Description
Parent Issue
Detail of Subtask
Validation update — 2026-11-02
Implementation is delivered; current-main focused decimal tests and public SQL BVT pass. Current optimized cast proof calls are outside row loops, and Q1/Q15 selected-kernel/CPU diagnostics have been collected. Overall performance acceptance remains OPEN for the missing SF100/mixed-I/O and other applicable gates. Server129 validation reuses its existing loaded data in place, with no image copy or reload. Queued work is not a measured pass. See the validation follow-up comment for exact source, executable and scoped evidence.
Evidence reassessment — 2026-10-26
Current delivery/performance status: PARTIAL DELIVERY. #30880 introduced the invariant hoist; merged correction #30981 addresses empty/NULL/setup costs and reports isolated local SF10 acceptance. The original all-NULL regression is historical, not an unresolved finding against current main. SF100/mixed-I/O and current-baseline completion evidence remain required.
Observed: Historical Q1 exclusive user leaves in type/scale proof helpers total about 18.62% at SF10 and 20.10% at SF100. Pinned source and optimized assembly place batch-invariant proof calls inside non-NULL cast loops. This established redundant work in that revision, not a remaining 20% opportunity after the merged fixes.
Not yet established: How much redundant proof/cast work remains on current main, and which entrypoints still own it. A hot type helper can serve multiple callers; its whole sample share is not the savings of one cast change.
Next discriminating experiment: Reprofile the current cast paths after #30981. Attribute each remaining metadata/proof call to its cast entrypoint and report calls/instructions per non-NULL value plus absolute query CPU. First confirm the proof has not already moved outside the loop.
Measured target: Unchanged Q1 and equivalent decimal cast workloads; show reduced remaining proof work and target latency/CPU after the current baseline.
Mandatory controls and total cost boundary: Empty and flat all-NULL batches; constants; widening/non-widening scales; same-scale paths; rejected values; scalar/tiny/tail batches. Include setup and broadcast cost.
Performance acceptance and rejection
- Freeze current-main/candidate sources, executables, real caller shapes and effective settings. Use the unchanged qualification SQL and complete result consumption; exclude cold runs and keep profiles separate from latency scoring.
- Demonstrate the named work/CPU reduction and an attributable uninstrumented target-query improvement. Include the controls below and full Q1-Q22 comparison; component wins, source changes, functional tests, SCA, merging and profile percentages are separate evidence.
- A confirmed affected/control slowdown fails; unresolved slower signals are inconclusive. Confirm with an independent longer balanced run. No gain elsewhere, favorable average or self-approved tolerance waives a regression.
- Complete applicable SF10/SF100 and memory/mixed-I/O acceptance before issue closure under the umbrella protocol. Report uncertainty, absolute CPU/instructions/work, allocations/copies and the same whole-application budget, effective cache, I/O/spill/swap/pressure evidence. Benchmark scripts do not verify input/table/schema/row counts/reference results/checksums.
Semantics and lifecycle requirements retained
- Type/scale decisions that are constant for one batch are absent from its non-NULL row loop; optimized code or per-row instruction evidence demonstrates the removal.
- Focused tests cover empty/constant/nullable vectors, widening and non-widening scales, overflow, rounding and error behavior without changing SQL metadata.
- Report warmed Q1 CPU/instructions and uninstrumented latency before/after at the same binary settings, image, CPU and memory budget; exclude cold runs.
- Report the measured gain without extrapolating the 20.10% sample share to a 16× speedup: eliminating that entire fraction alone has a conditional user-CPU ceiling near 1.25×.
Describe implementation you've considered
Keep the current batch-level proof when it is already adequate. Hoist only genuinely invariant remaining work; retain value-dependent precision, scaling, rounding and overflow checks. Empty/all-NULL/constant routes must avoid unnecessary setup.
Coordination: Coordinate domain inference with #30840; do not count the earlier hoist again as a new result.
Additional information
- Reassessed profile/caller evidence and delivery ledger.
- Historical MO source
873282742714436bff407dfcdbbe879147162bd3; DuckDB069cc9f9b5be802405797faecc284961b07c70ef. SF10 all-query profiles; SF100 results/profiles; mixed-I/O evidence. These are pinned historical captures, not current-main scores. - No new query/benchmark was run for this reassessment. Foreground query work, engine background maintenance, kernel CPU and off-CPU waits must be distinguished; all remain inside whole-application resource accounting.
Pinned implementation / plan references
Activity
XuPeng-SH commentedon Oct 22, 2026
转测:修复已合入(性能子任务),本地只能做微基准,压测验收交 QA
#30880 perf(function): hoist decimal cast invariants(已合入),无其他 OPEN PR。decimal乘法/除法内核在多精度组合下的结果与标量路径一致(单包/微基准级别)。#30838TPC-H SF10/SF100)要求的端到端性能收益。转测:assignee 从实现者改为 QA(
Ariznawlll),保持单一 owner;验收请在具备 SF10/SF100 环境的机器上做收益对比。aunjgr commentedon Nov 2, 2026
Validation follow-up — 2026-11-02: implementation present; issue stays OPEN pending remaining performance acceptance.
The original invariant-hoist problem is absent from all five owned cast paths in the current optimized executable. Each has exactly one
canWidenDecimalScalecall in setup; source AST inspection finds zeroGetType/ToType/proof calls inside their row loops. An independent control-flow audit of optimized disassembly also places all type/scale proof calls outside instruction cycles, excluding only Go's pre-execution stack-growth restart:decimal64ToDecimal640x3808548decimal64ToDecimal256Array0x3809508decimal128ToDecimal1280x380a1c8decimal128ToDecimal2560x380a688decimal256ToDecimal2560x380b148The current cast implementation retains early empty/NULL handling, batch proofs and value-dependent checked fallbacks. Passing precision/scale/NULL tests cover the relevant semantics. The current Q1/Q15 profiles have no sampled leaves in
canWidenDecimalScaleortypes.T.ToType; sampling alone is not proof of zero calls, so the source/assembly proof above is retained.Reuse, without rerunning, the separately isolated SF10 Q1-Q22 campaign for merged #30981: Q1 medians 1.646204 -> 1.467484 s; median paired change -9.86%, ratio interval [0.8908, 0.9084]. This is the historical isolated correction result, not a new current-main comparison or a gain to add to #30880.
Current-main validation snapshot:
be8eb40ad8bb7b35cbd3c1f50a5a6d23e1f6da1e. Normal release build, Go 1.27.1, GOAMD64=v3, GOEXPERIMENT=simd, no source overlays/PGO. Executable SHA256:0f4f07c1d39b32e08dcd0c100531cb50843500d74ae6380bd3704a7596647aae. This is current-code correctness/kernel evidence, not a before/after latency comparison of all changes merged since the original fixes.Focused function/planner/Substrait decimal tests pass (483 named top-level tests in the selected output, including producer-domain, legacy carrier, scale/rounding, prepared-execution and precision controls). SQL BVT passes 450/450 distinct statements on each of two same-instance runs: decimal intermediate precision 58, decimal multiply/subtract 18, casts 374; zero failures/ignores. The owned service stopped cleanly with SIGINT. These are semantic tests; the benchmark worker performs execution/draining only, with no input/table/schema/row/reference/result/checksum verification.
Separate warm CPU/PMU diagnostics, 16 completed calls/query after the selected cold call was excluded:
Both local SF10 profiles satisfy the existing all-memory gates: eight physical application CPUs, 16 GiB effective CN SHARED cache, 32 GiB whole-application budget including native image/pinned software, zero measured physical reads/writes, spill, swap, OOM, major faults, direct reclaim and measured memory-pressure stalls. Profiling is separate from scored latency. Raw PMU counts include the measured application process scope; sample percentages are user-space diagnostics, not savings estimates.
Server129 already retains the loaded SF100 database. The revised runner reuses it in place, sequentially, with no image/data transfer, copy or reload. It uses all 64 CPUs, a 200 GiB application / 192 GiB CN cache all-memory context and a 32 GiB / 16 GiB warm disk-backed context; actual I/O is recorded. A warm run is accepted as all-memory only if measured physical I/O/spill/swap are zero. Tiny configuration and diagnostic-output files are separate from the database. PSI availability limitations remain explicit.
The queued SF100 work is currently waiting for a quiet resource window; no benchmark service has launched. These queued jobs supplement the isolated #30981/#30983 Q1/Q15 evidence and current-main kernel/plan evidence. They do not claim that #31034's SF100 effect, every full-suite/context requirement or this issue's complete performance acceptance has already passed. A resource-rejected arm is retained and is not silently staged or relabeled.
Ariznawlll commentedon Nov 16, 2026
QA 验证补充:cast invariant 提升的功能与白盒核对通过(性能验收门仍未完成,issue 保持 OPEN)
测试版本
8e8708a8d306a69512d140b40bfcfebc1d404a32;perf(function): hoist decimal cast invariants #30880(invariant hoist)及修正 fix(function): avoid decimal cast setup and widening overhead #30981 已确认在该 main 祖先链。白盒核对(当前源码)
对
pkg/sql/plan/function/func_cast.go逐处核对canWidenDecimalScaleproof 调用位置:decimal64ToDecimal64decimal64ToDecimal128Arraydecimal64ToDecimal256Arraydecimal128ToDecimal128decimal128ToDecimal256decimal256ToDecimal256全部 6 处批不变 proof 调用均位于行循环之前的 setup 段,与交付声明一致。该核对为源码结构确认,未独立复现优化后二进制的反汇编地址证据(沿用交接记录)。
功能验证
decimal(18,4)→decimal(30,8)、decimal(30,8)→decimal(40,12)、同精度 256→256 均逐位精确;缩窄decimal(30,8)→decimal(18,4)按 scale 正确舍入(12345678.12345678 → 12345678.1235)。price * (1 - discount)列操作数 →decimal(37,4))在 SQL 元数据上逐字复核通过(详见 [Subtask]: Preserve sound decimal domains and avoid unnecessary wide arithmetic #30840 的验证 comment)。Go 单测
TestDecimal|TestArithDecimal(pkg/sql/plan/function)本地 ok。回归测试
cast 功能契约已并入 matrixorigin/motr#349 的
14_issue_regression/issue_30840_decimal_domain(37 语句)。PR 4 项 CI 全部成功,用例标记@target-branch: main。验证边界(保持 OPEN 的原因)
本子任务的核心验收是 warmed Q1/Q15 的 CPU/指令数与未插桩延迟的前后对比(冻结源、同机同预算、排除冷启动),以及 full Q1–Q22 对照和分配/拷贝预算——本地不具备该基准条件,未执行也不宣称任何性能收益数字。原 20.10% 样本份额不可外推为整体加速比(交接记录已注明条件上限约 1.25×)。功能与白盒核对通过不等于性能验收通过,issue 维持 OPEN,待基准环境数据补齐。
Ariznawlll commentedon Nov 18, 2026
Note
QA 性能面补充验证:大数据量真机基准已实测(main
517e169538),功能面此前已通过。本 subtask 的可测性能证据已交付;最终"目标倍数"裁定权在研发/负责人,QA 证据供其引用。保持 OPEN 至父项策略裁定。QA 补充:大数据量真机基准(#30839 cast invariant hoist / #30840 decimal 域)
此前功能面验证(2026-11-16)已通过。本.comment 补性能面证据。
测试环境
517e1695388cbaf1135238d5ab0c19a4556fb551(git_version()实测确认),1 LOG / 1 TN / 1 CN,Darwin arm64 8 核 16GB。qa_big.lineitem5,498,998 行(1M 订单、DECIMAL(15,2) 价量),partsupp800,000 行 ⋈part200,000 行。大数据量计时(warm 1 + 3 轮,取 best)
l_extendedprice * l_quantity乘法 + 全量 GROUP SUM(三组,组值达 4.06e12,超 DECIMAL(15,2) 单行域宽——域拓宽分派正确)group by l_orderkey+sum(price*qty)pkg/sql/plan定向 219 项 Decimal/Cast 单测ok1.75s,0 FAIL)aggexec(聚合执行核心)全包结论