hcrosse opened a new pull request, #1646:
URL: https://github.com/apache/arrow-go/pull/1646

   ### Rationale for this change
   
   Part of #1516. Moving `Decimal256` into `arrow/decimal` is the first step 
toward making `arrow/decimal` the primary decimal package while keeping 
`arrow/decimal256` compatible.
   
   ### What changes are included in this PR?
   
   I moved `Decimal256` into `arrow/decimal` and turned `arrow/decimal256` into 
type aliases and thin wrappers, keeping a dummy call so Go still inlines the 
method set (`golang/go#82474`). Internal callers in `arrow/` and `parquet/` now 
use `arrow/decimal`, which also adds `MaxScale`.
   
   To avoid extra struct copies through `arrow/decimal256` wrappers on Go 1.26 
and 1.27, I rewrote `Decimal256FromI64` and `Decimal256FromDecimal128` as 
single composite literals and rewrote `Decimal256FromBigInt` to unpack limbs 
and negate in registers. Over 10 interleaved `benchstat` rounds on Go 1.26.10 
(Linux amd64, allocations unchanged):
   
   | Benchmark (PR call) | `main` | PR | Change |
   | --- | ---: | ---: | ---: |
   | `decimal256.FromI64` | 6.55 ns/elem | 0.76 ns/elem | -88.4% |
   | `decimal256.FromDecimal128` | 1.78 ns/elem | 1.06 ns/elem | -40.5% |
   | `decimal256.FromBigInt` (1 / multi word) | 17.67 / 17.70 ns/elem | 12.84 / 
12.94 ns/elem | -27.3% / -26.9% |
   | `decimal.Decimal256FromBigInt` (1 / multi word) | 17.62 / 17.73 ns/elem | 
10.05 / 10.26 ns/elem | -43.0% / -42.1% |
   | `Decimal256Builder` append and array construction (`decimal256.FromI64`) | 
16.20 ns/elem | 12.62 ns/elem | -22.1% |
   
   `main` uses `decimal256.FromBigInt` for the direct call row. Unchanged 
composite literals `decimal256.FromU64` (0.62 to 0.64 ns/elem, +3.4%) and 
`decimal256.New` (0.62 to 0.65 ns/elem, +5.6%) are sensitive to loop alignment.
   
   ### Are these changes tested?
   
   Yes. I added layout compatibility checks for `arrow/decimal256` plus unit 
tests for `MaxScale`, `Decimal256FromI64`, `Decimal256FromDecimal128` and 
`Decimal256FromBigInt` covering boundary and overflow cases.
   
   ### Are there any user-facing changes?
   
   Yes. `arrow/decimal` now exports `Decimal256` constructors and `MaxScale`, 
while `arrow/decimal256` remains source compatible through aliases and wrappers.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to