[perf stack4 3/4] decimal 合法标志直接通过,保留非法值异常路径 - #635
Merged
Merged
Conversation
This was referenced Sep 9, 2026
SunSi12138
changed the base branch from
perf/stack4-02-packet-clear-20260909
to
dev
September 9, 2026 13:30
SunSi12138
marked this pull request as ready for review
September 9, 2026 13:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
依赖 #634,第3/4层,不自动合并。
改动
用公共decimal.GetBits取得flags;保留位为0且scale≤28的值直接返回。非法值继续走原decimal构造函数并包装原DataLoss/ArgumentException,保留错误码和消息。不依赖生产native字段偏移,不重新规范化负零或scale。
历史默认JIT、v1.1.1主要对照
合法校验4.91→4.29ns;完整单值解码14.82→13.51ns(-8.86%);跨段29.55→27.93ns;8元素数组78.45→71.08ns;256元素数组1500.55→1334.07ns(-11.09%)。分配不变。关闭分层编译时曾有更大收益,未作为主结论。适用于decimal相关codec,不是普通int Add每次都会受益。
验证
新增全部scale/符号/负零/边界word保持位模式测试,以及通过测试内native布局探测构造的非法flags对照;生产代码不使用该布局探测。四层顶端使用相同仓库测试源码的定向TUnit宿主,正常和禁用intrinsics均15/15通过,Release0警告0错误、格式通过。全Unit编译曾触发工具时限,未宣称全仓测试通过。每层发布前完整tree与本地受测tree一致。没有新TCP成绩。
说明doc/performance-audit/stack4/03-decimal.md。