Skip to content

fix(function): avoid decimal cast setup and widening overhead - #30981

Merged
mergify[bot] merged 14 commits into
matrixorigin:mainfrom
aunjgr:fix/decimal-cast-null-setup
Oct 23, 2026
Merged

mergify[bot] merged 14 commits into
matrixorigin:mainfrom
aunjgr:fix/decimal-cast-null-setup

Conversation

@aunjgr

@aunjgr aunjgr commented Oct 23, 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 #30839 and #30838. This focused correction does not complete the broader optimization issue.

What this PR does / why we need it:

Skip decimal cast setup for empty and entirely NULL batches, use resolved values and NULL bitmaps, and reuse the result-owned parameter frame. Write same-scale non-NULL Decimal64/128 widening batches directly into the Decimal256 result. Use bounded integer rescaling for Decimal128-to-64 values that fit the declared precision; retain the existing rounding method and error conversion for rejected values. Convert constant inputs once and broadcast the result. Preserve checked scaling, rounding, precision, NULL and error behavior; cover signed widening, bounded NULL domains, rebinding and overflow recovery.

Validation: owning-package tests, full pre-push static checks, isolated local TPC-H SF10 Q1–Q22 and separate CPU profiles pass. The baseline is a real clean-main checkout; the candidate contains only this fix, with no source overlays. Six balanced process pairs use three scored calls per query after excluded cold warmups. The local performance gate passed; the detailed measurements below identify any independent confirmation used for initial slower-query signals. Detailed measurements are recorded in the PR comment.

@aunjgr aunjgr added the severity/s0 Active / top priority for current sprint. Owner has committed to working on it now. label Oct 23, 2026
@aunjgr aunjgr self-assigned this Oct 23, 2026
@aunjgr

aunjgr commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Local verification uses only clean main and this candidate, built normally in separate checkouts. No combined candidate or source overlays.

Comparison base: 5fb586e1429386260b900171f65ffa844f49c981. Tested candidate: bdf5d1a8caf479fccfe6433a8f234ada6165a8d5. PR head after the required main merge: 898da0695cc2cce85c0933e9c3d15296c99baef6. GOAMD64=v3, GOEXPERIMENT=simd; matching stamped native generation.

SF10: eight physical CPUs, 16 GiB CN SHARED cache, 32 GiB whole application including the private RAM image, no swap. Existing loaded image reused. Cold selected-query warmups excluded; profiles collected separately. No input/table/schema/row-count/reference/result verification.

Query Baseline median (s) Candidate median (s) Paired change 95% time-ratio interval
Q1 1.6462 1.4675 -9.86% 0.8908–0.9084
Q2 0.0502 0.0519 +3.64% 0.9445–1.1107
Q3 0.4180 0.4128 -1.00% 0.9741–1.0116
Q4 0.3249 0.3198 -2.04% 0.9655–1.0016
Q5 0.3895 0.3861 +0.07% 0.9578–1.0136
Q6 0.2528 0.2439 -2.73% 0.9229–1.0079
Q7 0.3775 0.3652 -2.66% 0.9425–0.9931
Q8 0.3617 0.3629 -0.73% 0.9745–1.0222
Q9 0.7386 0.7317 -1.05% 0.9645–1.0090
Q10 0.6109 0.6037 -0.24% 0.9443–1.0374
Q11 0.0944 0.0939 -2.77% 0.9115–1.0469
Q12 0.4783 0.4582 -2.66% 0.9327–1.0040
Q13 0.3591 0.3538 -1.89% 0.9669–1.0173
Q14 0.2704 0.2584 -4.16% 0.9435–0.9670
Q15 0.4710 0.4652 -1.31% 0.9819–1.0051
Q16 0.1378 0.1378 -0.14% 0.9792–1.0099
Q17 0.3149 0.3159 +0.85% 0.9734–1.0234
Q18 1.2396 1.1520 -5.88% 0.9063–0.9930
Q19 0.6269 0.6222 -0.83% 0.9768–1.0358
Q20 0.3877 0.3811 -2.21% 0.9665–0.9860
Q21 1.4449 1.4085 -2.80% 0.9622–1.0062
Q22 0.1148 0.1126 -1.66% 0.9608–1.0013

Changes use the median of paired process ratios; columns show medians over six process generations. No aggregate gain overrides an individual regression.

Main advanced after timing collection. The intervening commits change Python SDK/tests, CSV test fixtures, UNIX_TIMESTAMP(DATETIME) selection and persisted DDL validation, detached background table-statistics stock, cancelled keepalive handling and GC Bloom sizing. Decimal casts/arithmetic, vector/null/bitmap/type/memory-pool primitives and native build inputs are unchanged. TPC-H does not invoke UNIX_TIMESTAMP or persisted-expression DUMP/LOAD; its arithmetic argument types and query expressions are unchanged. Statistics/GC changes may affect background activity, so the published performance numbers remain explicitly attributed to the tested snapshot pair, not presented as a fresh measurement of the merged head. Reuse the unchanged decimal functional and performance evidence; rerun owning-package and full static validation on the merged head.

Environmental exclusions were preserved and whole matched pairs repeated. No performance sample was discarded for being slower.

Package/static checks and separate profile/resource gates passed. Software/source identities, raw timing records and profiles are retained locally; broader optimization issues stay open.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH 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.

Reviewed the current head 898da0695cc2cce85c0933e9c3d15296c99baef6 and the changed cast/test files. I found no actionable correctness regression in the added empty/all-NULL guards, bounded Decimal128→Decimal64 conversion, or same-scale Decimal64/128→Decimal256 widening. The SF10 results in the PR discussion are author-reported for candidate bdf5d1a8caf479fccfe6433a8f234ada6165a8d5, not measurements I ran; the owning-package tests and local harness were not executable in this workspace. Related performance issue #30839 remains open, so this approval does not mark its broader performance acceptance complete.

@mergify

mergify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-23 16:14 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-10-23 17:10 UTC · at 7f586371fceffa96c9146cc57614738e80b0c95e · squash

This pull request spent 56 minutes 13 seconds in the queue, including 53 minutes 56 seconds running CI.

Required conditions to merge

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working severity/s0 Active / top priority for current sprint. Owner has committed to working on it now. size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants