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

Fix quadtree spatial join OOMs on large numbers of input polygons #1381

Merged

Conversation

trxcllnt
Copy link
Contributor

@trxcllnt trxcllnt commented May 7, 2024

Description

Followup to #1346.

  • Fixes some typos/omissions in types and CMake.
  • Adds a new test that OOMs when quadtree_point_in_polygon is passed too many input polygons.
  • Fixes quadtree spatial join to handle overflow while counting and more conservatively allocate output buffers.

Fixes #890.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@trxcllnt trxcllnt requested review from a team as code owners May 7, 2024 04:44
@trxcllnt trxcllnt requested review from harrism and isVoid May 7, 2024 04:44
@github-actions github-actions bot added cmake Related to CMake code or build configuration libcuspatial Relates to the cuSpatial C++ library labels May 7, 2024
@trxcllnt trxcllnt added 3 - Ready for Review Ready for review by team improvement Improvement / enhancement to an existing function non-breaking Non-breaking change and removed cmake Related to CMake code or build configuration libcuspatial Relates to the cuSpatial C++ library labels May 7, 2024
@github-actions github-actions bot added cmake Related to CMake code or build configuration libcuspatial Relates to the cuSpatial C++ library labels May 7, 2024
Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

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

Nice improvement. I think adding some of the details from your review comments as actual code comments might be valuable. But I approve.

trxcllnt added 2 commits May 10, 2024 19:09
…its and allocating the exact amount of memory for the results
Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

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

Thanks for fixing! One small request.

@trxcllnt trxcllnt added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 3 - Ready for Review Ready for review by team labels May 18, 2024
@trxcllnt
Copy link
Contributor Author

Not sure what's going on with the conda-notebook-tests job. Can we admin merge this?

Copy link
Contributor

@isVoid isVoid left a comment

Choose a reason for hiding this comment

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

One small code suggestion below. Otherwise lgtm!

Comment on lines +160 to +166
auto count_in_chunks = [&](auto const& func) {
std::uint64_t memo{};
for (std::uint64_t offset{0}; offset < num_total_points; offset += max_points_to_test) {
memo += func(memo, offset, std::min(max_points_to_test, num_total_points - offset));
}
return memo;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a count + reduce to me.. I'm ok with using a for loop in the small scope here. One small suggestion: renaming func to count_func could increase readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is a special form of std::reduce. The difference is mainly in how it passes min(max, num_left_to_process) as the size argument, which I thought would be more confusing to read if I implemented it as an iterator of [max, max, .., leftover].

@trxcllnt
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit 8840189 into rapidsai:branch-24.06 May 24, 2024
69 checks passed
@trxcllnt trxcllnt deleted the fix/quadtree-spatial-join-oom branch May 24, 2024 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge Testing and reviews complete, ready to merge cmake Related to CMake code or build configuration improvement Improvement / enhancement to an existing function libcuspatial Relates to the cuSpatial C++ library non-breaking Non-breaking change
Projects
Status: Review
Development

Successfully merging this pull request may close these issues.

[BUG]: Strange behavior with quadtree point in polygon
3 participants