feat: Enable native c2r by default, add debug asserts#3649
feat: Enable native c2r by default, add debug asserts#3649andygrove merged 7 commits intoapache:mainfrom
Conversation
| ) -> jni::sys::jobject { | ||
| try_unwrap_or_throw(&e, |mut env| { | ||
| // Get the context | ||
| debug_assert!(c2r_handle != 0, "columnarToRowConvert: c2r_handle is null"); |
There was a problem hiding this comment.
can c2r_handle be negative?
There was a problem hiding this comment.
jlong is a signed 64-bit integer, so yes, c2r_handle can technically be negative since memory addresses above 2^63 appear as negative values when stored in a signed long. However, the only invalid value we need to check for is 0 (null pointer). Negative values are valid memory addresses on 64-bit systems.
There was a problem hiding this comment.
Sorry for the AI response. Claude didn't ask me first 😞
| c2r_handle: jlong, | ||
| ) { | ||
| try_unwrap_or_throw(&e, |_env| { | ||
| debug_assert!(c2r_handle != 0, "columnarToRowClose: c2r_handle is null"); |
| let src_start = start_idx * $elem_size; | ||
| debug_assert!( | ||
| src_start + byte_len <= values_slice.len() * $elem_size, | ||
| "bulk_copy_range: source slice out of bounds: src_start={}, byte_len={}, values_len={}", |
There was a problem hiding this comment.
should we output elem.size as well?
| inherits = "release" | ||
| lto = false # Skip LTO for faster linking | ||
| codegen-units = 16 # Parallel codegen (faster compile, slightly larger binary) | ||
| debug-assertions = true |
There was a problem hiding this comment.
should it be always true, even for releases?
There was a problem hiding this comment.
we wouldn't want to enable the assertions for releases because it would defeat the point of having the unsafe code that skips bounds checks
There was a problem hiding this comment.
Oh I see, I thought it is enabled for release and it was my concern, for ci it is fine.
|
moving to draft while I run new benchmarks to confirm the benefit |
|
It looks like a debug assertion did fail, but no detailed were logged. I am enabling RUST_BACKTRACE next. |
Enable RUST_BACKTRACE=1 in all CI workflows to get full stack traces when debug assertions or other panics occur. Also add elem_size to the bulk_copy_range debug assert message for better diagnostics.
|
I am still not seeing a stack trace or reason for the failure. |
|
Added |
|
test failure is an existing issue in main branch and is fixed in #3652. I will rebase this PR once that is merged |
comphead
left a comment
There was a problem hiding this comment.
Thanks @andygrove the CI fails presumably because of OOM issues
The tests passed on CI, it says |
A debug assert is triggered because of unaligned memory access. |
Actually, I am a bit confused now. The error is: I confirmed that the changes in #3652. do fix this, but not sure why this only shows up when enabling debug assertions 😕 |
I suppose the debug assertion must be in Rust |
|
The expression causing panic may be in the debug_assert. It would then show up only in debug. The issue would be missed silently! |
Which issue does this PR close?
Closes #.
Rationale for this change
~I see a
10% speedup in TPC-H @ 1TB with this feature enabled.edit: this was actually due to usingnative_datafusionscan. However, I see no perf regression from this PR, and it reduces GC pressure by avoiding many java allocations.What changes are included in this PR?
How are these changes tested?