Skip to content

[C++] Refactor memory allocation from InvertKernel #20710

Closed

Description

@asfimport

subtask for overall fix to remove memory allocation.  Do this first to make sure I understand the problem and acceptable solution (seems like a simple API change).

Reporter: Micah Kornfield / @emkornfield
Assignee: Micah Kornfield / @emkornfield

Note: This issue was originally created as ARROW-4121. Please see the migration documentation for further details.

Activity

  1. asfimport commented on Dec 27, 2018

    @asfimport
    Author

    Wes McKinney / @wesm:
    To be clear, we need to have a usable code path for both the case of

    • allocate memory and invoke kernel

    • invoke kernel on pre-allocated memory

      Right now we only have the first option.

      There's some code that partly handles this issue in kernels/cast.cc, but it could also benefit from some refactoring (to make the "allocate output space" problem more generic / reusable for other kernel implementations)

  2. asfimport commented on Dec 27, 2018

    @asfimport
    Author

    Micah Kornfield / @emkornfield:
    @wesm Yes, sorry misleading title. I changed it.  I'm still ramping up on the code base, so I'm not sure on the desired outcome here.

    Looking quickly at the the code in cast.cc (https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/cast.cc#L1103[)](https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/cast.cc#L710))  seems to be assuming that if the array buffers are already allocated those are fine to use.   

    It seems there are a two things that could be done:

    1. Replicate this pattern to the boolean kernels and document this contract.

    2. Change/Add API entry points to make the choice on allocation more explicit and more generic.

      My intention was to move forward with option 1, and hopefully factor out some of the code from AllocateIfNotPreallocated to a utility method.  If option 2 is desired, I would rather do a little bit more work with Kernels before I trying to propose an appropriate API.

       

  3. asfimport commented on Dec 27, 2018

    @asfimport
    Author

    Wes McKinney / @wesm:
    My preference would be to not allocate memory at all in the implementation of Call for fixed-width / primitive outputs. This is discussed as it relates to Cast in ARROW-1896.

    If the output is binary or nested then things have to be handled a bit differently

  4. asfimport commented on Feb 3, 2019

    @asfimport
    Author

    Micah Kornfield / @emkornfield:
    I attached the wrong Jira number to the PR for this (#3287)

  5. added this to the 0.14.0 milestone on Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions