You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "andygrove (via GitHub)" <gi...@apache.org> on 2025/08/14 17:56:51 UTC

[PR] chore: Simplify approach to avoiding memory corruption due to buffer reuse [wip] [datafusion-comet]

andygrove opened a new pull request, #2156:
URL: https://github.com/apache/datafusion-comet/pull/2156

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## How are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] chore: Simplify approach to avoiding memory corruption due to buffer reuse [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove merged PR #2156:
URL: https://github.com/apache/datafusion-comet/pull/2156


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] chore: Simplify approach to avoiding memory corruption due to buffer reuse [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #2156:
URL: https://github.com/apache/datafusion-comet/pull/2156#issuecomment-3191484295

   > Looks good. I don't see this changing the behavior of native_iceberg_compat though; I assume that is covered by the previous PR?
   
   I haven't made any changes specific to `native_iceberg_compat`. 
   
   The current behavior, before this current PR, is that we attempt to make deep copies just before certain operators (such as `HashJoinExec`) if we detect that the origin of the arrays was a `ScanExec` reading from the JVM (regardless of scan type). There were two bugs in the implementation:
   
   - The method `can_reuse_input_batches` was poorly implemented and missed some cases.
   - We had missed calling `wrap_in_copy_exec` for `SortMergeJoinExec`
   
   So far this week, the following related PRs were merged:
   
   - https://github.com/apache/datafusion-comet/pull/2142 improved the logic in `can_reuse_input_batches`
   - https://github.com/apache/datafusion-comet/pull/2155 added calls to `wrap_in_copy_exec` for `SortMergeJoinExec`
   
   So the current implementation is _probably_ safe now.
   
   This PR makes the logic simpler and more robust by performing the deep copy directly in `ScanExec` and removing the `can_reuse_input_batches` method. The calls to `wrap_in_copy_exec` now just create an `UnpackOrClone` rather than `UnpackOrDeepCopy`. This also allows us to remove the custom Comet version of `FilterExec`, reducing the amount of code we have to maintain.
   
   This is arguably a sledgehammer approach to ensuring that we never have memory corruption issues due to underlying buffers being reused (in the mutable Parquet buffer) or prematurely freed due to FFI lifetime bugs, but it doesn't significantly add to the number of copies that we were already making.
   
   
   
   
   


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] chore: Simplify approach to avoiding memory corruption due to buffer reuse [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #2156:
URL: https://github.com/apache/datafusion-comet/pull/2156#issuecomment-3191530617

   @mbutrovich could you review? See https://github.com/apache/datafusion-comet/pull/2156#issuecomment-3191484295 for an explanation of what other PRs were already merged and what this one does.


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] chore: Simplify approach to avoiding memory corruption due to buffer reuse [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #2156:
URL: https://github.com/apache/datafusion-comet/pull/2156#issuecomment-3191637445

   Merged. Thanks for the reviews @parthchandra and @mbutrovich 


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] chore: Simplify approach to avoiding memory corruption due to buffer reuse [datafusion-comet]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2156:
URL: https://github.com/apache/datafusion-comet/pull/2156#issuecomment-3189887768

   ## [Codecov](https://app.codecov.io/gh/apache/datafusion-comet/pull/2156?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 35.08%. Comparing base ([`f09f8af`](https://app.codecov.io/gh/apache/datafusion-comet/commit/f09f8af64c6599255e116a376f4f008f2fd63b43?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`24b64bd`](https://app.codecov.io/gh/apache/datafusion-comet/commit/24b64bdbc23d3c479b7f8a7a5a57919fb3ec2ffd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 386 commits behind head on main.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##               main    #2156       +/-   ##
   =============================================
   - Coverage     56.12%   35.08%   -21.05%     
   + Complexity      976      866      -110     
   =============================================
     Files           119      143       +24     
     Lines         11743    13198     +1455     
     Branches       2251     2368      +117     
   =============================================
   - Hits           6591     4630     -1961     
   - Misses         4012     7671     +3659     
   + Partials       1140      897      -243     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/datafusion-comet/pull/2156?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org