Repository navigation
perf(types): accelerate short Decimal128 coefficient construction - #31032
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? |
LeftHandCold
left a comment
There was a problem hiding this comment.
代码审查结论:建议通过,未发现需要 Request Changes 的确定性问题。审查 HEAD:484a15e6223451ea4054a0772a42b517f7cb10e2;merge-base:d93d5d66c83d2927c233de17f21fe7f513bc7d32。
设计与范围:在现有 Decimal128FromCoefficient 中增加有证明的窄范围算术快路径,属于局部性能修复。没有另建数字解析器,也没有迁移符号/scale/舍入/诊断职责,不需要架构级重设计。
核对内容:
- 最多 18 个 ASCII 数字的值不超过 10^18-1,每个中间前缀也不超过这个上界;uint64 乘十加 digit 不会溢出,Decimal128 高 64 位保持 0。不是通过有损转换或忽略可能发生的算术错误换性能。
- nil/空输入仍为零;每个字节仍验证 '0'..'9',拒绝正负号、小数点、指数、空格、NUL 和非 ASCII 数字,非法输入返回零值及原 error code/text,不返回部分系数。
- 19–38 位继续走旧的完整 Decimal128 运算;>38 位在快路径之前拒绝。输入不被改写、不被保留。
- 跟踪了 strict CAST 和 MySQL numeric-prefix 两个实际调用方:舍入/精度上限先处理,符号后处理。18→19 位舍入进位会自然落回旧路径,精度 18 的 clamp 和逐行 warning 不因本优化被省略。
- 新测试用 math/big 独立验证两个 word,包含 18/19/38/39 位、低位进位、非法字节和输入不变性;消费层直接检查正负舍入及两条精确 1264 warning。没有新增全局生产状态、分配、锁或清理路径。
Q1–Q3:只有局部标量,不持有输入;无新增等待;新循环最多 18 次,长系数维持原来的 38 位上限。
性能结论限定:短系数构造的降本成立;完整查询收益仍是作者特定数据/布局的 ABBA 证据,本次没有重新压测。19/38 位控制保持原算法;该 PR 的代码本身不依赖 #31022,只是作者性能实验基线包含了它。
验证:本次完成全部 diff、实际调用方、边界及 diff --check;没有在本机重复执行重型 function UT/JSONBench。当前 HEAD 的 UT 与 SCA 均在 checkout 时因 gnutls_handshake 失败,不能据此判断 decimal 测试失败,也不能当作测试通过。合并前仍需正常完成所需 CI。
当前认证账号也是作者,GitHub 不允许自审 Approve;以 COMMENT 记录“代码层面建议通过”,不替代 CI 门禁,也未执行合并。
|
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-local · review
Commit: 484a15e6223451ea4054a0772a42b517f7cb10e2
Assessment: approve
Reviewed the complete four-file delta and both production callers. The optimization belongs in the existing coefficient constructor: at most 18 decimal digits safely fit in uint64, while longer inputs retain the established implementation. Validation, error behavior, rounding, signs and warnings remain consistent. The measured short-input benefit justifies the small fallback cost. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Reviewed arithmetic boundaries, malformed inputs, input immutability, strict and MySQL-prefix conversion paths, rounding carry, overflow clamping, warning behavior, fixture cleanup and benchmark correctness.
-
Isolation preflight passed. Verified 192 native build inputs against the current revision and checked native provenance before testing. Source remained unchanged.
-
113 focused Decimal and MySQLDecimalPrefix tests passed through the supplied test executor, including the new boundary and consumer tests. Receipt: checks/1792841496541594881-5.json; log: decimal-tests.log.
-
A/B/B/A microbenchmarks compared the candidate with the exact base production file through a verified overlay. Median 16-digit time improved from 62.85 to 8.221 ns; 18-digit time improved from 70.53 to 9.351 ns. The 19/38-digit fallback medians increased approximately 2.6%/2.2%. All measured cases allocated zero bytes.
-
Formatting and diff checks passed. The frozen CI snapshot records later successful UT, static analysis, coverage and BVT runs, superseding earlier unsuccessful attempts.
-
Reconciled commands, source fingerprints, exit receipts, retained logs and benchmark inputs in /home/xupeng/.local/state/mo-bot/jobs/24072b6a022fc99af693174e/attempt-1/review-evidence-audit.json. Final audit receipt checks/1792841595115765577-4.json exited successfully.
Limitations:
-
Author JSONBench measurements lack retained raw receipts in the supplied evidence; no independent end-to-end SQL speedup is claimed.
-
The linked issue body was absent from the frozen evidence. Approval covers the PR's explicit coefficient-construction contract and complete code delta.
Merge Queue Status
This pull request spent 13 minutes 38 seconds in the queue, with no time running CI. ReasonPull request #31032 has been merged manually at 0abc1d3 HintYou were too fast! Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #31031
What this PR does / why we need it:
Short string-to-DECIMAL coefficients currently use full-width arithmetic for every digit. Accumulate coefficients of at most 18 ASCII digits in a uint64 instead: their maximum is below 10^18, so the high word is zero and no intermediate can overflow. Keep the existing 19–38-digit path, byte validation, empty input and exact error contract. Parsing, sign, scale, rounding, overflow and warnings remain with the existing callers. This adds 13 production lines and no allocations or shared state.
Validation on main
3878a13e: both baseline and candidate pass the same helper boundary tests and 13 neighboring/consumer tests, including rounding carry and precise clamp warnings. Both changed owning packages, gofmt, vet and configured incremental lint pass. Paired microbenchmarks reduce 16/18-digit construction from 105.15/117.00 ns to 10.715/11.820 ns; 19/38-digit controls remain comparable. All four allocate zero bytes.Actual JSONBench validation uses 9,999,997 complete documents, the same qualified clustered STORED table, four CPUs and a 12 GiB no-swap cap. A/B/B/A, four warmups plus five samples per query/block: all 180 complete outputs pass. The performance baseline includes the grouping optimization from #31022; the causal candidate adds only this coefficient change. The delivery diff is independently based on main.
Q3/Q4/Q5 latency decreases are 30.35%/7.74%/10.10%, with separated sample ranges. Q1/Q2 changes are not attributed to this patch. Candidate peaks are 3.13/3.00 GiB; every block has zero limit/OOM/swap events and stable schema/count/objects and executable/native identities. This is bounded validation, not a universal memory-safety or overall benchmark-completion claim; Q5 still trails the retained ClickHouse lane by about 12.85x.
Evidence fingerprints: unit/static
3885e170…; causal build7fc36daf…; full SQL ABBA1d13c630…. No query rewrite, table-layout change or benchmark harness is included in this PR.