Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-185: Make padding and alignment for all buffers be 64 bytes #74

Closed
wants to merge 7 commits into from

Conversation

emkornfield
Copy link
Contributor

  • some small cleanup/removal of unnecessary code. I think there is likely a good opportunity to factor this code better generally, but this seems to work for now.

constexpr int64_t multiple_bitmask = round_to - 1;
int64_t remainder = num & multiple_bitmask;
int rounded = num;
if (remainder) { rounded += 64 - remainder; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use round_to here. I'm also pretty sure there is something clever we could do to avoid the condition here, but at the moment I'm blanking on it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this do it?

(num + multiple_bitmask) & ~multiple_bitmask

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that looks right to me. although the performance gains are probably moot given the other condition for overflow.

@emkornfield
Copy link
Contributor Author

hmm, tests passed locally, will need to take a closer look at what is going on.

virtual ~Buffer();

// An offset into data that is owned by another buffer, but we want to be
// able to retain a valid pointer to it even after other shared_ptr's to the
// parent buffer have been destroyed
// TODO(emkornfield) how will this play with 64 byte alignment/padding?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inevitably alignment and padding isn't always going to be a guarantee on in-memory data (of course when data is moved for IPC purposes, that will need to be guaranteed). I suppose then that buffers will need to be able to communicate their alignment/padding for algorithm selection (i.e. can we use the spiffy AVX512 function or not?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to see how use-cases play out. It seems given the current spec, most slicing operations in the general case will need memory allocation anyways. We could likely guarantee alignment/padding by providing a utility method that either allocates slices if it can keep the contract otherwise allocates new underlying data. For now I will put a warning here.

@emkornfield
Copy link
Contributor Author

still need to address other comments, but pushed a commit that should allow C++ tests to pass, I still need to check if python tests are still failing.

@emkornfield emkornfield changed the title ARROW-185: Make padding and alignment for all buffers be 64 bytes [WIP] ARROW-185: Make padding and alignment for all buffers be 64 bytes May 13, 2016
@emkornfield emkornfield changed the title [WIP] ARROW-185: Make padding and alignment for all buffers be 64 bytes ARROW-185: Make padding and alignment for all buffers be 64 bytes May 17, 2016
@emkornfield
Copy link
Contributor Author

should be ready for review. Not done here is verification of alignment on RPC I will open up a jira to address this, if that is ok.

//
// This method makes no assertions about alignment or padding of the buffer but
// in general we expected buffers to be aligned and padded to 64 bytes. In the future
// we might add utility methods to help determine if a buffer satisfies this contract.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably what we can do is add a method to produce a buffer that is guaranteed to be aligned and padded (allocating as necessary). For example: if there is incoming data from another library to libarrow that is not aligned or padded, some algorithms may work without alignment or padding, while others (e.g. requiring SIMD) would require the buffer to be "fixed". This could get pretty hairy, though...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking about the case where an Arrow array is constructed from memory allocated elsewhere with zero copy

@wesm
Copy link
Member

wesm commented May 17, 2016

LGTM. thank you for the thorough efforts on this. +1

@asfgit asfgit closed this in 9c59158 May 17, 2016
praveenbingo added a commit to praveenbingo/arrow that referenced this pull request Aug 30, 2018
…e#74)

* Temporarily matching what the dremio does for mod zero.
* Used the latest Arrow APIs for allocating buffers.
praveenbingo added a commit to praveenbingo/arrow that referenced this pull request Aug 30, 2018
…e#74)

* Temporarily matching what the dremio does for mod zero.
* Used the latest Arrow APIs for allocating buffers.
praveenbingo added a commit to praveenbingo/arrow that referenced this pull request Aug 30, 2018
…e#74)

* Temporarily matching what the dremio does for mod zero.
* Used the latest Arrow APIs for allocating buffers.
praveenbingo added a commit to praveenbingo/arrow that referenced this pull request Aug 30, 2018
…e#74)

* Temporarily matching what the dremio does for mod zero.
* Used the latest Arrow APIs for allocating buffers.
wesm added a commit to wesm/arrow that referenced this pull request Sep 2, 2018
I added an option to make SSE strictly opt-in for now. As a side effect of this, parquet-cpp now builds and the test suite passes out of the box on 32-bit ARMv7 (I tried it on my RaspberryPi Model B 2).

Author: Wes McKinney <wesm@apache.org>

Closes apache#74 from wesm/PARQUET-488 and squashes the following commits:

61225e9 [Wes McKinney] Use -march=native
3833efd [Wes McKinney] Remove stale cmake comment
70fcf65 [Wes McKinney] Add cmake PARQUET_USE_SSE option
775c72d [Wes McKinney] Fix compilation on arm7/raspberrypi
praveenbingo added a commit to praveenbingo/arrow that referenced this pull request Sep 4, 2018
…e#74)

* Temporarily matching what the dremio does for mod zero.
* Used the latest Arrow APIs for allocating buffers.
wesm added a commit to wesm/arrow that referenced this pull request Sep 4, 2018
I added an option to make SSE strictly opt-in for now. As a side effect of this, parquet-cpp now builds and the test suite passes out of the box on 32-bit ARMv7 (I tried it on my RaspberryPi Model B 2).

Author: Wes McKinney <wesm@apache.org>

Closes apache#74 from wesm/PARQUET-488 and squashes the following commits:

61225e9 [Wes McKinney] Use -march=native
3833efd [Wes McKinney] Remove stale cmake comment
70fcf65 [Wes McKinney] Add cmake PARQUET_USE_SSE option
775c72d [Wes McKinney] Fix compilation on arm7/raspberrypi

Change-Id: If8e4e7e1b7fc64df952cb8b82662bb017ca56f72
wesm added a commit to wesm/arrow that referenced this pull request Sep 6, 2018
I added an option to make SSE strictly opt-in for now. As a side effect of this, parquet-cpp now builds and the test suite passes out of the box on 32-bit ARMv7 (I tried it on my RaspberryPi Model B 2).

Author: Wes McKinney <wesm@apache.org>

Closes apache#74 from wesm/PARQUET-488 and squashes the following commits:

61225e9 [Wes McKinney] Use -march=native
3833efd [Wes McKinney] Remove stale cmake comment
70fcf65 [Wes McKinney] Add cmake PARQUET_USE_SSE option
775c72d [Wes McKinney] Fix compilation on arm7/raspberrypi

Change-Id: If8e4e7e1b7fc64df952cb8b82662bb017ca56f72
wesm added a commit to wesm/arrow that referenced this pull request Sep 7, 2018
I added an option to make SSE strictly opt-in for now. As a side effect of this, parquet-cpp now builds and the test suite passes out of the box on 32-bit ARMv7 (I tried it on my RaspberryPi Model B 2).

Author: Wes McKinney <wesm@apache.org>

Closes apache#74 from wesm/PARQUET-488 and squashes the following commits:

61225e9 [Wes McKinney] Use -march=native
3833efd [Wes McKinney] Remove stale cmake comment
70fcf65 [Wes McKinney] Add cmake PARQUET_USE_SSE option
775c72d [Wes McKinney] Fix compilation on arm7/raspberrypi

Change-Id: If8e4e7e1b7fc64df952cb8b82662bb017ca56f72
wesm added a commit to wesm/arrow that referenced this pull request Sep 8, 2018
I added an option to make SSE strictly opt-in for now. As a side effect of this, parquet-cpp now builds and the test suite passes out of the box on 32-bit ARMv7 (I tried it on my RaspberryPi Model B 2).

Author: Wes McKinney <wesm@apache.org>

Closes apache#74 from wesm/PARQUET-488 and squashes the following commits:

61225e9 [Wes McKinney] Use -march=native
3833efd [Wes McKinney] Remove stale cmake comment
70fcf65 [Wes McKinney] Add cmake PARQUET_USE_SSE option
775c72d [Wes McKinney] Fix compilation on arm7/raspberrypi

Change-Id: If8e4e7e1b7fc64df952cb8b82662bb017ca56f72
praveenbingo added a commit to praveenbingo/arrow that referenced this pull request Sep 10, 2018
…e#74)

* Temporarily matching what the dremio does for mod zero.
* Used the latest Arrow APIs for allocating buffers.
praveenbingo added a commit to praveenbingo/arrow that referenced this pull request Sep 10, 2018
…e#74)

* Temporarily matching what the dremio does for mod zero.
* Used the latest Arrow APIs for allocating buffers.
xuechendi pushed a commit to xuechendi/arrow that referenced this pull request Aug 4, 2020
@emkornfield emkornfield deleted the emk_fix_allocations_PR branch February 26, 2021 05:14
zhouyuan added a commit to zhouyuan/arrow that referenced this pull request Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants