GH-40898: [C#] Do not import length-zero buffers from C Data Interface Arrays#41054
Merged
CurtHagenlocher merged 3 commits intoapache:mainfrom Apr 7, 2024
Merged
Conversation
|
|
CurtHagenlocher
approved these changes
Apr 7, 2024
Contributor
CurtHagenlocher
left a comment
There was a problem hiding this comment.
Thanks for doing this; I'm in the middle of a move and hadn't yet had a chance to look into this.
Member
Author
|
No problem! |
|
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 8fd3ce9. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 2 possible false positives for unstable benchmarks that are known to sometimes produce them. |
vibhatha
pushed a commit
to vibhatha/arrow
that referenced
this pull request
May 25, 2024
…terface Arrays (apache#41054) ### Rationale for this change When implementing integration tests for nanoarrow, it was observed that C# never released arrays where `array->buffers[i]` was `NULL` (including any buffers of any recursive child arrays). This is allowed ( https://arrow.apache.org/docs/format/CDataInterface.html#c.ArrowArray.buffers ); however, every other implementation appears to allocate even for length zero buffers (including nanoarrow after apache/arrow-nanoarrow#399 ). ### What changes are included in this PR? `AddMemory()` is replaced with `ArrowBuffer.Empty` if the length of the imported buffer would have been 0 bytes. For other buffers (or anywhere I saw dereferencing a buffer pointer), I added a `Debug.Assert` just to be sure. ### Are these changes tested? I'm not sure what the best way to test them is! They won't be tested in the nanoarrow integration tests since at the point that they run, nanoarrow will no longer export arrays that would trigger this. ### Are there any user-facing changes? No * GitHub Issue: apache#40898 Authored-by: Dewey Dunnington <dewey@fishandwhistle.net> Signed-off-by: Curt Hagenlocher <curt@hagenlocher.org>
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.
Rationale for this change
When implementing integration tests for nanoarrow, it was observed that C# never released arrays where
array->buffers[i]wasNULL(including any buffers of any recursive child arrays). This is allowed ( https://arrow.apache.org/docs/format/CDataInterface.html#c.ArrowArray.buffers ); however, every other implementation appears to allocate even for length zero buffers (including nanoarrow after apache/arrow-nanoarrow#399 ).What changes are included in this PR?
AddMemory()is replaced withArrowBuffer.Emptyif the length of the imported buffer would have been 0 bytes. For other buffers (or anywhere I saw dereferencing a buffer pointer), I added aDebug.Assertjust to be sure.Are these changes tested?
I'm not sure what the best way to test them is! They won't be tested in the nanoarrow integration tests since at the point that they run, nanoarrow will no longer export arrays that would trigger this.
Are there any user-facing changes?
No
ArrowArrayimports where a non-validity buffer is NULL #40898