mbutrovich opened a new pull request, #11896: URL: https://github.com/apache/arrow-rs/pull/11896
# Which issue does this PR close? - Closes #11895. # Rationale for this change The issue describes the problem. # What changes are included in this PR? `as_datetime`, `as_datetime_with_timezone`, `as_time` and `as_duration` wrap the `T::DATA_TYPE` temporary in `ManuallyDrop`. `as_duration` wasn't in the issue, but it has the same per-value drop. `as_date` calls `as_datetime`, so it benefits too. # Are these changes tested? The existing tests cover the converters through `PrimitiveArray::value_as_datetime`, `value_as_time` and the `arrow-cast` timestamp casts. Behavior is unchanged. The `timezone_control` cases of `arrow-cast`'s `cast_timestamp` bench call `as_datetime_with_timezone::<T>` once per value. On Apple M5 Max with `CARGO_PROFILE_BENCH_LTO=thin`, 8192 values, they ran 0.74x to 0.90x of `main`. With `-C llvm-args=-align-all-functions=7 -C llvm-args=-align-all-nofallthru-blocks=7` on both sides, they ran 0.80x to 0.92x. The casts without a time zone don't call the converters, and they ran 0.90x to 1.04x across both runs. | Case | `main` | This PR | | |---|---|---|---| | `timestamp_ns/date32_timezone_control` | 113.26 us | 84.00 us | 0.74x | | `timestamp_ns/time64_ns_timezone_control` | 66.47 us | 56.95 us | 0.86x | | `timestamp_s/date32_timezone_control` | 100.53 us | 77.58 us | 0.77x | | `timestamp_s/time32_s_timezone_control` | 55.68 us | 48.60 us | 0.87x | `format_temporal` didn't change (1.00x to 1.03x), because formatting costs far more per value than the call this removes. In the thin-LTO `cast_timestamp` binary on aarch64, `drop_glue::<DataType>` is no longer called from any `timestamp_to_time` or `adjust_timestamp_to_timezone` monomorphization. On x86_64, I checked a `unary_opt` kernel over `as_datetime::<TimestampNanosecondType>` before linking. It now compiles to the same 1166 instructions as the same kernel over `timestamp_ns_to_datetime`. # Are there any significant user-facing changes? No. ## AI Disclosure I wrote this PR with help from Claude but understand and support the core approach, implementation, and test coverage. -- 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]
