Skip to content

perf(decimal): vectorize expression arithmetic and widening casts - #32237

Draft
aunjgr wants to merge 17 commits into
matrixorigin:mainfrom
aunjgr:perf/decimal-avx2-kernels
Draft

aunjgr wants to merge 17 commits into
matrixorigin:mainfrom
aunjgr:perf/decimal-avx2-kernels

Conversation

@aunjgr

@aunjgr aunjgr commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #30860. Broader decimal performance work remains open.

What this PR does / why we need it:

Add bounded Go AVX2 kernels to existing decimal expression paths: prepared Decimal64/128 arithmetic, native Decimal64 multiplication, fused revenue expressions, lossless Decimal64-to-Decimal128 casts, and fully checked native Decimal128 addition/subtraction. Preserve SQL types, scales, overflow diagnostics, selected-row behavior and result ownership.

Check native Decimal128 add/sub in eight-row blocks before publishing stores. Resume the scalar owner at the first untouched block to preserve the first failing row, including in-place scale alignment and constant broadcasts. Use exact scalar overflow identities and direct one-row NULL handling to reduce fallback setup. Extend independent full-range arithmetic and aliasing tests and retain the existing SQL integration case.

Design and validation

The requester approved this coverage revision before implementation. The versioned design records the contracts, qualification decisions and scalar arithmetic proof. Reduction remains independent in #32266.

Performance tables, profiles and test outcomes are recorded in comments:

@aunjgr

aunjgr commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Local SF10 evidence for b722651ecb against clean main 3820136ff2: three alternating independent process pairs per mode, five full warm suites per process, full cold suite excluded; all32 CPUs,48GiB application/16GiB cache. Normal SQL comparison and both static gates pass. No SF100 result or readiness pass is claimed.

Memory screen

Query Scalar wall s SIMD wall s Wall change (95% CI) Scalar CPU s SIMD CPU s
Q1 0.37805 0.34701 -6.60% [-15.57%, +3.33%] 11.02903 10.10924
Q2 0.02872 0.02935 +1.85% [-7.93%, +12.66%] 0.44092 0.45738
Q3 0.10540 0.10507 -0.41% [-2.61%, +1.85%] 2.48116 2.52680
Q4 0.07372 0.07514 +1.80% [-1.99%, +5.74%] 1.75938 1.75691
Q5 0.09206 0.09212 +0.94% [-5.35%, +7.65%] 1.88102 1.89561
Q6 0.04374 0.04450 -1.24% [-9.25%, +7.46%] 0.94591 0.95747
Q7 0.09379 0.09373 +0.57% [-3.62%, +4.94%] 2.15167 2.14194
Q8 0.25219 0.25585 +1.52% [+0.40%, +2.65%] 2.38800 2.38241
Q9 0.28366 0.27954 -1.50% [-7.83%, +5.26%] 6.04651 6.05655
Q10 0.22310 0.22405 +0.18% [-1.54%, +1.93%] 5.02720 5.04006
Q11 0.03476 0.03507 +1.82% [-0.88%, +4.61%] 0.54283 0.53071
Q12 0.11088 0.11070 +0.33% [-2.89%, +3.65%] 2.65236 2.67260
Q13 0.13477 0.13557 +1.67% [-8.70%, +13.21%] 3.75112 3.75365
Q14 0.08198 0.08056 -1.31% [-20.84%, +23.03%] 1.41913 1.40758
Q15 0.15968 0.16254 +0.95% [-5.02%, +7.30%] 2.24841 2.39932
Q16 0.12733 0.12810 -0.04% [-5.64%, +5.89%] 1.34639 1.34001
Q17 0.08245 0.08224 -1.20% [-11.29%, +10.03%] 1.95229 1.94494
Q18 0.33277 0.33565 +1.72% [-1.98%, +5.56%] 6.38882 6.42875
Q19 0.17560 0.17755 +0.94% [-7.58%, +10.24%] 4.16585 4.00047
Q20 0.17233 0.17381 +1.55% [-6.75%, +10.60%] 3.78436 3.98305
Q21 0.33874 0.33961 -0.15% [-4.83%, +4.76%] 8.50688 8.41106
Q22 0.04917 0.04928 +1.21% [-2.83%, +5.41%] 0.96279 0.95460
Total 3.37488 3.35705 -0.28% [-2.13%, +1.60%] 71.87206 71.15111

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

Disk screen

Query Scalar wall s SIMD wall s Wall change (95% CI) Scalar CPU s SIMD CPU s
Q1 0.50063 0.47599 -5.43% [-12.34%, +2.02%] 10.53307 9.89626
Q2 0.02951 0.02895 -2.31% [-4.16%, -0.42%] 0.40102 0.42732
Q3 0.17946 0.17486 -2.37% [-7.28%, +2.80%] 2.52006 2.53168
Q4 0.11658 0.10942 -3.43% [-20.49%, +17.30%] 1.71312 1.68909
Q5 0.17410 0.17495 +0.54% [-8.34%, +10.28%] 1.97215 1.98041
Q6 0.10967 0.10247 -4.25% [-21.61%, +16.95%] 0.96255 0.94917
Q7 0.18604 0.18837 -0.42% [-14.50%, +15.97%] 2.19550 2.18502
Q8 0.33178 0.33680 +1.06% [-3.36%, +5.69%] 2.41322 2.39719
Q9 0.39447 0.39775 -1.97% [-7.74%, +4.17%] 6.35216 6.31599
Q10 0.29919 0.30113 +1.12% [-6.70%, +9.58%] 5.04719 5.11921
Q11 0.03498 0.03525 +2.09% [-6.66%, +11.65%] 0.53142 0.53479
Q12 0.20346 0.19221 -5.60% [-12.17%, +1.45%] 2.70910 2.65249
Q13 0.13717 0.13816 +0.71% [-1.30%, +2.76%] 3.81014 3.86666
Q14 0.16343 0.15361 -1.82% [-20.79%, +21.69%] 1.41446 1.44212
Q15 0.30975 0.29771 -0.62% [-10.67%, +10.56%] 2.40462 2.37930
Q16 0.12927 0.12815 -0.24% [-2.19%, +1.74%] 1.32761 1.32525
Q17 0.18159 0.18161 -0.01% [-6.17%, +6.56%] 1.86501 1.90890
Q18 0.35410 0.35499 -0.55% [-6.74%, +6.06%] 6.07640 6.05822
Q19 0.31521 0.32363 +1.54% [-4.17%, +7.58%] 4.25293 4.29176
Q20 0.24954 0.24530 -2.01% [-5.37%, +1.48%] 3.66375 3.64850
Q21 0.49631 0.50133 -0.07% [-11.36%, +12.67%] 8.37314 8.25712
Q22 0.05076 0.05086 -1.22% [-6.81%, +4.69%] 0.91874 0.92518
Total 4.94698 4.89351 -1.21% [-4.77%, +2.49%] 71.45738 70.78164

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

Independent memory confirmation

Query Scalar wall s SIMD wall s Wall change (95% CI) Scalar CPU s SIMD CPU s
Q1 0.36746 0.35267 -4.54% [-5.69%, -3.39%] 10.67645 10.11623
Q2 0.02962 0.02892 -1.73% [-5.65%, +2.36%] 0.45766 0.44470
Q3 0.10923 0.10499 -2.28% [-9.06%, +5.00%] 2.55204 2.51620
Q4 0.07634 0.07535 -2.19% [-12.21%, +8.97%] 1.76492 1.75029
Q5 0.09514 0.09373 -2.44% [-11.54%, +7.60%] 1.91612 1.91236
Q6 0.04410 0.04267 -1.82% [-7.42%, +4.12%] 0.96967 0.96208
Q7 0.09607 0.09287 -2.25% [-16.34%, +14.21%] 2.17337 2.16073
Q8 0.25306 0.25320 -0.38% [-3.99%, +3.36%] 2.37162 2.37003
Q9 0.28089 0.27836 +0.11% [-6.15%, +6.78%] 5.97448 6.06439
Q10 0.22711 0.22511 -1.02% [-5.61%, +3.80%] 5.07421 5.05893
Q11 0.03531 0.03551 -0.61% [-5.10%, +4.10%] 0.54637 0.53139
Q12 0.11217 0.11469 +1.10% [-4.07%, +6.55%] 2.68708 2.67805
Q13 0.13565 0.13464 -0.74% [-4.57%, +3.25%] 3.76066 3.76478
Q14 0.08179 0.08285 -1.05% [-10.18%, +9.02%] 1.43038 1.40519
Q15 0.16058 0.16289 +0.06% [-7.95%, +8.76%] 2.26185 2.37084
Q16 0.12822 0.12844 -0.26% [-3.64%, +3.24%] 1.34070 1.35248
Q17 0.08372 0.08104 -2.24% [-8.05%, +3.92%] 1.96254 1.96459
Q18 0.34090 0.33203 -2.61% [-4.98%, -0.18%] 6.63913 6.38904
Q19 0.17535 0.17738 +0.63% [-1.48%, +2.78%] 4.00678 4.02967
Q20 0.17381 0.17258 -0.55% [-6.79%, +6.11%] 3.88151 3.86988
Q21 0.34848 0.33797 -2.83% [-6.11%, +0.57%] 8.57858 8.42019
Q22 0.04962 0.04864 -2.31% [-7.51%, +3.18%] 0.96327 0.95667
Total 3.40463 3.35654 -1.54% [-3.70%, +0.66%] 71.98940 71.08870

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

The initial memory screen flagged Q8 at+1.52% (95% interval+0.40% to+2.65%). The independent same-order confirmation has no slower-query intervals; disk mode has none. Profiles are separate: Q1 instructions126.034B→118.476B(-6.00%), Q9 instructions37.502B→36.909B(-1.58%). The Q1 profiler windows each contain53KiB residual reads and are not strict zero-I/O evidence.

SF100 is running on quiet server129 with the existing database, all64 CPUs/interleaved NUMA and the approved budgets. This PR remains draft until that gate passes. The independent reduction candidate still has unresolved control regressions and is not included in this PR.

@aunjgr

aunjgr commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Complete Q1–Q22 profiling against main

Baseline 3820136ff2, candidate b722651ecb; SF10, all32 CPUs,48GiB application/16GiB cache, existing RAM-backed database. Full cold suite excluded. These are separate CPU-clock/cycle/instruction recordings, not the paired latency acceptance runs already posted. No query data/result verification.

Query Main instr B PR instr B Instructions Δ Main CPU s PR CPU s Zero-I/O windows main/PR
Q1 125.604 118.259 -5.85% 10.7673 10.2092 True/True
Q2 2.713 2.710 -0.09% 0.4254 0.4378 True/True
Q3 13.241 13.205 -0.27% 2.5624 2.5596 True/True
Q4 13.039 13.050 +0.08% 1.7992 1.7917 True/True
Q5 12.135 12.154 +0.15% 1.9242 1.9731 True/True
Q6 6.439 6.443 +0.06% 0.9731 0.9806 False/False
Q7 11.592 11.619 +0.23% 2.2024 2.2269 True/True
Q8 15.512 15.516 +0.03% 2.3502 2.3640 True/True
Q9 37.552 36.703 -2.26% 5.8884 5.8819 True/True
Q10 31.726 31.723 -0.01% 5.0205 5.1990 True/False
Q11 4.341 4.353 +0.26% 0.5610 0.5676 True/True
Q12 20.793 20.791 -0.01% 2.6884 2.7060 True/True
Q13 22.726 22.666 -0.27% 3.7625 3.9237 True/True
Q14 10.802 10.793 -0.08% 1.4013 1.4251 True/True
Q15 16.960 16.939 -0.12% 2.2737 2.3112 True/True
Q16 7.803 7.802 -0.02% 1.3381 1.4959 True/True
Q17 16.366 16.352 -0.09% 1.9812 1.9993 True/True
Q18 23.183 23.230 +0.20% 6.6762 6.7546 True/True
Q19 36.197 36.296 +0.27% 3.9147 3.9664 True/True
Q20 16.710 16.714 +0.03% 3.5729 3.8053 False/False
Q21 74.134 74.070 -0.09% 8.4783 8.4782 True/True
Q22 9.339 9.339 -0.01% 0.9661 0.9821 True/True
Total 528.908 520.725 -1.55% 71.5274 72.0392 —

Separate profiled windows, normalized by completed repetitions. Total sums the per-query normalized costs. These single-window diagnostics are not paired latency acceptance. SIMD is a subset of decimal-expression samples, not an exclusive category. Residual I/O and interference are retained in the JSON records.

The instruction reduction is concentrated in Q1 and Q9. All other20 queries stay within about±0.3% instructions. Across all22 queries, instructions fall528.908B→520.725B(-1.55%), while summed normalized CPU in these separate windows rises71.5274s→72.0392s(+0.72%). This does not establish a full-suite speedup. It must not be summarized using Q1 alone.

No spill, benchmark swap or compiler interference was observed. Non-zero-I/O windows: main Q6 (4096 read bytes), main Q20 (53248 read bytes), typed Q6 (32768 read bytes), typed Q10 (53248 read bytes), typed Q20 (53248 read bytes). They remain flagged rather than being presented as strict zero-I/O evidence.

The earlier paired latency tables cover all22 queries, both memory and disk modes, with Total rows. The memory Q8 screen signal did not reproduce in independent same-order confirmation. SF100 remains unaccepted following its rejected interference window; readiness is unchanged.

Replace AVX-512-only signed64 shifts with AVX2 sign masks and current Go SIMD bitcast operations. Hoist coefficient guards and establish multiplication views outside the row loop. Derive widened sum/difference sign limbs directly while preserving exact 65/129-bit results, declared carriers, checked publication and scalar fallback offsets.

Exact boundary, alias and tail models, owning-package tests, Group consumers, normal SQL comparisons and compiled-kernel ISA inspection pass. This local checkpoint does not claim latency or TPC-H acceptance.
@aunjgr

aunjgr commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Implementation and performance checkpoint (unpublished refinements)

The published PR head remains b722651ecb. The following results belong to
local expression checkpoint 4f39ccbc580e, independently compared with main
007dd57a6192; they do not relabel the historical PR-head measurements.

The refinement replaces AVX-512-only signed64 arithmetic shifts under the AVX2
guard, hoists repeated constants and reduces multiplication/sign-limb work.
Generated-code inspection finds zero EVEX instructions in all35 expression
kernel symbols (40 before). Existing exact arithmetic/alias/refusal tests,
owning-package suites, Group consumer and34-statement SQL comparison pass.
Canonical full-repository SCA and SIMD-enabled changed-package lint pass;
experimental whole-repository SIMD lint has two untouched unsafe findings also
reproduced on clean main. No exclusions or suppressions were added.

Five alternating component-control blocks have no confirmed slower interval.
Compared with the previous candidate, widened Decimal64 add improves4.94%,
Decimal64 multiply9.45%, and Decimal128 multiply4.10%. These isolated gains
are separate from end-to-end acceptance.

Local TPC-H SF10 uses all32 CPUs,48GiB application/16GiB CN cache,32GiB
aggregate/join spill thresholds, no application swap/OOM/spilling, one complete
excluded cold suite and five warm Q1–Q22 suites per startup. RAM has three
independent alternating process pairs. Scripts execute/drain only; they do not
verify input/schema/query results. CPU time is application-cgroup CPU; wall
time is query latency. Total sums per-query medians.

SF10 RAM — complete collection:

Query Main wall s Candidate wall s Wall change (95% CI) Main CPU s Candidate CPU s
Q1 0.37595 0.35940 -4.31% [-5.29%, -3.32%] 10.92997 10.33115
Q2 0.03203 0.03265 +1.28% [-5.41%, +8.45%] 0.52616 0.51146
Q3 0.14067 0.14317 +2.86% [-4.78%, +11.11%] 3.44567 3.50077
Q4 0.08939 0.08587 -4.27% [-9.16%, +0.88%] 2.08301 2.02260
Q5 0.11076 0.11257 -1.00% [-9.13%, +7.86%] 2.41061 2.39561
Q6 0.05026 0.05142 +0.62% [-9.65%, +12.05%] 1.15848 1.14759
Q7 0.11615 0.11643 -1.00% [-7.41%, +5.85%] 2.75280 2.70195
Q8 0.27186 0.27143 +0.14% [-6.75%, +7.54%] 2.85668 2.84243
Q9 0.33625 0.33146 -1.22% [-4.78%, +2.48%] 7.12022 7.18611
Q10 0.28896 0.28545 -1.27% [-3.89%, +1.42%] 6.68454 6.57725
Q11 0.03715 0.03624 -1.86% [-4.92%, +1.30%] 0.59289 0.59134
Q12 0.13420 0.13262 -0.92% [-10.00%, +9.08%] 3.26898 3.21406
Q13 0.16518 0.16484 +0.92% [-2.56%, +4.52%] 4.62089 4.65338
Q14 0.09372 0.09339 -1.39% [-4.42%, +1.73%] 1.67705 1.63584
Q15 0.18508 0.18603 +0.75% [-5.38%, +7.28%] 2.73349 2.77422
Q16 0.15135 0.14844 -0.93% [-5.40%, +3.74%] 1.87460 1.78170
Q17 0.09279 0.09232 -1.63% [-7.61%, +4.73%] 2.24458 2.23661
Q18 0.39055 0.38769 -1.00% [-8.08%, +6.64%] 7.69342 7.52784
Q19 0.20129 0.19697 -2.71% [-5.71%, +0.38%] 4.66702 4.55494
Q20 0.21300 0.21212 +0.58% [-8.49%, +10.55%] 4.93001 4.94109
Q21 0.36580 0.36374 -0.29% [-2.36%, +1.83%] 9.04825 9.00989
Q22 0.05057 0.05103 +1.35% [-2.09%, +4.92%] 0.99981 0.99403
Total 3.89296 3.85529 -0.95% [-2.82%, +0.96%] 84.31911 83.13187

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

Q1 improves4.31% with its95% interval entirely below zero. No query has a
confirmed slower interval; Total's interval overlaps zero, so no overall
speedup is claimed.

SF10 disk — partial collection, two of the required three process pairs:

Query Main wall s Candidate wall s Wall change (95% CI) Main CPU s Candidate CPU s
Q1 0.52713 0.49033 -6.99% [-21.62%, +10.37%] 11.30030 10.58611
Q2 0.03196 0.03280 +2.82% [-53.72%, +128.46%] 0.50069 0.49854
Q3 0.20513 0.19970 -2.62% [-18.52%, +16.40%] 3.38475 3.43343
Q4 0.11303 0.11455 +1.32% [-8.34%, +12.01%] 1.97116 2.04014
Q5 0.19223 0.19086 -0.77% [-16.60%, +18.07%] 2.42432 2.46972
Q6 0.11905 0.10902 -8.42% [-46.80%, +57.66%] 1.13256 1.15382
Q7 0.20738 0.20917 +1.01% [-39.03%, +67.36%] 2.76523 2.96385
Q8 0.35142 0.34799 -0.99% [-7.93%, +6.47%] 2.86644 2.72122
Q9 0.44803 0.46966 +4.53% [-50.41%, +120.35%] 7.49916 7.59138
Q10 0.35524 0.35275 -0.70% [-8.01%, +7.20%] 6.45429 6.36977
Q11 0.03800 0.03711 -2.35% [-7.13%, +2.68%] 0.57489 0.57672
Q12 0.20173 0.20348 +0.51% [-57.09%, +135.41%] 3.28634 3.24704
Q13 0.16854 0.16693 -0.95% [-15.38%, +15.95%] 4.71950 4.64864
Q14 0.16008 0.16428 +2.59% [-10.98%, +18.22%] 1.66355 1.84352
Q15 0.31321 0.31081 -0.80% [-18.43%, +20.65%] 2.87765 2.81968
Q16 0.14527 0.14627 +0.68% [-23.29%, +32.13%] 1.73783 1.71888
Q17 0.19328 0.19218 -0.58% [-27.09%, +35.58%] 2.18542 2.18735
Q18 0.40208 0.40476 +0.66% [-11.55%, +14.55%] 7.26869 7.29565
Q19 0.34105 0.34095 -0.20% [-53.83%, +115.71%] 4.82134 4.98657
Q20 0.27513 0.28237 +2.62% [-27.55%, +45.36%] 4.57266 4.76387
Q21 0.50540 0.49951 -1.23% [-25.61%, +31.15%] 8.88896 9.01668
Q22 0.05244 0.05278 +0.66% [-4.82%, +6.45%] 0.96778 0.97911
Total 5.34680 5.31825 -0.56% [-18.56%, +21.42%] 83.86352 83.91169

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

The quiet-window attempt retained another complete valid disk pair. The final
pair was rejected at2.76393 outside CPU cores against the unchanged2-core
limit. Lightweight process samples show Btrfs workers, memory reclaim and
CodeGraph activity; kernel-worker CPU outside the application cgroup is not
necessarily unrelated work. Rejected timing is excluded, and completed pairs
remain intact. No further retry is queued.

The same independent sources are built on server129 without transferring data
or reloading its retained SF100 database. SF100's first main block was rejected
at2.01255 outside cores before any complete pair. All run-owned services have
exited. This PR stays draft until the final local disk pair and required SF100
acceptance finish. No performance gate is waived.

@aunjgr

aunjgr commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Local acceptance completed for expression checkpoint 4f39ccbc580e against
main 007dd57a6192. All three independent process pairs are now valid in both
SF10 RAM and disk modes. Each process excludes the full cold Q1–Q22 suite and
scores five full warm suites, with the existing32-CPU,48GiB application/16GiB
cache, no spill/swap/OOM/interference protocol. No data/schema/result verification
is performed by the timing scripts. Rejected attempts remain excluded.

No query or Total has a confirmed slower95% interval in either mode. RAM Q1
improves4.31%; the overall RAM/disk speedup remains inconclusive. Positive point
estimates and their full intervals are retained below. Total sums per-query
medians; CPU is application-cgroup CPU time, wall is query latency.

SF10 RAM:

Query Main wall s Candidate wall s Wall change (95% CI) Main CPU s Candidate CPU s
Q1 0.37595 0.35940 -4.31% [-5.29%, -3.32%] 10.92997 10.33115
Q2 0.03203 0.03265 +1.28% [-5.41%, +8.45%] 0.52616 0.51146
Q3 0.14067 0.14317 +2.86% [-4.78%, +11.11%] 3.44567 3.50077
Q4 0.08939 0.08587 -4.27% [-9.16%, +0.88%] 2.08301 2.02260
Q5 0.11076 0.11257 -1.00% [-9.13%, +7.86%] 2.41061 2.39561
Q6 0.05026 0.05142 +0.62% [-9.65%, +12.05%] 1.15848 1.14759
Q7 0.11615 0.11643 -1.00% [-7.41%, +5.85%] 2.75280 2.70195
Q8 0.27186 0.27143 +0.14% [-6.75%, +7.54%] 2.85668 2.84243
Q9 0.33625 0.33146 -1.22% [-4.78%, +2.48%] 7.12022 7.18611
Q10 0.28896 0.28545 -1.27% [-3.89%, +1.42%] 6.68454 6.57725
Q11 0.03715 0.03624 -1.86% [-4.92%, +1.30%] 0.59289 0.59134
Q12 0.13420 0.13262 -0.92% [-10.00%, +9.08%] 3.26898 3.21406
Q13 0.16518 0.16484 +0.92% [-2.56%, +4.52%] 4.62089 4.65338
Q14 0.09372 0.09339 -1.39% [-4.42%, +1.73%] 1.67705 1.63584
Q15 0.18508 0.18603 +0.75% [-5.38%, +7.28%] 2.73349 2.77422
Q16 0.15135 0.14844 -0.93% [-5.40%, +3.74%] 1.87460 1.78170
Q17 0.09279 0.09232 -1.63% [-7.61%, +4.73%] 2.24458 2.23661
Q18 0.39055 0.38769 -1.00% [-8.08%, +6.64%] 7.69342 7.52784
Q19 0.20129 0.19697 -2.71% [-5.71%, +0.38%] 4.66702 4.55494
Q20 0.21300 0.21212 +0.58% [-8.49%, +10.55%] 4.93001 4.94109
Q21 0.36580 0.36374 -0.29% [-2.36%, +1.83%] 9.04825 9.00989
Q22 0.05057 0.05103 +1.35% [-2.09%, +4.92%] 0.99981 0.99403
Total 3.89296 3.85529 -0.95% [-2.82%, +0.96%] 84.31911 83.13187

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

SF10 disk:

Query Main wall s Candidate wall s Wall change (95% CI) Main CPU s Candidate CPU s
Q1 0.52572 0.49562 -4.54% [-15.04%, +7.25%] 11.26167 10.69306
Q2 0.03229 0.03287 +2.87% [-12.00%, +20.25%] 0.46370 0.47607
Q3 0.19852 0.19874 +0.14% [-11.62%, +13.46%] 3.37840 3.37679
Q4 0.11441 0.11225 -2.64% [-18.08%, +15.72%] 2.01478 2.03464
Q5 0.18635 0.18693 -0.41% [-4.06%, +3.38%] 2.42203 2.46218
Q6 0.11645 0.11130 -3.58% [-24.58%, +23.26%] 1.11618 1.13352
Q7 0.19815 0.21119 +2.84% [-9.27%, +16.55%] 2.74216 3.01256
Q8 0.34325 0.33792 -0.52% [-2.95%, +1.97%] 2.83160 2.82327
Q9 0.43951 0.43323 +2.87% [-12.44%, +20.87%] 7.35578 7.53067
Q10 0.35091 0.35056 +2.22% [-9.83%, +15.87%] 6.44576 6.37713
Q11 0.03809 0.03705 -3.04% [-6.13%, +0.14%] 0.56195 0.56660
Q12 0.19774 0.20422 +3.76% [-16.36%, +28.73%] 3.28427 3.18542
Q13 0.16637 0.16684 -0.69% [-3.90%, +2.63%] 4.70783 4.64596
Q14 0.16198 0.15834 +0.95% [-6.30%, +8.76%] 1.68009 1.64354
Q15 0.30948 0.31367 +0.23% [-5.47%, +6.28%] 2.85266 2.80783
Q16 0.14436 0.14405 +1.03% [-4.40%, +6.77%] 1.70813 1.71644
Q17 0.19443 0.19231 -0.75% [-6.63%, +5.51%] 2.15410 2.15906
Q18 0.40082 0.39937 +0.82% [-1.79%, +3.49%] 7.24931 7.23590
Q19 0.34047 0.36102 +4.07% [-17.74%, +31.67%] 4.73941 4.91349
Q20 0.27460 0.27766 +1.18% [-7.66%, +10.86%] 4.42631 4.66486
Q21 0.49660 0.51935 +1.36% [-10.49%, +14.77%] 8.82605 8.97837
Q22 0.05194 0.05198 -0.92% [-7.49%, +6.13%] 0.95382 1.00004
Total 5.28241 5.29649 +0.55% [-5.48%, +6.97%] 83.17598 83.43740

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

The exact-source full pre-push gate passed with zero issues; previous unchanged
SIMD-specific tests/lint, arithmetic models and normal SQL comparison evidence
remain valid. The draft source update includes the AVX2 ISA correction and
kernel refinements described above. SF100 is running separately on server129
using the retained database, with no data transfer/reload. Its first main
process passed; a complete paired SF100 verdict is not yet available. This PR
remains draft. The failing reduction candidate stays separate and unpublished.

@aunjgr

aunjgr commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

SF100 RAM completed on expression 4f39ccbc580e versus main 007dd57a6192,
using the retained server129 database, all64 CPUs/interleaved NUMA,
216GiB application/192GiB CN cache,32GiB spill thresholds, no application
spill/swap/OOM, and the unchanged outside-CPU guard. Three independent
alternating process pairs each exclude a full cold Q1–Q22 suite and score
five full warm suites. Scripts execute/drain only, without data/schema/result
verification. Only242,530 encoded bytes of compressed timing/resource results
were downloaded; no dataset, loaded image or executable was transferred.

Q1 improves3.70% (95% CI -4.78% to -2.60%). Total wall improvement is
inconclusive. Q15 is flagged at+0.269% (+0.028% to +0.510%); its CPU changes
are mixed across the pairs, so the cause is not established. This remains a
failed readiness gate; no regression signal is dismissed because it is small.

The disk phase was stopped once the complete RAM failure was identified.
All owned processes from that screen exited; unrelated jobs were untouched.
One predeclared additional full-suite RAM pair will be combined with all three
original pairs, with separate Q15 CPU profiles and acknowledged fixed-work
instruction counters collected after scoring. No further confirmation pairs
are planned after that collection. This PR remains draft.

Query Main wall s Candidate wall s Wall change (95% CI) Main CPU s Candidate CPU s
Q1 5.31420 5.11746 -3.70% [-4.78%, -2.60%] 319.06659 307.16865
Q2 0.33037 0.32787 -1.13% [-2.65%, +0.40%] 11.14795 11.13245
Q3 1.94631 1.93939 +0.76% [-2.35%, +3.96%] 87.89842 89.08795
Q4 1.39385 1.36039 -1.80% [-5.79%, +2.35%] 58.98958 58.73334
Q5 1.92390 1.91714 -0.79% [-9.10%, +8.28%] 77.06325 76.67858
Q6 1.03750 1.04476 -0.84% [-12.55%, +12.45%] 41.89316 40.77880
Q7 1.78509 1.79267 +0.75% [-0.80%, +2.33%] 84.56757 84.60868
Q8 2.63687 2.62711 -0.09% [-5.75%, +5.90%] 83.30661 83.03487
Q9 8.00093 7.99606 -0.05% [-0.22%, +0.12%] 334.88663 333.83104
Q10 4.33412 4.31099 -0.46% [-2.18%, +1.28%] 153.83799 153.80745
Q11 0.44969 0.45422 +0.62% [-2.94%, +4.31%] 13.40859 13.45104
Q12 1.87128 1.87854 -0.15% [-6.24%, +6.35%] 89.86364 90.26268
Q13 2.49698 2.52913 +1.00% [-0.67%, +2.70%] 135.07595 134.89091
Q14 1.29482 1.28671 -1.17% [-3.79%, +1.53%] 49.71738 49.17309
Q15 2.70802 2.71778 +0.27% [+0.03%, +0.51%] 90.52780 90.26464
Q16 1.67752 1.67229 +0.08% [-1.51%, +1.70%] 35.42465 35.11655
Q17 1.59679 1.59018 -0.93% [-8.11%, +6.81%] 70.94991 70.91847
Q18 8.13328 8.13349 -0.17% [-6.65%, +6.75%] 179.29544 179.36178
Q19 3.12804 3.12065 +0.17% [-7.15%, +8.06%] 149.75961 149.89663
Q20 3.64232 3.64404 -0.02% [-4.19%, +4.33%] 127.98242 127.49504
Q21 6.06507 6.00518 -1.05% [-6.51%, +4.74%] 256.72790 255.27265
Q22 0.62918 0.63512 +0.87% [-0.88%, +2.64%] 29.81507 29.85079
Total 62.39615 62.10117 -0.50% [-2.90%, +1.95%] 2481.20611 2464.81609

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

Compute native add/sub in overflow-checked AVX2 prefixes and resume scalar execution at the first untouched block. Preserve in-place and broadcast operands, scale alignment, NULL handling and first-error publication.

Use direct one-row scalar handling and signed-overflow identities to reduce fallback setup. Cover full signed128 endpoints, every overflow lane, aliases, broadcasts and untouched suffixes with independent exact models.
@aunjgr
aunjgr marked this pull request as draft November 6, 2026 08:58
@aunjgr aunjgr changed the title perf(decimal): accelerate revenue, multiplication, and widening casts perf(decimal): vectorize expression arithmetic and widening casts Nov 6, 2026
A nonnegative left operand can overflow only when subtrahend and result are both negative; a negative left operand can overflow only when both are nonnegative. Choose once before the scalar loop to remove repeated XORs while retaining full signed128 overflow and publication semantics.
@aunjgr

aunjgr commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Decimal128 add/sub correction: b765029

Published commit b7650291b13994563c0e9b4f9fd6ecf457ac86b4, including authoritative main dfc3ab0e382d7c21ca66aa1a03744b0c48c9d7ac. Native add/sub uses fully checked eight-row AVX2 prefixes with scalar first-error continuation, exact aliases and cached broadcasts. Other new SIMD families remain separate.

Correctness and static validation

  • Full owning function package passes in SIMD mode (Go1.27.1,20.680s); ordinary scalar-build checks and exact full-range/overflow-lane/alias/NULL models pass.
  • Existing SQL case passes all49 statements twice, with teardown absence checked before repetition; test-owned services are stopped.
  • Incremental SIMD static analysis and the complete pre-push gate pass with zero issues (final gate254.37s). Both native kernels pass the AVX2/no-EVEX audit.

Component qualification

Five fixed alternating process pairs compare independent binaries with the same main context, identical fixtures, Go1.27.1, GOAMD64=v3, GOEXPERIMENT=simd and64-byte function alignment. First warm-ups are excluded; compiler/interference guards apply. The initial complete pair is retained after a compiler interruption, and resumption executes only missing arms, without adding scored pairs.

All156 controls have zero confirmed regressions and zero allocations. The earlier V2 gate failed at constant-left subtraction n15 (+2.43% [1.86%,3.01%]); that failed result is retained. Hoisting the constant-sign decision corrects the scalar path. Component confidence intervals use the registered unadjusted95% paired t method on log ratios.

Operation/control Before ns/op Corrected ns/op Paired change (95% CI)
add128, n128, flat 112.900 104.900 -7.54% [-13.05%, -1.67%]
add128, n256, flat 228.400 192.600 -16.17% [-19.92%, -12.24%]
add128, n8192, flat 8466.000 6116.000 -26.45% [-30.86%, -21.77%]
sub128, n128, flat 109.800 101.800 -7.69% [-9.13%, -6.23%]
sub128, n256, flat 220.100 193.600 -12.01% [-12.39%, -11.62%]
sub128, n8192, flat 7068.000 6093.000 -13.62% [-14.84%, -12.37%]
sub128, n15, left_const 15.860 15.280 -3.75% [-4.20%, -3.29%]

End-to-end acceptance remains incomplete

The local disk-backed SF100 Q1–Q22 comparison uses all32 CPUs,48GiB application/no swap,16GiB CN shared cache,32GiB aggregation/join spill thresholds and excluded cold suites. Two of three registered pairs are complete; Cargo restarted before the final pair. All four accepted suites are retained, and no spill/swap/OOM/compiler interference was accepted. This is a bounded screen with one scored warm full suite per startup.

Accepted pair Main Total wall s Candidate Total wall s
1 71.49858 78.08008
2 81.68430 77.44382

These partial totals are not an acceptance verdict. The missing final SF100 pair and SF10 RAM/disk runs still need a compiler-free window. No row/schema/result verification is performed in benchmark scripts; existing loaded SF100 data is reused. SF10 raw inputs remain, and its load/run scripts are prepared without loading data.

The PR remains draft under the existing performance gate. The independent shared-CI mode prerequisite is still #32325 / matrixorigin/CI#473; it is not bypassed by these local results.

Separate compressed raw evidence

Component release: seven separate gzip files,50,671 bytes total. They contain both failed V2 and corrected V3 raw pairs/intervals plus source/compiler metadata; no executable, database or sampled stack memory.

File Bytes
decimal128-v2-records.json.gz 16894
decimal128-v2-comparison.json.gz 7701
decimal128-v2-decision.json.gz 210
decimal128-v3-records.json.gz 16797
decimal128-v3-comparison.json.gz 7705
decimal128-v3-decision.json.gz 161
decimal128-builds-and-protocol.json.gz 1203

@aunjgr

aunjgr commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Performance and validation history moved from the PR description

This is an archived snapshot, copied intact from the description so the PR body can remain focused on the change and design. It contains results for several explicitly identified historical revisions, including superseded status statements. Those statements describe their original snapshots; they are not the latest PR state.

For the published Decimal128 correction and remaining acceptance work, see the newer result comment.

  • Owning function/colexec/Group suites pass; the final focused exact/public-vector models also pass after merging newest main. Tests include signed endpoints,65-bit differences, every block-refusal lane, NULLs, broadcasts, offsets/tails, constant cast chunk boundaries, scale growth and narrowing errors.
  • The extended SQL fixture passes normal comparison, including Q9-style projection, selected CASE casts with an invalid unselected branch, and nullable widening.
  • The complete canonical pre-push gate passes on88dc633dbeff against main57e7871e50. Selected SIMD-mode lint passes; the retained kernel ISA audit has zero EVEX instructions.

Current native Decimal128 extension: validation and remaining gates

The requester adds native Decimal128 add/sub to this PR and defers other new kernels. The native addition is commit d430e502520142dc39cae26c3fa5ed6041e440fe; current head eda47b80c957a24ed2f8696dc59df85b5472cb98 includes authoritative main dfc3ab0e382d7c21ca66aa1a03744b0c48c9d7ac. This expanded scope is draft pending performance qualification.

  • Independent exact models cover signed128 endpoints, carry/borrow, every overflow lane, tails, broadcasts, exact aliases, NULLs and untouched output suffixes. Focused SIMD and ordinary scalar-build checks pass; the full owning function package passes in SIMD mode (20.732s), using Go1.27.1.
  • Existing expression/decimal_mul_sub.sql: all49 statements pass twice on a fresh owned instance. Teardown absence is checked before repetition. Single-node native wide-column add/sub retains its ordinary owner because aggregate-chain preparation declines one-node/no-cast expressions.
  • Incremental SIMD molint/golangci and the complete canonical pre-push gate pass with zero issues. Both new native kernels pass the instruction audit with no EVEX/AVX512 instructions.
  • The first exploratory screen showed larger-array gains but one-row regressions. The refined code removes batch setup for one row and simplifies scalar overflow checks. The published head retains the V2 result: 15-row constant-left subtraction +2.43% [1.86%, +3.01%], so that component gate fails. The local constant-sign correction b7650291b1 now completes all five paired runs with zero confirmed regressions and zero allocations across156 controls; the flagged case changes by -3.75% [-4.20%, -3.29%]. Both signs/aliases/NULLs pass exact tests, and the SQL case passes twice. This correction is not yet pushed: its full Q1-Q22 SF100 comparison against clean main is running, and final delivery checks remain.
  • Current-head Q1–Q22 wall/CPU acceptance is also pending. Reuse the loaded local data, exclude cold runs and reject spill/swap/OOM/interference. All timing tables below belong to their explicitly identified earlier commits and do not qualify this head.
  • The separate coverage-mode prerequisite is matrixorigin/CI#473, whose checks pass but which is not merged. #32325 tracks its independent MO caller opt-in and subsequent fresh merged-coverage verification. The earlier40.34% failure is not a new-head coverage verdict.

Small-batch multiplication and aggregate-reduction changes are outside this extension. The independent reduction PR retains its own performance blockers.

Earlier qualification through expression88dc633dbe

The preceding expression88dc633dbeff scope included authoritative main57e7871e50. This section records that earlier qualification; it does not qualify the newly added native Decimal128 path. The component comparison uses main5792e1c372; the later main merge changes neither the measured arithmetic sources nor their contracts. Unchanged closures retain their evidence, and changed one-row/cast closures were remeasured after fixes. All rejected revisions and raw intervals are retained.

Five alternating process pairs cover171 retained controls, with the first benchmark selection excluded. There is no confirmed slower control and no per-operation allocation. Ordinary checked Decimal64/Decimal128 add/sub candidates failed their controls and are removed. The table reports kernel elapsed time, not a whole-query speedup.

Kernel Rows Main ns/op Candidate ns/op Paired change (95% CI)
fused 32 89.18 49.31 -44.65% [-45.00%, -44.31%]
fused 64 153.50 64.30 -57.91% [-58.35%, -57.46%]
fused 8192 17125.00 4045.00 -76.29% [-76.55%, -76.03%]
multiply 32 68.15 27.01 -60.33% [-60.44%, -60.23%]
multiply 64 130.70 39.64 -70.03% [-70.67%, -69.38%]
multiply 8192 16280.00 3489.00 -78.60% [-78.75%, -78.45%]
cast 64 50.84 41.40 -16.53% [-22.17%, -10.48%]
cast 128 79.11 59.67 -24.73% [-25.07%, -24.39%]
cast 8192 3886.00 2500.00 -35.57% [-36.21%, -34.92%]

Historical SF10 results for expression88dc633dbe

Matched sources57e7871e50 /88dc633dbe complete all22 local SF10 queries in RAM-backed and disk-backed modes, with Total wall/CPU rows below. Three alternating pairs, five warm suites after one excluded cold suite, all32 CPUs,48GiB application/16GiB CN cache and32GiB spill thresholds. No spill/swap/OOM/compiler interference was accepted. No query regression is Holm-confirmed and neither mode has a primary Total regression.

RAM Q9 improves3.23% [95% CI -4.26%,-2.19%], adjusted target p0.005675; Q14 improves2.29% [-2.48%,-2.10%], adjusted p0.000557. Their instructions decrease in both separate diagnostic pairs: Q9 -2.06%/-2.92%; Q14 -0.79%/-0.47%. Q5 benefit is not confirmed. RAM Total's paired estimate is -0.56% [-1.40%,+0.29%]; overall speedup is not established. Disk variability leaves its Total and target benefits inconclusive.

Actual instrumentation confirms Q9's shared prepared D64 multiply and Q14's fused revenue/selected widening. Ordinary D64-product admission is zero for these targets; it is not credited for their gains. The separately instrumented executable is excluded from timing. Hardware counts have CPU profiling disabled; the12 CPU profiles use separate short known-query workloads.

Query Main wall s Candidate wall s Wall change (95% CI) Main CPU s Candidate CPU s
Q1 0.25742 0.23117 -10.03% [-15.82%, -3.84%] 7.28292 6.51510
Q2 0.02873 0.02856 -0.90% [-3.23%, +1.49%] 0.43593 0.42323
Q3 0.10455 0.10657 +2.10% [-5.40%, +10.19%] 2.48923 2.53127
Q4 0.07477 0.07388 +3.16% [-16.10%, +26.83%] 1.74527 1.74995
Q5 0.09507 0.09426 +0.83% [-6.09%, +8.27%] 1.91158 1.92165
Q6 0.04418 0.04310 -0.20% [-13.07%, +14.57%] 0.95802 0.97290
Q7 0.09414 0.09521 +1.96% [-1.71%, +5.76%] 2.16114 2.17558
Q8 0.23951 0.23805 -0.05% [-1.99%, +1.92%] 2.41954 2.38510
Q9 0.27955 0.27035 -3.23% [-4.26%, -2.19%] 5.77053 5.94871
Q10 0.21935 0.22420 +1.52% [-0.92%, +4.03%] 4.99895 5.02496
Q11 0.03563 0.03581 -1.94% [-8.38%, +4.96%] 0.53417 0.53906
Q12 0.11093 0.11223 +1.34% [-4.76%, +7.84%] 2.70782 2.69097
Q13 0.13140 0.13323 +0.22% [-6.52%, +7.43%] 3.70126 3.71671
Q14 0.08267 0.08083 -2.29% [-2.48%, -2.10%] 1.44794 1.43049
Q15 0.16160 0.15965 +0.89% [-6.20%, +8.51%] 2.31258 2.24583
Q16 0.12720 0.12655 -0.03% [-1.79%, +1.76%] 1.33512 1.34978
Q17 0.08539 0.08218 -1.66% [-15.16%, +13.98%] 1.94121 1.94988
Q18 0.32328 0.32725 +0.72% [-6.22%, +8.18%] 6.22837 6.20716
Q19 0.17785 0.17793 +0.23% [-5.84%, +6.68%] 3.99832 4.01941
Q20 0.17067 0.17211 +1.18% [-1.15%, +3.57%] 3.82543 3.83474
Q21 0.33729 0.34264 +0.60% [-4.54%, +6.03%] 8.39429 8.50809
Q22 0.04905 0.04969 +1.12% [-6.25%, +9.08%] 0.95710 0.95175
Total 3.23023 3.20545 -0.56% [-1.40%, +0.29%] 67.55672 67.09231

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

Query Main wall s Candidate wall s Wall change (95% CI) Main CPU s Candidate CPU s
Q1 0.33883 0.28769 -8.65% [-23.96%, +9.74%] 7.28899 6.31906
Q2 0.02989 0.02989 +0.67% [-4.77%, +6.43%] 0.39416 0.38120
Q3 0.14030 0.13336 -2.61% [-53.47%, +103.85%] 2.42892 2.51897
Q4 0.10282 0.09256 -4.85% [-31.29%, +31.76%] 1.73347 1.69119
Q5 0.10858 0.10850 +7.77% [-52.33%, +143.65%] 1.85190 1.85597
Q6 0.07312 0.06490 +11.88% [-39.99%, +108.57%] 0.92025 0.89316
Q7 0.14046 0.12649 +3.66% [-33.42%, +61.39%] 2.12513 2.09690
Q8 0.26461 0.25933 -1.14% [-33.72%, +47.46%] 2.35544 2.36452
Q9 0.31539 0.28746 -3.37% [-40.38%, +56.61%] 6.09551 5.82985
Q10 0.24107 0.23362 +1.11% [-30.44%, +46.98%] 5.01683 5.10247
Q11 0.03500 0.03481 -2.48% [-6.62%, +1.85%] 0.54056 0.53530
Q12 0.17721 0.17643 +1.32% [-17.61%, +24.61%] 2.61187 2.56702
Q13 0.13607 0.13394 -0.83% [-3.05%, +1.44%] 3.79203 3.78049
Q14 0.11628 0.10336 +3.74% [-42.06%, +85.76%] 1.43829 1.37946
Q15 0.21739 0.21711 +7.58% [-34.90%, +77.77%] 2.32557 2.25239
Q16 0.12784 0.12848 +0.71% [-3.34%, +4.93%] 1.30452 1.31172
Q17 0.12426 0.13262 +2.84% [-63.94%, +193.29%] 1.88054 1.90282
Q18 0.33616 0.33632 +0.05% [-7.19%, +7.87%] 6.15916 6.24442
Q19 0.23718 0.22211 -1.08% [-39.42%, +61.51%] 3.92296 3.90332
Q20 0.21589 0.21458 +2.16% [-27.16%, +43.26%] 3.48152 3.84497
Q21 0.44452 0.39690 -5.58% [-40.17%, +49.00%] 8.19089 8.32581
Q22 0.05024 0.05035 -0.28% [-9.34%, +9.69%] 0.94602 0.94691
Total 3.97310 3.77080 -0.40% [-30.46%, +42.66%] 66.80453 66.04790

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

The displayed Total sums query medians; paired changes use independent process blocks. The approved Total/query/target Holm gates and all raw intervals are retained. Profiles and raw evidence are58 separate compressed files (1.08MB), without binaries/database/heap/raw stack-memory recordings.

The 88dc633 local SF100 disk-backed screen is now complete (below). It establishes neither a suite speedup nor a regression; the wide interval is not evidence of equivalence. The separate CI coverage failure remains a merge blocker; ready-for-review status does not claim CI is green. The 88dc633dbe coverage check fails at40.34% (required >75%), with the same untested SIMD-backend files. The coverage producer omits SIMD-tagged unit tests. Shared CI workflow changes were explicitly kept out of scope; local tests/full static gates do not clear this CI blocker.

Historical local SF100 disk-backed results for expression88dc633dbe

Independent current main 57e7871e50 vs this PR 88dc633dbe; all 32 local CPUs, 48GiB application budget, 16GiB CN cache, 32GiB aggregation/join spill thresholds. Three alternating process pairs, one excluded cold full suite and one scored warm full suite per startup. This is a bounded local disk-backed screen, not an all-memory or five-warm-suite experiment. No spill/swap/OOM/compiler interference was accepted. The reduction PR is excluded.

Query Main wall s Candidate wall s Wall change (95% CI) Main CPU s Candidate CPU s
Q1 5.82908 5.29415 -5.45% [-15.02%, +5.21%] 102.82322 96.03421
Q2 0.40577 0.42216 +3.13% [-13.62%, +23.13%] 5.84556 5.79136
Q3 3.35783 3.08087 -2.46% [-24.32%, +25.72%] 45.29298 45.90220
Q4 2.39049 2.36850 +3.40% [-18.65%, +31.44%] 35.17192 35.43575
Q5 3.28500 2.99125 +0.03% [-27.84%, +38.66%] 43.35231 42.78621
Q6 1.82237 1.59217 -2.61% [-32.17%, +39.82%] 19.42201 19.97047
Q7 3.86207 3.46276 -2.61% [-32.95%, +41.46%] 42.85703 42.40776
Q8 3.27036 2.96523 -2.08% [-20.06%, +19.94%] 41.08885 40.29181
Q9 7.50551 7.33878 -0.64% [-5.50%, +4.46%] 147.42788 146.78913
Q10 4.81038 4.66994 +0.09% [-11.39%, +13.07%] 78.55577 78.87935
Q11 0.58040 0.57402 +1.59% [-9.06%, +13.50%] 6.63285 6.50614
Q12 4.01003 4.04440 -0.84% [-10.76%, +10.18%] 49.54114 48.75216
Q13 2.56110 2.55539 -0.09% [-4.73%, +4.76%] 70.22027 69.89968
Q14 3.03054 2.79935 -4.77% [-18.62%, +11.45%] 24.64237 24.39573
Q15 4.89846 4.57020 -1.37% [-27.16%, +33.53%] 46.36191 46.19413
Q16 0.68142 0.64797 -5.78% [-17.76%, +7.94%] 11.49354 10.87960
Q17 3.50114 3.20738 -0.97% [-23.28%, +27.82%] 35.79892 35.38564
Q18 5.67166 5.69692 +0.95% [-4.83%, +7.08%] 93.77245 93.45585
Q19 5.21712 4.96085 -1.75% [-8.81%, +5.85%] 70.30506 70.11510
Q20 3.91322 3.81145 -1.55% [-7.60%, +4.90%] 50.89518 49.62090
Q21 8.64508 8.33387 -0.13% [-11.73%, +12.99%] 119.20083 119.19689
Q22 0.49151 0.48140 -3.61% [-15.37%, +9.78%] 11.30262 11.50144
Total 79.74053 75.86899 -1.29% [-13.70%, +12.90%] 1152.00467 1140.19151

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

Paired Total wall is −1.29% [−13.70%, +12.90%] and paired CPU is −0.99% [−3.81%, +1.91%]: neither establishes an overall improvement. No raw 95% query slowdown interval is wholly positive, and no query fails the approved Holm gate. Displayed medians and paired percentages use different estimators; this is not a ratio-of-displayed-medians claim. Q5/Q9/Q14 wall changes remain inconclusive.

Full paired data, resource limits and six separate gzip evidence files: complete SF100 report. The benchmark is stopped; the reusable loaded image is retained. No production code was changed for this screen.

Historical measurements and profiles

Everything below predates this coverage revision: expression4f39ccbc580e versus main007dd57a6192, before the dense-state main integration. These results remain historical and do not qualify88dc633dbeff.

Five alternating component blocks have no confirmed slower control and no
per-operation allocations. Against the previous candidate, Decimal64 widened
add improves4.94%, Decimal64 multiply9.45%, and Decimal128 multiply4.10%.
The subtract interval overlaps zero. The generated-code audit finds zero EVEX
instructions in all35 production expression symbols, versus40 before the guard
correction. These are component/ISA results, not whole-query speedup claims.

The complete local SF10 RAM/disk tables
use all32 CPUs,48GiB application/16GiB CN cache,32GiB spill thresholds, three
alternating process pairs and five full warm suites per startup after excluding
a full cold suite. No spill/swap/OOM/interference is accepted. RAM Q1 improves
4.31%; RAM Total is3.89296s→3.85529s, paired-0.95% [-2.82%,+0.96%], with CPU
84.31911s→83.13187s. Disk Total is5.28241s→5.29649s, paired+0.55%
[-5.48%,+6.97%], with CPU83.17598s→83.43740s. Neither mode establishes an
overall speedup, and neither has a raw confirmed slower query/Total interval.

The complete four-pair SF100 RAM table
uses the retained server129 database,64 CPUs/interleaved NUMA,
216GiB application/192GiB CN cache and the same cold exclusion/spill rules.
Total wall is62.43583s→62.18310s, paired-0.36% [-1.70%,+1.00%]; CPU is
2476.01304s→2463.76410s. Q1 improves3.78% [-4.40%,-3.15%], but the suite Total
remains inconclusive. There is no primary Total or Holm-confirmed query
regression. Q13 retains its raw+1.03% [+0.15%,+1.92%] interval; its adjustedp
is0.36896. The original Q15 screen signal's combined interval overlaps zero.
All valid observations are retained, including the one predeclared confirmation.

Q15 diagnostic profiles and counters
are uploaded as eight separate compressed assets (835,476 bytes). The fixed-work
instruction count is293.578477B→293.510575B per request (-0.0231%); cycles are
+0.7194%. These isolated diagnostics exclude the first Q15 execution; early
warming and profiling overhead mean their timings are not acceptance. The
30-second Go sampling window may cover only part of the eight-request batch.
No executable, database or sampled stack-memory recording is included.

SF100 disk startup did not launch: its preflight measured29.28 busy CPU cores.
All benchmark services owned by these attempts exited; no timing retry is queued.
Benchmark scripts execute/drain only, without data/schema/result verification.
Total always sums per-query medians. The independent reduction work is
draft#32266.

Historical profiling

The earlier all22-query profile comparison
compared published predecessor b722651ecb with main 3820136ff2, not the current
refinements. Its instruction reduction and old latency tables remain historical
evidence for those source identities. They are not current-source acceptance.

@aunjgr

aunjgr commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Current-head CI diagnosis and actual Decimal128 SIMD coverage

Source b7650291b13994563c0e9b4f9fd6ecf457ac86b4. This is a new comment; the PR/issue description is unchanged.

CI has two separate failures

  • Required UT: TestIssue25590QueueMembershipDeduplicatesAtScale times out at the second reopened drain; TestInventoryCASRCTransfer reads epoch 1 rather than 2 after commit/RowID transfer. Both test sources are unchanged by this PR.
  • Independent clean main dfc3ab0e38 passes both isolated tests in CI build mode (Go 1.27.1, race, matrixone_test, GOAMD64=v1, no SIMD). The bounded adaptive race protocol then passes 69 queue repetitions and 4 RC-transfer repetitions. This does not reproduce or resolve the CI failure, and does not justify weakening assertions or silently increasing deadlines. The complete CI process reached its 16 GiB memory boundary without OOM. That observation does not establish the cause of either failure.
  • Merged coverage: 209/432 = 48.38%, required >75%. The shared producer still omits the SIMD build mode. CI#473 is green but unmerged, so neither it nor the separate MO caller opt-in has changed this run. Local arithmetic tests cannot make that required job pass.

Confirmed clean-main scheduling counterexample

A private Go source overlay adds only two scheduling/observation hooks to clean main dfc3ab0e38; it changes no production branch or queue decision. A single race-enabled diagnostic (Go 1.27.1, scalar CI mode) forces this interleaving:

  1. The successful drain reads an empty queue and records resched=false, then pauses before its deferred scheduling-slot release.
  2. A second enqueue accepts a new member. It sees drainScheduled=true, so it cannot start a successor.
  3. The first drain releases the slot and exits with its stale resched=false.
  4. After that worker has completed, the diagnostic positively observes one pending member and drainScheduled=false. An explicit retry then collects the member and is joined for cleanup.

The diagnostic completed in 13.53 seconds including compilation and printed confirmed missed immediate handoff: pending=1 scheduled=false. Its passing assertion means the bad state was observed, not that the production bug is fixed. The drain source is identical between this clean main and #32237. This is a concrete pre-existing missed-handoff window consistent with the failing queue test, whose mock engine does not run the periodic GC retry scheduler; it is not proof that the archived CI run took this exact interleaving.

The fix needs to make the successful-drain queue check and scheduling-slot release one synchronized handoff, preserving the bounded retry policy on deletion failure. Increasing the test timeout would not address this state. No queue/transaction production changes were folded into this decimal PR. The separate integer RC-transfer failure remains unattributed; isolated passes do not waive it.

Why component speedups yield little TPC-H improvement

A diagnostic-only source overlay counts the native and prepared D128 add/sub paths across all 22 SF100 queries, with all 32 CPUs, 48 GiB/no swap, 16 GiB cache and 32 GiB spill thresholds. One complete cold suite is excluded before counter collection. Production source and the timed executable remain unchanged. These are activation counts, not latency acceptance.

Query Native add values Native subtract values Native subtract SIMD values Prepared subtract input values
Q1 0 0 0 0
Q2 0 0 0 0
Q3 0 0 0 0
Q4 0 0 0 0
Q5 0 0 0 0
Q6 0 0 0 0
Q7 0 0 0 0
Q8 0 244821 244424 0
Q9 0 0 0 30058496
Q10 0 0 0 0
Q11 0 0 0 0
Q12 0 0 0 0
Q13 0 0 0 0
Q14 0 1245395 1236616 0
Q15 0 0 0 0
Q16 0 0 0 0
Q17 0 0 0 0
Q18 0 0 0 0
Q19 0 0 0 0
Q20 0 0 0 0
Q21 0 0 0 0
Q22 0 0 0 0
Total 0 1490216 1481040 30058496

The new native addition path is unused by this run. Native subtraction appears only in Q8 and Q14, processing 1,481,040 values with SIMD out of 1,490,216 native values (~99.38%). Its eligible work is already almost fully vectorized; the amount of work reaching it is small. Q9 processes 30,058,496 values through the prepared SIMD subtraction path already present in earlier revisions of #32237, which this native extension does not accelerate further. This prepared SIMD implementation is part of the PR, not main; its input counter includes scalar tails. Q1/Q5 do not call the new native D128 add/sub paths. These counters measure the reach of the latest native add/sub extension, not the reach of every multiplication/cast/fused kernel in the full PR.

The earlier matched SF10 profiles independently show the larger costs: Q5 hash lookup ~25% flat CPU, Q9 hash lookup ~24% cumulative plus projection/copying, Q14 ordered filtering ~16% and decompression ~10%. Those percentages belong to the earlier matched profiling sources, not this counter-only run. They explain why a fast arithmetic primitive cannot translate directly into a comparable whole-query gain.

For Q5, the earlier shape probe observed 7,329 non-NULL calls covering 72,985 coefficients; every call had fewer than 32 values (about 10 per call), below the fused SIMD threshold. Its fused decimal executor was only about 0.2% of sampled CPU. This is a concrete dispatch limitation, but its measured CPU share is too small to promise a large Q5 gain merely by lowering a threshold.

The latest timed SF100 comparison remains incomplete (two of three pairs), and has not established a suite gain. Further improvement should follow measured path coverage rather than add more native decimal kernels blindly. Q5 small-batch work and join/filter/materialization changes remain separate follow-ups.

The 8,192-row native component wins (-26.45% add, -13.62% subtract) apply to those arithmetic loops; they are not predicted TPC-H percentages. The native extension’s TPC-H reach was overestimated.

Compressed counters are separate files: all22 activation counts, source/overlay metadata. The temporary diagnostic service is stopped and its disposable database clone removed.

@aunjgr

aunjgr commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Completed current-head SF100 disk-backed screen

Compared clean main dfc3ab0e382d7c21ca66aa1a03744b0c48c9d7ac against #32237 b7650291b13994563c0e9b4f9fd6ecf457ac86b4. The previously completed four arms are retained; only the missing final pair was run. Both source and executable pins were checked before each arm.

These are valid measurements, but this SF100 screen establishes no end-to-end speedup. Paired Total wall change is +2.17% (95% CI -14.36% to +21.88%). No query or Total has a confirmed slowdown under the registered tests; none of the predeclared Q5/Q9/Q14 targets has a confirmed wall gain here. The wide intervals are inconclusive, not proof of equivalence. Overall acceptance remains pending the current-head SF10 results and target instruction evidence.

All 32 local CPUs; 48 GiB application budget/no swap; 16 GiB CN shared cache; 32 GiB aggregation/join thresholds. Three alternating independent pairs, each excluding one full cold Q1-Q22 suite before one scored warm full suite. No spilling, swap, OOM, or memory-limit events in accepted runs; compiler and outside-CPU guards remained active. This is disk-backed, not all-memory. Benchmark/load scripts execute and drain SQL without row/schema/result verification.

Query Main wall s Candidate wall s Wall change (95% CI) Main CPU s Candidate CPU s
Q1 5.67132 5.61001 -2.40% [-21.70%, +21.67%] 104.48471 99.44075
Q2 0.43374 0.45340 +0.97% [-15.65%, +20.86%] 6.12264 5.84065
Q3 3.24636 3.16256 +1.69% [-13.39%, +19.40%] 48.39080 47.57497
Q4 2.44806 2.47910 +1.88% [-6.42%, +10.92%] 36.33364 36.56568
Q5 2.79294 2.73995 -0.79% [-11.63%, +11.38%] 45.49521 45.38587
Q6 1.76835 1.80566 +3.78% [-13.46%, +24.44%] 20.69682 20.09070
Q7 3.53993 3.45333 +3.93% [-16.85%, +29.90%] 46.36763 45.93084
Q8 2.96215 2.82297 +1.72% [-13.35%, +19.42%] 43.34197 43.28521
Q9 7.45263 7.46845 +0.56% [-8.12%, +10.04%] 147.87589 147.15097
Q10 4.70669 4.76879 +2.97% [-11.36%, +19.62%] 81.42748 80.86790
Q11 0.57044 0.58802 +9.92% [-13.84%, +40.24%] 6.72083 7.00819
Q12 3.93848 4.19376 +4.85% [-10.12%, +22.32%] 51.18178 51.20961
Q13 2.58665 2.60159 -2.68% [-12.13%, +7.79%] 70.67722 70.94923
Q14 2.44962 2.98531 +10.80% [-15.75%, +45.71%] 25.17224 25.45365
Q15 5.48415 5.20834 -5.20% [-50.34%, +80.99%] 46.92963 46.34628
Q16 0.80796 0.77995 +2.25% [-13.38%, +20.70%] 13.59123 12.26093
Q17 3.08550 3.91766 +9.74% [-36.20%, +88.75%] 35.76140 35.05258
Q18 5.79463 5.75779 +4.69% [-6.95%, +17.80%] 96.69178 96.08072
Q19 4.77331 4.95694 +3.14% [-6.14%, +13.34%] 72.35327 72.37056
Q20 4.18937 4.28699 +9.30% [-7.78%, +29.55%] 53.09216 52.76183
Q21 8.04501 8.01006 +2.35% [-6.66%, +12.22%] 124.17911 123.51964
Q22 0.49054 0.50361 -1.46% [-20.15%, +21.62%] 12.02501 11.74973
Total 77.23785 78.55423 +2.17% [-14.36%, +21.88%] 1188.91244 1176.89649

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

Displayed rows are medians across process blocks; Total sums those per-query medians. The change/interval column instead uses paired log ratios, so it is not necessarily the ratio of the two displayed medians.

Pair Main Total wall s Candidate Total wall s Main CPU s Candidate CPU s
1 71.49858 78.08008 1159.31610 1163.72568
2 81.68430 77.44382 1180.24421 1173.71801
3 83.07938 85.57405 1404.74279 1400.62833

The third pair used more CPU in both arms; it is retained rather than discarded. Per-arm scored physical reads were about 170-188 GiB, consistent with a substantial disk-backed workload. Thus this result cannot isolate decimal arithmetic latency from filesystem and scheduling variation.

Separate compressed evidence

All five files contain timings, resource counters, statistics and source/compiler metadata; no executable, database, or sampled stack memory.

Remaining delivery work

SF10 loading has completed from retained local inputs in 109.00 seconds including setup/statistics/checkpoint/shutdown. The timing preflight then detected new Cargo/Rust jobs and deferred SF10 before any scored run; the loaded image is retained and those unrelated jobs are untouched. The expression source is unchanged. Newest MO main has advanced with Top-K and service changes; this table qualifies only the explicitly pinned current PR/main pair, not a future merged head. CI#473 remains unmerged. The unrelated RC-transfer failure is tracked in #32321; the queue handoff counterexample is reported on #25590. This PR remains draft; no failed or missing acceptance criterion is waived.

@aunjgr

aunjgr commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Completed current-head SF10 RAM/disk comparison

Compared clean main dfc3ab0e382d7c21ca66aa1a03744b0c48c9d7ac with current #32237 b7650291b13994563c0e9b4f9fd6ecf457ac86b4, independently of other draft PRs. All 12 arms completed: three alternating process pairs per placement, each excluding a full cold Q1-Q22 suite before five scored warm suites. All 32 local CPUs, 48 GiB application/no swap, 16 GiB CN shared cache and 32 GiB aggregation/join thresholds. Accepted runs observed no spill, swap, OOM or compiler interference; the outside-CPU guard passed. Scripts execute/drain without table/schema/row/result verification.

The registered wall-gain criterion remains unmet. Neither placement establishes a Q5/Q9/Q14 target wall gain. Neither Total nor any query has a confirmed slowdown under the approved tests. RAM Q19 is +6.60% in the raw comparison (95% CI +1.43% to +12.03%), retained below, but is not confirmed after the registered Holm correction. This is not proof of equivalence; the signal remains visible for follow-up. Absence of a confirmed regression does not replace this expression PR's separate target-gain requirement.

This is consistent with the completed SF100 screen, which also established no target wall gain. Component improvements and lower CPU point estimates do not establish a whole-query latency win.

SF10 RAM-backed

Query Main wall s Candidate wall s Wall change (95% CI) Main CPU s Candidate CPU s
Q1 0.25998 0.23276 -10.83% [-13.83%, -7.72%] 7.24350 6.47100
Q2 0.02799 0.02943 +2.24% [-4.45%, +9.39%] 0.43255 0.43390
Q3 0.10522 0.10538 -1.42% [-9.70%, +7.61%] 2.47819 2.49670
Q4 0.07481 0.07329 -2.32% [-5.73%, +1.22%] 1.75193 1.72667
Q5 0.09381 0.09184 -4.00% [-10.22%, +2.65%] 1.86829 1.83614
Q6 0.04367 0.04394 +1.25% [-7.56%, +10.91%] 0.95984 0.96399
Q7 0.09254 0.09624 +1.58% [-4.42%, +7.95%] 2.14075 2.14966
Q8 0.24487 0.24331 -3.65% [-14.21%, +8.21%] 2.39679 2.36254
Q9 0.27611 0.27908 +1.03% [-1.92%, +4.06%] 5.78547 5.77916
Q10 0.21954 0.21818 +0.33% [-3.87%, +4.72%] 4.95287 4.95811
Q11 0.03437 0.03433 -4.91% [-27.97%, +25.53%] 0.54158 0.53770
Q12 0.11129 0.11168 +0.03% [-0.66%, +0.73%] 2.69234 2.67609
Q13 0.13228 0.13238 -0.02% [-3.44%, +3.52%] 3.70680 3.72508
Q14 0.08103 0.08426 +0.35% [-8.05%, +9.53%] 1.41940 1.57248
Q15 0.15970 0.16163 +1.24% [-1.16%, +3.70%] 2.27423 2.19914
Q16 0.12893 0.12574 -2.91% [-9.74%, +4.44%] 1.36604 1.32665
Q17 0.08183 0.08341 -0.86% [-8.16%, +7.03%] 1.96869 1.93711
Q18 0.33252 0.32937 -2.01% [-4.36%, +0.41%] 6.43141 6.36747
Q19 0.17075 0.18148 +6.60% [+1.43%, +12.03%] 4.01313 4.20324
Q20 0.17132 0.17034 -0.95% [-4.16%, +2.36%] 3.80334 3.77577
Q21 0.33659 0.33271 -0.15% [-6.70%, +6.85%] 8.66351 8.42692
Q22 0.04825 0.04866 +0.25% [-11.46%, +13.52%] 0.94594 0.95558
Total 3.22739 3.20942 -1.22% [-4.00%, +1.63%] 67.83658 66.88111

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

SF10 disk-backed

Query Main wall s Candidate wall s Wall change (95% CI) Main CPU s Candidate CPU s
Q1 0.31196 0.27705 -6.40% [-39.78%, +45.46%] 7.18767 6.63596
Q2 0.02986 0.02966 -1.23% [-5.93%, +3.71%] 0.39472 0.39358
Q3 0.11556 0.11762 +5.71% [-13.56%, +29.29%] 2.50935 2.46332
Q4 0.10545 0.10440 +1.62% [-8.76%, +13.18%] 1.72655 1.69534
Q5 0.11695 0.11542 +0.84% [-7.93%, +10.45%] 1.84392 1.81810
Q6 0.04619 0.05098 +15.13% [-31.35%, +93.09%] 0.91921 0.88330
Q7 0.11300 0.12443 +9.14% [-4.55%, +24.78%] 2.13905 2.12388
Q8 0.28027 0.27684 -1.66% [-3.16%, -0.14%] 2.39477 2.35360
Q9 0.32417 0.31858 -1.67% [-3.31%, -0.00%] 6.05859 5.89157
Q10 0.23859 0.22531 -2.71% [-9.14%, +4.17%] 4.92099 4.94172
Q11 0.03479 0.03649 +1.01% [-10.71%, +14.27%] 0.52090 0.53008
Q12 0.16759 0.17552 +4.60% [-11.39%, +23.48%] 2.59463 2.58304
Q13 0.13290 0.13349 +2.55% [-5.61%, +11.40%] 3.72981 3.74759
Q14 0.09291 0.09174 +4.85% [-23.04%, +42.84%] 1.40524 1.44635
Q15 0.18452 0.18839 +2.47% [-21.09%, +33.06%] 2.24945 2.21862
Q16 0.12727 0.12748 +0.49% [-0.23%, +1.20%] 1.32780 1.32144
Q17 0.11763 0.11052 +0.93% [-16.49%, +22.00%] 1.84903 1.87226
Q18 0.33431 0.33058 -0.70% [-7.81%, +6.96%] 6.15759 6.00258
Q19 0.23022 0.23478 +4.17% [-4.14%, +13.21%] 4.22644 4.12540
Q20 0.20030 0.19723 +1.61% [-7.88%, +12.07%] 3.67191 3.50830
Q21 0.46063 0.45053 -1.60% [-11.14%, +8.96%] 8.14726 8.16037
Q22 0.05012 0.05005 -1.61% [-7.48%, +4.64%] 0.92739 0.94117
Total 3.81519 3.76708 +0.40% [-6.80%, +8.16%] 66.90227 65.65757

Total sums per-query medians. Paired changes use independent process blocks. Negative means faster. Cold suites excluded.

The wall-change column uses matched process-block log ratios; displayed rows are medians across blocks and Total sums per-query medians, so changes need not equal the ratio of displayed columns. Total uses its unadjusted 95% primary interval. Query-regression confirmation uses Holm across all 22 at one-sided alpha 0.025; target-wall confirmation uses the predeclared Q5/Q9/Q14 family. No test rule was changed after viewing these results.

The original completion record inherited an incorrect SF100 label from its copied harness. Source audit confirms the executed query manifest/config were SF10 and five warm suites were scored. The original label is preserved locally; published metadata records the correction. No timing samples were edited or rerun for that label correction.

Separate compressed evidence

These files contain timing samples, CPU times, statistical decisions and public source/build identity. Internal paths, process identifiers and raw system snapshots are omitted. There is no executable, database or sampled stack memory.

The PR remains draft. matrixorigin/CI#473 is still unmerged, and the existing UT failures remain separate blockers. Further chain fusion belongs in a following design/PR as agreed; no production source was changed for this measurement.

@fengttt fengttt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move go up to 1.27 and implement both amd64 and arm64 SIMD

This branch had an error being deployed

1 failed deployment
ci — b7650291 Deployed Nov 6, 2026 by aunjgr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants