Repository navigation
perf(function): hoist decimal cast invariants - #30880
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-xupeng · review
Commit: 09a552c50b3bfa84d7bab55fc0733268b260cd95
Assessment: approve
Reviewed the complete two-file delta, callers, conversion owners, and test coverage. The hoisting preserves rounding, overflow, NULL, and metadata behavior while improving throughput. No actionable findings.
Model: gpt-6-astra / xhigh
Session: 01a15209-2c6d-71e2-b8f3-aa17387fa283 · slot 2 · generation 0
Validation:
-
Isolation preflight passed. Verified 192 matching native inputs and repository-owned native provenance before testing.
-
All 61 precision cases and three related test functions passed on both the candidate and the merge-base implementation with identical current tests.
-
The complete function package passed: 2,203 top-level tests, with no failures or skips; function-package.log matches receipt 1792692100868710044-3.json.
-
Six alternating benchmark pairs across 11 cases showed 1.97–3.47× speedups in affected cases, unchanged allocations, and approximately 1% variation in unchanged controls.
-
Source cleanliness, command/source/exit receipts, logs, and artifact hashes reconciled in /home/xupeng/.local/state/mo-bot/jobs/3939e7f775253d9972b9d241/attempt-1/validation-report.json; benchmark details are in benchmark-summary.json.
Limitations:
-
Local validation used Linux/amd64, Go 1.27.1, and GOAMD64=v1. Kernel benchmarks do not independently establish the reported end-to-end TPC-H Q1 speedup.
-
Frozen evidence contained CI success statuses but no raw CI or author performance logs, and no linked-issue bodies. The issue contract was assessed from the supplied PR description.
Merge Queue Status
This pull request spent 1 hour 35 minutes 57 seconds in the queue, including 58 minutes 45 seconds running CI. Required conditions to merge
|
…ch (#30885) Use valid Decimal256 operand precision to skip redundant range scans in multiplication dispatch. Precision up to 9 proves an int32 coefficient; precision up to 18 proves int64. Compute proofs once per batch, preserve the int32-before-int64 tier order, and retain dynamic checks for unknown or invalid metadata. Existing multiply, scaling, rounding and result-precision enforcement remain responsible for results and errors. Metadata-free callers retain the original unknown-proof path. Validation: full function package tests including the newly merged decimal-cast changes, an independent math/big oracle across precision 9/10/18/19, signed values, constants, NULLs, selection and scale rounding, plus existing overflow/wide-path coverage. Public-dispatch 256-row microbenchmarks improve ~1.39x for proven int32 and ~1.20x for proven int64, with zero allocations; wide fallback is unchanged. Query timing is reported separately from kernel gains. Comparison protocol: optimized SIMD builds, eight physical CPUs, a private retained SF10 native image, 32 GiB application limit including the image, no swap, and a 16 GiB CN SHARED memory cache verified from running-process metrics. Query cold warmups are excluded; CPU profiling is separate from latency. All query evidence uses main with #30880 merged. No dataset or query-result verification runs in benchmark scripts. Paired SF10 replay on merged main (six balanced process generations, three scored calls per query per arm): | Query | Main median | Candidate median | Speedup | Paired 95% interval | |---|---:|---:|---:|---:| | Q1 | 1.596845 s | 1.601109 s | 0.9973x | 0.9728–1.0219x | | Q15 | 0.464836 s | 0.457631 s | 1.0157x | 1.0060–1.0249x | Q1 shows no demonstrated whole-query gain; Q15 shows a modest ~1.6% gain in this replay. All measured windows pass the zero physical I/O, spill, swap, OOM and sustained-memory-pressure gates. These are selected-query results, not a whole-suite or SF100 speedup claim. Separate CPU/PMU diagnostic (one process generation per variant, two warm query calls, excluded from the latency comparison): user instructions per call 211.846G → 215.195G, user cycles 48.694G → 49.829G. The recordings have no lost samples. This single diagnostic pair is not a significance test or a query speedup claim. Isolated kernel microbenchmarks used the pre-#30880 main snapshot; that cast-only merge does not change the timed constructor, multiplication or SUM kernel closures. The retained-image query comparisons and profiles were rebuilt and rerun with #30880 included. Approved by: @XuPeng-SH
…30884) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #30849; umbrella #30838. [Approved versioned design](https://github.com/aunjgr/matrixone/blob/0f810e8452/docs/design/tpch-column-cache-attribution.md). ## What this PR does / why we need it: Attribute repeated decoded-column work to reader write bypasses, cache admission decisions and column construction. Add fixed per-codec calls, successful decoded bytes and errors, plus memory-cache update outcomes. Counters aggregate per block, IOVector or column construction and reset with the existing CounterSet. Cache policy, capacity, decoding and ownership remain unchanged. Make the existing HTML counter reporter load live atomic leaves without copying enclosing containers or reading atomic fields through reflect.IsZero. A concurrent writer/reporter regression test reproduced the old race; the complete perfcounter race suite passes with the fix. Validation: full perfcounter, fileservice, objectio and readutil package tests; focused cache/constructor race coverage; cold versus hit reconstruction, threshold boundary, policy bypass, every admission rejection stage, codec errors and counter reset tests. Constructor microbenchmarks show ~79 ns extra for an uncompressed 16 KiB column (~8.6%) and ~1.6% for LZ4, with unchanged allocations. This is an attribution step, not a cache-policy optimization. Comparison protocol: optimized SIMD builds, eight physical CPUs, a private retained SF10 native image, 32 GiB application limit including the image, no swap, and a 16 GiB CN SHARED memory cache verified from running-process metrics. Query cold warmups are excluded; CPU profiling is separate from latency. All query evidence uses main with #30880 merged. No dataset or query-result verification runs in benchmark scripts. With the effective 16 GiB cache, three warm Q6 calls reconstruct 4.03 GiB in 75,516 LZ4 constructions; memory-cache reads/hits are 87,900/12,384, reader-policy bypasses and FileService policy skips are both 18,879, and no decoded-entry admission attempts or pressure skips occur in the measured window. Cache use is only ~260 MiB. Q10 similarly shows 21,279 reader-policy bypasses, 7.21 GiB reconstructed and ~859 MiB cache use. These counters distinguish policy bypass from insufficient cache capacity; changing that policy is follow-up work. Separate CPU/PMU diagnostic (one process generation per variant, two warm query calls, excluded from the latency comparison): user instructions per call 18.188G → 18.309G, user cycles 6.476G → 6.406G. The recordings have no lost samples. This single diagnostic pair is not a significance test or a query speedup claim. Isolated kernel microbenchmarks used the pre-#30880 main snapshot; that cast-only merge does not change the timed constructor, multiplication or SUM kernel closures. The retained-image query comparisons and profiles were rebuilt and rerun with #30880 included. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Closes #30839
Related to #30838
What this PR does / why we need it:
Implicit decimal casts recomputed the same type/scale proof for every non-NULL row. Wide casts also repeatedly selected the physical width used for scaling. These batch-invariant decisions were a measured Q1 CPU hotspot.
Compute the widening proof, scale delta, width selection and fallback predicates once per batch in the five affected cast kernels. Keep the existing value-dependent scaling, precision checks, rounding, NULL handling, append errors and SQL result metadata. Leave the Decimal64-to-128 array helper unchanged because it already hoists its proof.
Extend the existing precision tests with empty/all-NULL batches, repeated constant values, and scaling boundaries across Decimal64/128/256. Extend the existing microbenchmark with wide and same-scale cases and the existing fast-path control.
Validation:
1daa5e459band candidate5c9b6e0d8d. Subsequent main merges preserve all five changed decimal kernels; post-merge function tests and the complete static gate are refreshed.make static-checkpasses in the default CI analysis profile. Functional/performance binaries use optimized GOAMD64=v3 / GOEXPERIMENT=simd.The end-to-end measurement covers Q1; it does not claim a full TPC-H suite speedup.