comphead commented on PR #12342:
URL: https://github.com/apache/arrow-rs/pull/12342#issuecomment-7023014834

   > the only thing I think we should double check is that this is backwards 
compatible
   
   @alamb it is, with the usual caveat for a new trait method:
   
   - `cargo semver-checks -p arrow-cast -p arrow-array --baseline-rev 
9f8745333` passes all 229 checks for both crates.
   - A downstream crate that implements `DecimalCast` for its own type, with 
only the six methods from before, compiles before and after this change, and so 
does generic code over `T: DecimalCast`.
   - A downstream crate with its own trait that also has a `mul_checked_opt` 
method on `i128`, used while `DecimalCast` is in scope, now fails with `E0034: 
multiple applicable items in scope`. That is the breakage the API evolution RFC 
accepts for a new defaulted trait item, and it needs that exact name.
   
   `DecimalCast::mul_checked_opt` is the only new public item. It is on the 
trait because the generic kernels and `rescale_decimal` only have `DecimalCast 
+ ArrowNativeTypeOp` to call through, and adding a bound to `rescale_decimal` 
would break its generic callers.
   
   > we should be using the benchmark bot to make final performance evaluations 
(arm64, x86-64, x86-64-v3, and aligned builds since sometimes alignment is the 
win)
   
   Thanks for running these, @Rich-T-kid. The six runs against 9f8745333, 
change of this PR (negative is faster):
   
   | Benchmark | arm64 | arm64 aligned | amd64 | amd64 aligned | x86-64-v3 | 
x86-64-v3 aligned |
   |---|---:|---:|---:|---:|---:|---:|
   | `cast decimal256 to decimal128 512` | -26% | -25% | -27% | -26% | -31% | 
-33% |
   | `cast decimal256 to decimal256 512` | -36% | -36% | -37% | -37% | -35% | 
-38% |
   | `cast int64 to decimal32(9, 0) 512` | -24% | -23% | -23% | -24% | -25% | 
-26% |
   | `cast int64 within 1e6 late overflow to decimal128(18, 2) 512` | -10% | 
-10% | -6% | -10% | -8% | -11% |
   | `cast int32 to decimal32(8, 0) 8192 precision overflow safe` | -31% | -32% 
| +2% | -2% | -2% | -4% |
   | `cast decimal128 to decimal128 512 lower precision` | -7% | -5% | -10% | 
0% | +1% | -1% |
   | `cast float32 to decimal32(7, 2) 8192 valid safe` | -2% | -1% | -17% | -5% 
| +7% | +6% |
   | `cast float32 to decimal32(7, 2) 8192 valid strict` | -1% | +10% | 0% | 
+18% | +3% | +2% |
   
   The other 18 cases are between -7% and +5%, except `cast decimal128 to 
decimal128 512 with same scale` at +6% on arm64, an 81 ns case that is 0% in 
the aligned arm64 run.
   
   The inputs that get slower are the two `float32` casts:
   
   - `valid safe` is 6% to 7% slower on x86-64-v3. There, the loop of this PR 
drops the indirect `callq *%r13` to `is_valid_decimal_precision` and the four 
`xmm` reloads after it, and inlines two table compares instead. I don't see a 
codegen cause and can't profile x86 locally.
   - `valid strict` is 10% and 18% slower only in the aligned arm64 and amd64 
runs. On arm64 the aligned build makes `main` faster (13.5 µs to 12.4 µs) while 
this PR stays at 13.4 µs to 13.6 µs, so this looks layout sensitive.
   
   The filter `^cast .*decimal` skipped the quoted names, such as `"cast 
float64 to decimal128(32, 3)"` and `"cast string to decimal128(38, 3)"`, so 
I'll include them in the new runs.
   


-- 
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