Skip to content

Fix includes returning true for a run of equal elements not in the first range - #7871

Merged
hkaiser merged 1 commit into
TheHPXProject:masterfrom
Vaatsal-source:fix/includes-skipped-chunk
Nov 2, 2026
Merged

hkaiser merged 1 commit into
TheHPXProject:masterfrom
Vaatsal-source:fix/includes-skipped-chunk

Conversation

@Vaatsal-source

Copy link
Copy Markdown
Contributor

Fixes #7870

Proposed Changes

  • In includes, a chunk of the second range that consists only of elements
    covered by the previous chunk no longer returns early (unless it is the
    last chunk). It continues and verifies the run of equal elements that
    starts at the next chunk. Previously this run was skipped by the next
    chunk, which relies on the previous one to have verified it, so nobody
    checked it and includes could return true although the second range
    contained elements that are not in the first range.
  • Add the regression test includes_chunk_boundary: the minimal failing
    cases for static chunk sizes 2 and 3, and an exhaustive comparison with
    std::includes for all sorted multisets over {0, 1, 2} with up to 6 and
    8 elements for static chunk sizes 1 to 4.

Any background context you want to provide?

Without this change the new test fails (151 failed checks); with it, it passes.
The existing includes and includes_empty_ranges tests pass as well.

Checklist

Not all points below apply to all pull requests.

  • I have added a new feature and have added tests to go along with it.
  • I have fixed a bug and have added a regression test.
  • I have added a test using random numbers; I have made sure it uses a seed, and that random numbers generated are valid inputs for the tests.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f51fee5a-0896-4624-bc80-8a55961d9261
Commits

Reviewing files that changed from the base of the PR and between b143fbc and 9773d0c.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 94d4224c-28e2-410c-b072-22ee3d35d346
Commits

Reviewing files that changed from the base of the PR and between 57c4757 and b143fbc.

Files selected for processing: 3
  • libs/core/algorithms/include/hpx/parallel/algorithms/includes.hpp
  • libs/core/algorithms/tests/regressions/CMakeLists.txt
  • libs/core/algorithms/tests/regressions/includes_chunk_boundary.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed incorrect results from parallel inclusion checks when matching elements span processing boundaries. Checks now correctly identify when elements are missing, including cases where a boundary contains only elements already matched earlier. This improves consistency with standard inclusion behavior across different input sizes and processing chunk sizes.

Parallel hpx::includes now continues checking an empty partition remainder unless it reaches the end of the second range. Regression tests compare parallel results with std::includes for boundary cases and generated sorted ranges.

Changes: Parallel includes boundary handling

Layer / File(s) Summary
Restrict early success to the final chunk
libs/core/algorithms/include/hpx/parallel/algorithms/includes.hpp
The algorithm returns early for an empty remainder only when it ends at last2.
Test chunk-boundary behavior
libs/core/algorithms/tests/regressions/includes_chunk_boundary.cpp, libs/core/algorithms/tests/regressions/CMakeLists.txt
The new regression test checks specific boundary cases and compares generated sorted multisets with std::includes across static chunk sizes. The regression test is added to the existing test list.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • TheHPXProject/hpx#7860: This PR changes chunk iterators in the parallel partitioner, while this change handles hpx::includes behavior at partition boundaries.
  • TheHPXProject/hpx#7844: Both PRs address duplicate-run handling across partitions in parallel set algorithms.
Merge Risk: Minimal · previous review b143f

No actionable merge-blocking risk is identified; the change is ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the specific defect fixed: parallel includes returning true for a run of equal elements outside the first range. The changeset changes includes.hpp so that only the last chunk returns …
Description check Passed The description states the bug, the chunk-boundary mechanism, the proposed early-return change, and the new includes_chunk_boundary regression test. It also reports test results. This matches the chan…
Linked Issues check Passed Issue #7870 requires parallel hpx::includes to return false when the second sorted range contains a value absent from the first. The implementation now returns early only when part_end == last2.…
Out of Scope Changes check Passed The changed files implement issue #7870, register its regression test, and add focused coverage for the chunk-boundary defect. No unrelated change is established by the supplied pull request evidence.
Full details: Title check

Explanation

The title names the specific defect fixed: parallel includes returning true for a run of equal elements outside the first range. The changeset changes includes.hpp so that only the last chunk returns early, and it adds a regression test for this case. The title matches the main change.

Full details: Description check

Explanation

The description states the bug, the chunk-boundary mechanism, the proposed early-return change, and the new includes_chunk_boundary regression test. It also reports test results. This matches the changeset, so the check passes.

Full details: Linked Issues check

Explanation

Issue #7870 requires parallel hpx::includes to return false when the second sorted range contains a value absent from the first. The implementation now returns early only when part_end == last2. Otherwise, it verifies the run that starts in the next chunk. The regression test covers static chunk sizes 2 and 3 and compares static chunk sizes 1 through 4 with std::includes over sorted multisets.

Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@StellarBot

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@hkaiser

hkaiser commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Thanks! HPX v2.0.0 has been released and master now contains it. Could you please rebase this PR onto the current master so that CI runs against the released code base? We will merge it once that is done.

…rst range

includes partitions the second range into chunks. A chunk skips its
leading run of elements equal to its first element, relying on the
previous chunk to have verified that run by extending its own range over
it. A chunk that consisted only of such elements returned true right
away and therefore never extended over the run that starts at the next
chunk, which in turn skipped it. That run was never verified, so
includes could return true although the second range contained elements
that are not in the first range.

Only return early if the chunk is the last one, otherwise continue and
verify the run starting at the next chunk.

Add a regression test with the minimal failing cases and an exhaustive
comparison with std::includes for small sorted multisets.

Fixes TheHPXProject#7870

Signed-off-by: Vaatsalya Srivastava <[email protected]>
@Vaatsal-source
Vaatsal-source force-pushed the fix/includes-skipped-chunk branch from b143fbc to 9773d0c Compare November 2, 2026 13:53
@Vaatsal-source

Copy link
Copy Markdown
Contributor Author

Rebased onto the current master (974ae9d). Thanks!

@hkaiser hkaiser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the rebase, this looks right to me. A chunk that consists only of the run already covered by the previous chunk now verifies the run starting at the next chunk instead of returning early, which is exactly what the next chunk relies on. The exhaustive comparison against std::includes covers the boundary cases nicely. The macOS failure in static_chunker_2282 is unrelated.

@hkaiser
hkaiser merged commit b24228a into TheHPXProject:master Nov 2, 2026
80 of 81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

includes returns true with a parallel policy if the second range contains a run of equal elements that is not in the first range

3 participants